cetus.hir
Class BinaryExpression

java.lang.Object
  extended by cetus.hir.Expression
      extended by cetus.hir.BinaryExpression
All Implemented Interfaces:
Printable, Traversable, java.lang.Cloneable, java.lang.Comparable<Expression>
Direct Known Subclasses:
AccessExpression, AssignmentExpression

public class BinaryExpression
extends Expression


Field Summary
protected  BinaryOperator op
           
 
Fields inherited from class cetus.hir.Expression
children, needs_parens, object_print_method, parent
 
Constructor Summary
BinaryExpression(Expression lhs, BinaryOperator op, Expression rhs)
          Creates a binary expression.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a deep copy of this expression.
static void defaultPrint(BinaryExpression expr, java.io.OutputStream stream)
          Prints a binary expression to a stream.
 Expression getLHS()
          Returns the lefthand expression.
 BinaryOperator getOperator()
          Returns the operator of the expression.
 Expression getRHS()
          Returns the righthand expression.
static void setClassPrintMethod(java.lang.reflect.Method m)
          Overrides the class print method, so that all subsequently created objects will use the supplied method.
 void setLHS(Expression expr)
          Sets the lefthand expression.
 void setOperator(BinaryOperator op)
          Sets the operator for the expression.
 void setRHS(Expression expr)
          Sets the righthand expression.
 java.lang.String toString()
          Every expression class should override toString method.
 
Methods inherited from class cetus.hir.Expression
compareTo, equals, equals2, findExpression, getChildren, getParent, getStatement, needsParens, print, printSelf, removeChild, setChild, setParens, setParent, setPrintMethod, swapWith, verify
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

op

protected BinaryOperator op
Constructor Detail

BinaryExpression

public BinaryExpression(Expression lhs,
                        BinaryOperator op,
                        Expression rhs)
Creates a binary expression.

Parameters:
lhs - The lefthand expression.
op - A binary operator.
rhs - The righthand expression.
Method Detail

clone

public java.lang.Object clone()
Description copied from class: Expression
Creates and returns a deep copy of this expression.

Overrides:
clone in class Expression
Returns:
a deep copy of this expression.

defaultPrint

public static void defaultPrint(BinaryExpression expr,
                                java.io.OutputStream stream)
Prints a binary expression to a stream.

Parameters:
expr - The expression to print.
stream - The stream on which to print the expression.

toString

public java.lang.String toString()
Description copied from class: Expression
Every expression class should override toString method.

Overrides:
toString in class Expression

getLHS

public Expression getLHS()
Returns the lefthand expression.

Returns:
the lefthand expression.

getOperator

public BinaryOperator getOperator()
Returns the operator of the expression.

Returns:
the operator.

getRHS

public Expression getRHS()
Returns the righthand expression.

Returns:
the righthand expression.

setClassPrintMethod

public static void setClassPrintMethod(java.lang.reflect.Method m)
Overrides the class print method, so that all subsequently created objects will use the supplied method.

Parameters:
m - The new print method.

setLHS

public void setLHS(Expression expr)
Sets the lefthand expression.

Parameters:
expr - The new lefthand expression. It must not be the child of another expression.

setOperator

public void setOperator(BinaryOperator op)
Sets the operator for the expression.

Parameters:
op - The operator.

setRHS

public void setRHS(Expression expr)
Sets the righthand expression.

Parameters:
expr - The new righthand expression. It must not be the child of another expression.