edu.mit.ai.psg.jevaES
Class LeftAssociativeOperatorExpression
java.lang.Object
|
+--edu.mit.ai.psg.jevaES.SimpleNode
|
+--edu.mit.ai.psg.jevaES.JevaNode
|
+--edu.mit.ai.psg.jevaES.ExpressionNode
|
+--edu.mit.ai.psg.jevaES.LeftAssociativeOperatorExpression
- Direct Known Subclasses:
- JNEAdditiveExpression, JNEAndExpression, JNEEqualityExpression, JNEExclusiveOrExpression, JNEInclusiveOrExpression, JNEMultiplicativeExpression, JNERelationalExpression, JNEShiftExpression
- public abstract class LeftAssociativeOperatorExpression
- extends ExpressionNode
Shared implementation for left associative operators.
|
Method Summary |
abstract Object |
binaryCombine(Token operator,
Object accumResult,
Object nextResult)
binaryCombine -- combine two values, implemented in subclasses |
abstract Class |
binaryCombineTypes(Token operator,
Class accumType,
Class nextType)
binaryCombineTypes -- Class 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). |
Class |
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.jevaES.JevaNode |
getBeginToken,
getEndToken,
notVerified,
print,
print,
printToken,
printToString,
printToString,
setBeginToken,
setEndToken,
shouldNotHappen,
shouldNotHappen,
shouldNotHappen |
computeType
public Class 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:
- Class of result returned by this operator on these arguments.
- Throws:
- IllegalTypeException - if types not acceptable
- VerifyingException - if expression is illegal.
binaryCombineTypes
public abstract Class binaryCombineTypes(Token operator,
Class accumType,
Class nextType)
throws IllegalArgumentException
- binaryCombineTypes -- Class 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:
- Class 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 leftAssociatively,
using binaryCombine()
- Throws:
- ThrowException - if expression completes abruptly with 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 - if expression completes abruptly with exception