All Packages Class Hierarchy This Package Previous Next Index
Class openjava.ptree.BinaryExpression
java.lang.Object
|
+----openjava.ptree.PtreeObject
|
+----openjava.ptree.NonLeaf
|
+----openjava.ptree.BinaryExpression
- public class BinaryExpression
- extends NonLeaf
- implements Expression
The BinaryExpression
class represents
an expression which consists of an operators and two operands.
This doesn't includes the expression whose operator is
the instanceof
operator
nor the expression whose operator is one of the
assignment operators.
If the operator in the expression of the left operand or
the right operand has week unity,
this automatically produces the code in which the left operand
is enclosed by parenthesises.
In the case the left is a + b
,
the operator is *
the right is c + d
,
this produces the code :
(a + b) * (c + d)
- See Also:
- Expression, InstatnceofExpression, AssignmentExpression
-
BITAND
-
-
BITOR
-
-
DIVIDE
-
-
EQUAL
-
-
GREATER
-
-
GREATEREQUAL
-
-
INSTANCEOF
-
-
LESS
-
-
LESSEQUAL
-
-
LOGICAL_AND
-
-
LOGICAL_OR
-
-
MINUS
-
-
MOD
-
-
NOTEQUAL
-
-
PLUS
-
-
SHIFT_L
-
-
SHIFT_R
-
-
SHIFT_RR
-
-
TIMES
-
-
XOR
-
-
BinaryExpression(Expression, int, Expression)
- Allocates a new object.
-
getKind()
-
-
getLeft()
- Gets the expression of the left operand.
-
getOperator()
- Gets the id number of the operator.
-
getRight()
- Gets the expression of the right operand.
-
makeCopy()
- Makes a new copy of this nonleaf-node as a ptree-node.
-
makeRecursiveCopy()
- Makes a new copy (another object) of this nonleaf-node recursively.
-
setLeft(Expression)
- Sets the expression of the left operand.
-
setOperator(int)
- Sets the id number of the operator.
-
setRight(Expression)
- Sets the expression of the right operand.
-
strength(int)
- Returns the strength of the union of the operator.
-
writeCode()
- Writes the code this parse-tree presents for.
TIMES
public static final int TIMES
DIVIDE
public static final int DIVIDE
MOD
public static final int MOD
PLUS
public static final int PLUS
MINUS
public static final int MINUS
SHIFT_L
public static final int SHIFT_L
SHIFT_R
public static final int SHIFT_R
SHIFT_RR
public static final int SHIFT_RR
LESS
public static final int LESS
GREATER
public static final int GREATER
LESSEQUAL
public static final int LESSEQUAL
GREATEREQUAL
public static final int GREATEREQUAL
INSTANCEOF
public static final int INSTANCEOF
EQUAL
public static final int EQUAL
NOTEQUAL
public static final int NOTEQUAL
BITAND
public static final int BITAND
XOR
public static final int XOR
BITOR
public static final int BITOR
LOGICAL_AND
public static final int LOGICAL_AND
LOGICAL_OR
public static final int LOGICAL_OR
BinaryExpression
public BinaryExpression(Expression lexp,
int opr,
Expression rexp)
- Allocates a new object.
- Parameters:
- lexp - the expression of the left operand.
- opr - the id number of operator.
- rexp - the expression of the right operand.
makeRecursiveCopy
public Ptree makeRecursiveCopy()
- Makes a new copy (another object) of this nonleaf-node recursively.
- Overrides:
- makeRecursiveCopy in class NonLeaf
makeCopy
public Ptree makeCopy()
- Makes a new copy of this nonleaf-node as a ptree-node.
- Overrides:
- makeCopy in class NonLeaf
writeCode
public void writeCode()
- Writes the code this parse-tree presents for.
- Overrides:
- writeCode in class NonLeaf
strength
protected static final int strength(int op)
- Returns the strength of the union of the operator.
- Parameters:
- op - the id number of operator.
- Returns:
- the strength of the union.
getLeft
public Expression getLeft()
- Gets the expression of the left operand.
- Returns:
- the left expression.
setLeft
public void setLeft(Expression lexpr)
- Sets the expression of the left operand.
- Parameters:
- lexpr - the left expression.
getRight
public Expression getRight()
- Gets the expression of the right operand.
- Returns:
- the right expression.
setRight
public void setRight(Expression rexpr)
- Sets the expression of the right operand.
- Parameters:
- rexpr - the right expression.
getOperator
public int getOperator()
- Gets the id number of the operator.
- Returns:
- the id number of the operator.
- See Also:
- TIMES, DIVIDE, MOD, PLUS, MINUS, SHIFT_L, SHIFT_R, SHIFT_RR, LESS, GREATER, LESSEQUAL, GREATEREQUAL, INSTANCEOF, EQUAL, NOTEQUAL, BITAND, XOR, BITOR, LOGICAL_AND, LOGICAL_OR
getKind
public int getKind()
setOperator
public void setOperator(int opr)
- Sets the id number of the operator.
- Parameters:
- opr - the id number of the operator.
- See Also:
- TIMES, DIVIDE, MOD, PLUS, MINUS, SHIFT_L, SHIFT_R, SHIFT_RR, LESS, GREATER, LESSEQUAL, GREATEREQUAL, INSTANCEOF, EQUAL, NOTEQUAL, BITAND, XOR, BITOR, LOGICAL_AND, LOGICAL_OR
All Packages Class Hierarchy This Package Previous Next Index