ast
Class BinaryExpr

java.lang.Object
  extended by ast.ASTNode
      extended by ast.Expr
          extended by ast.BinaryExpr
Direct Known Subclasses:
BinaryArithExpr, BinaryCompExpr, BinaryLogicExpr

public abstract class BinaryExpr
extends Expr

The abstract BinaryExpr class represents binary expressions whose operands are both expressions (i.e., this does not include assignments, instanceof, etc.). It can be either a comparison expression ('==', '!=', '<', '>', '<=', '>='), an arithmetic expression ('+', '-', '*', '/', '%'), or a boolean expression ('&&', '||'). It contains a lefthand expression and a righthand expression. Subclasses of this class can be handled similarly within the compiler, so most functionality can be implemented in the visitor method for this class.

See Also:
ASTNode, Expr

Field Summary
protected  Expr leftExpr
          The lefthand expression
protected  Expr rightExpr
          The righthand expression
 
Fields inherited from class ast.ASTNode
charNum, lineNum, lineStr
 
Constructor Summary
BinaryExpr(int lineNum, Expr leftExpr, Expr rightExpr)
          BinaryExpr constructor
 
Method Summary
abstract  java.lang.Object accept(visitor.Visitor v, java.lang.Object o)
          Visitor method
 Expr getLeftExpr()
          Get the lefthand expression
abstract  java.lang.String getOperandType()
          Get the operand type (e.g., "int") (must be defined by each subclass)
abstract  java.lang.String getOpName()
          Get the operation name (e.g., "+") (must be defined by each subclass)
abstract  java.lang.String getOpType()
          Get the operation type (e.g., "int") (must be defined by each subclass)
 Expr getRightExpr()
          Get the righthand expression
 
Methods inherited from class ast.Expr
getExprType, setExprType
 
Methods inherited from class ast.ASTNode
getLineNum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftExpr

protected Expr leftExpr
The lefthand expression


rightExpr

protected Expr rightExpr
The righthand expression

Constructor Detail

BinaryExpr

public BinaryExpr(int lineNum,
                  Expr leftExpr,
                  Expr rightExpr)
BinaryExpr constructor

Parameters:
lineNum - source line number corresponding to this AST node
leftExpr - left operand expression
rightExpr - right operand expression
Method Detail

getLeftExpr

public Expr getLeftExpr()
Get the lefthand expression

Returns:
lefthand expression

getRightExpr

public Expr getRightExpr()
Get the righthand expression

Returns:
righthand expression

getOpName

public abstract java.lang.String getOpName()
Get the operation name (e.g., "+") (must be defined by each subclass)

Returns:
op name

getOpType

public abstract java.lang.String getOpType()
Get the operation type (e.g., "int") (must be defined by each subclass)

Returns:
op type

getOperandType

public abstract java.lang.String getOperandType()
Get the operand type (e.g., "int") (must be defined by each subclass)

Returns:
operand type

accept

public abstract java.lang.Object accept(visitor.Visitor v,
                                        java.lang.Object o)
Visitor method

Specified by:
accept in class Expr
Parameters:
v - visitor object
o - object to pass down
Returns:
result of visiting this node
See Also:
Visitor