junc.ast
Class ExpressionNode

java.lang.Object
  |
  +--antlr.BaseAST
        |
        +--antlr.CommonAST
              |
              +--junc.ast.JUnCASTNode
                    |
                    +--junc.ast.ExpressionNode
All Implemented Interfaces:
antlr.collections.AST, java.io.Serializable
Direct Known Subclasses:
AdditiveExpNode, AllocationExpNode, AndExpNode, ArrayExpNode, ArrayInitializerNode, AssignmentNode, CastExpNode, ConditionalAndExpNode, ConditionalExpNode, ConditionalOrExpNode, ConstructorInvocationNode, EqualityExpNode, ExclusiveOrExpNode, FieldExpNode, InclusiveOrExpNode, InstanceOfExpNode, Literal, MethodExpNode, MultiplicativeExpNode, PostDecrementExpNode, PostIncrementExpNode, PreDecrementExpNode, PreIncrementExpNode, RelationalExpNode, ShiftExpNode, SymbolExpNode, UnaryMinusExpNode, UnaryNegExpNode, UnaryNotExpNode, UnaryPlusExpNode, VariableExpNode

public abstract class ExpressionNode
extends JUnCASTNode

Describe class ExpressionNode here.

Version:
1.0
Author:
Diwaker Gupta
See Also:
Serialized Form

Field Summary
 org.apache.bcel.generic.InstructionList falseList
          Describe variable falseList here.
 boolean leftValue
          Set to true by the parser if this expression is to the left of an assignment operator.
 boolean statementExpression
          This flag is set to true by the parser if the parent of this expression is a statement expression.
 org.apache.bcel.generic.InstructionList trueList
          Describe variable trueList here.
 junc.types.JUnCBaseType type
          Describe variable type here.
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
ExpressionNode()
           
 
Method Summary
 org.apache.bcel.generic.InstructionList addFalseList(org.apache.bcel.generic.InstructionHandle ih)
          Add an instruction to the false list for backpatching.
 org.apache.bcel.generic.InstructionList addTrueList(org.apache.bcel.generic.InstructionHandle ih)
          Add an instruction to the true list for backpatching.
 org.apache.bcel.generic.InstructionList appendToFalseList(org.apache.bcel.generic.InstructionList right)
          Append a list to the false list.
 org.apache.bcel.generic.InstructionList appendToTrueList(org.apache.bcel.generic.InstructionList right)
          Append a list to the true list.
static void backPatch(org.apache.bcel.generic.InstructionList list, org.apache.bcel.generic.InstructionHandle target)
          Backpatch a true or a false list.
 void desynthesize(org.apache.bcel.generic.ClassGen classGen, org.apache.bcel.generic.MethodGen methodGen)
          Describe desynthesize method here.
 java.math.BigDecimal evaluate(junc.symtab.SymbolTable symbolTable)
          Describe evaluate method here.
 java.math.BigDecimal evaluateExp()
          Describe evaluateExp method here.
 boolean leftValue()
          Determines if the expression is an lvalue.
 junc.types.MethodType lookupPrimop(junc.symtab.SymbolTable symbolTable, int op, junc.types.MethodType ctype)
          Describe lookupPrimop method here.
 boolean superExp()
          Determines if the expression is 'super'.
 org.apache.bcel.generic.BranchHandle synthesize(org.apache.bcel.generic.ClassGen classGen, org.apache.bcel.generic.MethodGen methodGen)
          Synthesize a boolean expression, i.e., either push a 0 or 1 onto the operand stack for the next statement to succeed.
 boolean thisExp()
          Determines if the expression is 'this'.
 boolean thisOrSuperExp()
          Determines if the expression refers to this or super.
 void translate(org.apache.bcel.generic.ClassGen classGen, org.apache.bcel.generic.MethodGen methodGen)
          Describe translate method here.
 org.apache.bcel.generic.BranchHandle translateSynthesized(org.apache.bcel.generic.ClassGen classGen, org.apache.bcel.generic.MethodGen methodGen)
          First translate the expression and then synthesize it.
 junc.types.JUnCBaseType type()
          Describe type method here.
abstract  junc.types.JUnCBaseType typeCheck(junc.symtab.SymbolTable symbolTable)
          Describe typeCheck method here.
 boolean typeExp()
          Determines if the expression refers to a type.
 boolean variableExp()
          Determines if the expression is an access to a local or a formal param.
 
Methods inherited from class junc.ast.JUnCASTNode
getColumnNumber, getLineNumber, setColumnNumber, setLineNumber
 
Methods inherited from class antlr.CommonAST
getText, getType, initialize, initialize, initialize, setText, setType
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, 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

type

public junc.types.JUnCBaseType type
Describe variable type here.


trueList

public org.apache.bcel.generic.InstructionList trueList
Describe variable trueList here.


falseList

public org.apache.bcel.generic.InstructionList falseList
Describe variable falseList here.


leftValue

public boolean leftValue
Set to true by the parser if this expression is to the left of an assignment operator.


statementExpression

public boolean statementExpression
This flag is set to true by the parser if the parent of this expression is a statement expression.

Constructor Detail

ExpressionNode

public ExpressionNode()
Method Detail

typeCheck

public abstract junc.types.JUnCBaseType typeCheck(junc.symtab.SymbolTable symbolTable)
                                           throws TypeCheckError
Describe typeCheck method here.

Specified by:
typeCheck in class JUnCASTNode
Parameters:
symbolTable - a SymbolTable value
Returns:
a JUnCBaseType value
Throws:
TypeCheckError - if an error occurs

type

public junc.types.JUnCBaseType type()
Describe type method here.

Returns:
a JUnCBaseType value

evaluateExp

public java.math.BigDecimal evaluateExp()
Describe evaluateExp method here.

Returns:
a BigDecimal value

evaluate

public java.math.BigDecimal evaluate(junc.symtab.SymbolTable symbolTable)
                              throws NotConstantException
Describe evaluate method here.

Parameters:
symbolTable - a SymbolTable value
Returns:
a BigDecimal value
Throws:
NotConstantException - if an error occurs

translate

public void translate(org.apache.bcel.generic.ClassGen classGen,
                      org.apache.bcel.generic.MethodGen methodGen)
Describe translate method here.

Parameters:
classGen - a ClassGen value
methodGen - a MethodGen value

translateSynthesized

public org.apache.bcel.generic.BranchHandle translateSynthesized(org.apache.bcel.generic.ClassGen classGen,
                                                                 org.apache.bcel.generic.MethodGen methodGen)
First translate the expression and then synthesize it. This method is redefined in those expressions that already synthesize their result to avoid synthesize, de-synthesize, synthesize sequences.

Parameters:
classGen - a ClassGen value
methodGen - a MethodGen value
Returns:
a BranchHandle value

synthesize

public org.apache.bcel.generic.BranchHandle synthesize(org.apache.bcel.generic.ClassGen classGen,
                                                       org.apache.bcel.generic.MethodGen methodGen)
Synthesize a boolean expression, i.e., either push a 0 or 1 onto the operand stack for the next statement to succeed. Returns the handle of the instruction to be backpatched.

Parameters:
classGen - a ClassGen value
methodGen - a MethodGen value
Returns:
a BranchHandle value

desynthesize

public void desynthesize(org.apache.bcel.generic.ClassGen classGen,
                         org.apache.bcel.generic.MethodGen methodGen)
Describe desynthesize method here.

Parameters:
classGen - a ClassGen value
methodGen - a MethodGen value

lookupPrimop

public junc.types.MethodType lookupPrimop(junc.symtab.SymbolTable symbolTable,
                                          int op,
                                          junc.types.MethodType ctype)
Describe lookupPrimop method here.

Parameters:
symbolTable - a SymbolTable value
op - an int value
ctype - a MethodType value
Returns:
a MethodType value

variableExp

public boolean variableExp()
Determines if the expression is an access to a local or a formal param. Redefined in the VariableExpNode class.

Returns:
a boolean value

leftValue

public boolean leftValue()
Determines if the expression is an lvalue. TODO -> check if it is final.

Returns:
a boolean value

typeExp

public boolean typeExp()
Determines if the expression refers to a type.

Returns:
a boolean value

thisExp

public boolean thisExp()
Determines if the expression is 'this'.

Returns:
a boolean value

superExp

public boolean superExp()
Determines if the expression is 'super'.

Returns:
a boolean value

thisOrSuperExp

public boolean thisOrSuperExp()
Determines if the expression refers to this or super.

Returns:
a boolean value

backPatch

public static void backPatch(org.apache.bcel.generic.InstructionList list,
                             org.apache.bcel.generic.InstructionHandle target)
Backpatch a true or a false list.

Parameters:
list - an InstructionList value
target - an InstructionHandle value

addTrueList

public org.apache.bcel.generic.InstructionList addTrueList(org.apache.bcel.generic.InstructionHandle ih)
Add an instruction to the true list for backpatching.

Parameters:
ih - an InstructionHandle value
Returns:
an InstructionList value

addFalseList

public org.apache.bcel.generic.InstructionList addFalseList(org.apache.bcel.generic.InstructionHandle ih)
Add an instruction to the false list for backpatching.

Parameters:
ih - an InstructionHandle value
Returns:
an InstructionList value

appendToTrueList

public org.apache.bcel.generic.InstructionList appendToTrueList(org.apache.bcel.generic.InstructionList right)
Append a list to the true list.

Parameters:
right - an InstructionList value
Returns:
an InstructionList value

appendToFalseList

public org.apache.bcel.generic.InstructionList appendToFalseList(org.apache.bcel.generic.InstructionList right)
Append a list to the false list.

Parameters:
right - an InstructionList value
Returns:
an InstructionList value