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.

Author:
CarlManning, caroma@ai.mit.edu
Copyright (c) 1997 Massachusetts Institute of Technology

Fields inherited from class edu.mit.ai.psg.jevaES.SimpleNode
children, id, parent
 
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)
           
 Class computeType(IEnv env)
           
 Object eval(IEnv env)
           
 
Methods inherited from class edu.mit.ai.psg.jevaES.ExpressionNode
getType, getValue, isConstant
 
Methods inherited from class edu.mit.ai.psg.jevaES.JevaNode
getBeginToken, getEndToken, print, print, printToken, printToString, printToString, setBeginToken, setEndToken
 
Methods inherited from class edu.mit.ai.psg.jevaES.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 Class computeType(IEnv env)
                  throws VerifyingException
Returns:
Class of result returned by this operator on these arguments.
Throws:
IllegalTypeException - if types not acceptable
VerifyingException - if expression is illegal.
Overrides:
computeType in class ExpressionNode

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
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 .
Overrides:
computeIsConstant in class ExpressionNode

eval

public Object eval(IEnv env)
            throws ThrowException
Returns:
evaluated children combined leftAssociatively, using binaryCombine()
Throws:
ThrowException - if expression completes abruptly with exception
Overrides:
eval in class ExpressionNode

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

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-bugs@ai.mit.edu