All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----openjava.ptree.PtreeObject | +----openjava.ptree.NonLeaf | +----openjava.ptree.UnaryExpression
UnaryExpression
class presents for an expression which
consists of unary operator with one Expression.
expr++
,expr--
,++expr
,--expr
,^expr
,!expr
,+expr
or-expr
expr is an expression.
If the operator in the expression of the operand has week unity,
this automatically produces the code in which the operand
is enclosed by parenthesises.
In the case the operand is y = x
and
the urary operator is +
,
this produces the code :
+(y = x)
- See Also:
- NonLeaf, Expression
-
BITNOT
- Post increment operator like:
~i
-
MINUS
- Post increment operator like:
-i
-
NOT
- Post increment operator like:
! c
-
PLUS
- Post increment operator like:
+i
-
POST_DEC
- Post decrement operator like:
i--
-
POST_INC
- Post increment operator like:
i++
-
PRE_DEC
- Post increment operator like:
--i
-
PRE_INC
- Pre increment operator like:
++i
-
UnaryExpression(Expression, int)
- Allocates a new object.
-
UnaryExpression(int, Expression)
- Allocates a new object.
-
getExpression()
- Gets the expression operated in this expression.
-
getKind()
-
-
getOperator()
- Gets the operator of this unary expression.
-
isPostfix()
- Tests if the operator of unary expression is a postfix operator.
-
isPrefix()
- Tests if the operator of unary expression is a prefix operator.
-
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.
-
setExpression(Expression)
- Sets the expression operated in this expression.
-
setOperator(int)
- Sets the operator of this unary expression.
-
writeCode()
- Writes the code this parse-tree presents for.
POST_INC
public static final int POST_INC
- Post increment operator like:
i++
POST_DEC
public static final int POST_DEC
- Post decrement operator like:
i--
PRE_INC
public static final int PRE_INC
- Pre increment operator like:
++i
PRE_DEC
public static final int PRE_DEC
- Post increment operator like:
--i
BITNOT
public static final int BITNOT
- Post increment operator like:
~i
NOT
public static final int NOT
- Post increment operator like:
! c
PLUS
public static final int PLUS
- Post increment operator like:
+i
MINUS
public static final int MINUS
- Post increment operator like:
-i
UnaryExpression
public UnaryExpression(int opr,
Expression expr)
- Allocates a new object.
- Parameters:
- opr - the operator of this unary expression.
- expr - the expression.
UnaryExpression
public UnaryExpression(Expression expr,
int opr)
- Allocates a new object.
- Parameters:
- expr - the expression.
- opr - the operator of this unary expression.
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
getExpression
public Expression getExpression()
- Gets the expression operated in this expression.
- Returns:
- the expression.
setExpression
public void setExpression(Expression expr)
- Sets the expression operated in this expression.
- Parameters:
- expr - the expression to set.
getOperator
public int getOperator()
- Gets the operator of this unary expression.
- Returns:
- the operator.
- See Also:
- POST_INC, POST_DEC, PRE_INC, PRE_DEC, BITNOT, NOT, PLUS, MINUS
getKind
public int getKind()
setOperator
public void setOperator(int opr)
- Sets the operator of this unary expression.
- Parameters:
- opr - the operator id to set.
- See Also:
- POST_INC, POST_DEC, PRE_INC, PRE_DEC, BITNOT, NOT, PLUS, MINUS
isPostfix
public boolean isPostfix()
- Tests if the operator of unary expression is a postfix operator.
- Returns:
- true if the operator is postfix.
isPrefix
public boolean isPrefix()
- Tests if the operator of unary expression is a prefix operator.
- Returns:
- true if the operator is prefix.
All Packages Class Hierarchy This Package Previous Next Index