jparse.expr
Class ExpressionAST

java.lang.Object
  extended byantlr.BaseAST
      extended byantlr.CommonAST
          extended byantlr.CommonASTWithHiddenTokens
              extended byjparse.JavaAST
                  extended byjparse.expr.ExpressionAST
All Implemented Interfaces:
antlr.collections.AST, HasExceptions, Serializable
Direct Known Subclasses:
ArithmeticAST, ArrayInitAST, AssignAST, BitwiseAST, BooleanAST, BooleanLiteralAST, CharLiteralAST, ConditionalAST, FloatLiteralAST, IdentifierAST, IndexAST, InitializerAST, ListAST, MethodCallAST, NewAST, NullLiteralAST, NumLiteralAST, ParenthesizedAST, ShiftAST, StringLiteralAST, TypecastAST, UnaryArithAST

public abstract class ExpressionAST
extends JavaAST
implements HasExceptions

An AST node that represents an expression

Author:
Jerry James
See Also:
Serialized Form

Field Summary
protected  Type[] exceptions
          The checked exceptions this expression might throw
static Object nonconstant
          A dummy object that indicates that an expression is not constant
private static Object noVal
          A dummy object used to determine when the value has been computed
protected  Type type
          The type of this expression
protected  Object value
          The constant value of this expression (possibly wrapped), or null if the expression is not constant
 
Fields inherited from class jparse.JavaAST
context, currSymTable, noTypes, symTable, topLevel, typeAST
 
Fields inherited from class antlr.CommonASTWithHiddenTokens
hiddenAfter, hiddenBefore
 
Fields inherited from class antlr.CommonAST
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
protected ExpressionAST()
          Create a new expression AST
protected ExpressionAST(antlr.Token token)
          Create a new expression AST
 
Method Summary
protected abstract  Type[] computeExceptions()
          Compute the checked exception types that might be thrown by this expression
protected abstract  Type computeType()
          Compute the type of this expression
protected abstract  Object computeValue()
          Compute the constant value of this expression, if any
 Type[] getExceptionTypes()
          Get the checked exception types that might be thrown by this expression
 Object getValue()
          Get the constant value of this expression, if it has one, or null if it does not
abstract  VarList getVarList()
          Get the list of variables read and written by this expression
 Type retrieveType()
          Retrieve the type of this expression
 
Methods inherited from class jparse.JavaAST
parseComplete, print, printHiddenAfter, printHiddenBefore
 
Methods inherited from class antlr.CommonASTWithHiddenTokens
getHiddenAfter, getHiddenBefore, initialize
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getColumn, getFirstChild, getLine, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toString, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

noVal

private static final Object noVal
A dummy object used to determine when the value has been computed


nonconstant

public static final Object nonconstant
A dummy object that indicates that an expression is not constant


type

protected Type type
The type of this expression


exceptions

protected Type[] exceptions
The checked exceptions this expression might throw


value

protected Object value
The constant value of this expression (possibly wrapped), or null if the expression is not constant

Constructor Detail

ExpressionAST

protected ExpressionAST()
Create a new expression AST


ExpressionAST

protected ExpressionAST(antlr.Token token)
Create a new expression AST

Parameters:
token - the token represented by this AST node
Method Detail

retrieveType

public final Type retrieveType()
Retrieve the type of this expression

Returns:
the type of this expression

computeType

protected abstract Type computeType()
Compute the type of this expression

Returns:
the type of this expression

getExceptionTypes

public final Type[] getExceptionTypes()
Get the checked exception types that might be thrown by this expression

Specified by:
getExceptionTypes in interface HasExceptions
Returns:
an array of types representing the exceptions that this expression might throw

computeExceptions

protected abstract Type[] computeExceptions()
Compute the checked exception types that might be thrown by this expression

Returns:
an array of types representing the exceptions that this expression might throw

getValue

public final Object getValue()
Get the constant value of this expression, if it has one, or null if it does not

Returns:
the constant value (if any) of this expression, as a wrapped primitive type or an object type

computeValue

protected abstract Object computeValue()
Compute the constant value of this expression, if any

Returns:
the constant value (if any) of this expression, as a wrapped primitive type or an object type

getVarList

public abstract VarList getVarList()
Get the list of variables read and written by this expression

Returns:
the list of variables read and written by this expression