edu.mit.ai.psg.jeva
Class LeftAssociativeOperatorExpression

java.lang.Object
  |
  +--edu.mit.ai.psg.jeva.SimpleNode
        |
        +--edu.mit.ai.psg.jeva.JevaNode
              |
              +--edu.mit.ai.psg.jeva.ExpressionNode
                    |
                    +--edu.mit.ai.psg.jeva.LeftAssociativeOperatorExpression
Direct Known Subclasses:
JNEAdditiveExpression, JNEAndExpression, JNEEqualityExpression, JNEExclusiveOrExpression, JNEInclusiveOrExpression, JNEMultiplicativeExpression, JNERelationalExpression, JNEShiftExpression

public abstract class LeftAssociativeOperatorExpression
extends ExpressionNode

Shared implementation for left associative operators.


Fields inherited from class edu.mit.ai.psg.jeva.SimpleNode
children, id, parent
 
Method Summary
abstract  Object binaryCombine(Token operator, Object accumResult, Object nextResult)
          binaryCombine -- combine two values, implemented in subclasses
abstract  IClass binaryCombineTypes(Token operator, IClass accumType, IClass nextType)
          binaryCombineTypes -- IClass of result of combining two types; implemented in subclasses
 boolean computeIsConstant(IEnv env)
          Compute whether this expression is a constant (nodes should not call this method directly).
 IClass computeType(IEnv env)
          Compute the static type of the expression (nodes should not call this method directly).
 Object eval(IEnv env)
          Evaluate this expression (nodes should not call this method directly).
 
Methods inherited from class edu.mit.ai.psg.jeva.ExpressionNode
getType, getType, getValue, isConstant
 
Methods inherited from class edu.mit.ai.psg.jeva.JevaNode
checkInsertionPoint, find2ndTokenBeforeEndBody, findChildIndex, findPrecedingToken, findTokenBeforeChild, findTokenBeforeChild, findTokenBeforeEnd, getBeginToken, getEndToken, insertChildTokens, insertNewChildAfter, insertNewChildAt, insertNewChildBefore, jjtAccept, jnGetChild, jnGetParent, notVerified, print, print, printSpecialTokens, printToken, printToString, printToString, removeChild, removeChildTokens, replaceChild, replaceChild, setBeginToken, setEndToken, shouldNotHappen, shouldNotHappen, shouldNotHappen, updateEndTokens, updateEndTokensPriorChild, updateEndTokensPriorNode, updateEndTokensPriorNode
 
Methods inherited from class edu.mit.ai.psg.jeva.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

computeType

public IClass computeType(IEnv env)
                   throws VerifyingException
Description copied from class: ExpressionNode
Compute the static type of the expression (nodes should not call this method directly). Called by getType.
Overrides:
computeType in class ExpressionNode
Returns:
IClass of result returned by this operator on these arguments.
Throws:
IllegalTypeException - if types not acceptable
VerifyingException - if expression is illegal.

binaryCombineTypes

public abstract IClass binaryCombineTypes(Token operator,
                                          IClass accumType,
                                          IClass nextType)
binaryCombineTypes -- IClass of result of combining two types; implemented in subclasses
Parameters:
operator - is the Token between expressions (e.g., +,-,*,/,...)
accumResult - is result of accumulating the expressions to the left of the operator.
nextResult - is result of evaluating the next expression to the right of the operator.
Returns:
IClass of result of the combining accumResult and nextResult with operator.
Throws:
IllegalArgumentException - if types not acceptable

computeIsConstant

public boolean computeIsConstant(IEnv env)
                          throws VerifyingException
Description copied from class: ExpressionNode
Compute whether this expression is a constant (nodes should not call this method directly). Called by the isConstant method.
Overrides:
computeIsConstant in class ExpressionNode
Returns:
true if result of this expression is constant. Default is true if all subexpressions are constant, but subclasses may override this behavior.
Throws:
VerifyingException - if expression is illegal.

eval

public Object eval(IEnv env)
            throws ThrowException
Description copied from class: ExpressionNode
Evaluate this expression (nodes should not call this method directly). Called by the getValue method.
Overrides:
eval in class ExpressionNode
Returns:
evaluated children combined using binaryCombine()
Throws:
ThrowException - if completes abruptly with an exception

binaryCombine

public abstract Object binaryCombine(Token operator,
                                     Object accumResult,
                                     Object nextResult)
                              throws ThrowException
binaryCombine -- combine two values, implemented in subclasses
Parameters:
operator - is the Token between expressions (e.g., +,-,*,/,...)
accumResult - is result of accumulating the expressions to the left of the operator.
nextResult - is result of evaluating the next expression to the right of the operator.
Returns:
result of the combining accumResult and nextResult with operator
Throws:
ThrowException - wraps exception thrown by operator.

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu