All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class openjava.ptree.UnaryExpression

java.lang.Object
   |
   +----openjava.ptree.PtreeObject
           |
           +----openjava.ptree.NonLeaf
                   |
                   +----openjava.ptree.UnaryExpression

public class UnaryExpression
extends NonLeaf
implements Expression
The UnaryExpression class presents for an expression which consists of unary operator with one Expression.
The unary expressions are :
expr++, expr--, ++expr, --expr, ^expr, !expr, +expr or -expr

,where 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

Variable Index

 o BITNOT
Post increment operator like:
     ~i
 

 o MINUS
Post increment operator like:
     -i
 

 o NOT
Post increment operator like:
     ! c
 

 o PLUS
Post increment operator like:
     +i
 

 o POST_DEC
Post decrement operator like:
     i--
 

 o POST_INC
Post increment operator like:
     i++
 

 o PRE_DEC
Post increment operator like:
     --i
 

 o PRE_INC
Pre increment operator like:
     ++i
 

Constructor Index

 o UnaryExpression(Expression, int)
Allocates a new object.
 o UnaryExpression(int, Expression)
Allocates a new object.

Method Index

 o getExpression()
Gets the expression operated in this expression.
 o getKind()
 o getOperator()
Gets the operator of this unary expression.
 o isPostfix()
Tests if the operator of unary expression is a postfix operator.
 o isPrefix()
Tests if the operator of unary expression is a prefix operator.
 o makeCopy()
Makes a new copy of this nonleaf-node as a ptree-node.
 o makeRecursiveCopy()
Makes a new copy (another object) of this nonleaf-node recursively.
 o setExpression(Expression)
Sets the expression operated in this expression.
 o setOperator(int)
Sets the operator of this unary expression.
 o writeCode()
Writes the code this parse-tree presents for.

Variables

 o POST_INC
 public static final int POST_INC
Post increment operator like:
     i++
 

 o POST_DEC
 public static final int POST_DEC
Post decrement operator like:
     i--
 

 o PRE_INC
 public static final int PRE_INC
Pre increment operator like:
     ++i
 

 o PRE_DEC
 public static final int PRE_DEC
Post increment operator like:
     --i
 

 o BITNOT
 public static final int BITNOT
Post increment operator like:
     ~i
 

 o NOT
 public static final int NOT
Post increment operator like:
     ! c
 

 o PLUS
 public static final int PLUS
Post increment operator like:
     +i
 

 o MINUS
 public static final int MINUS
Post increment operator like:
     -i
 

Constructors

 o UnaryExpression
 public UnaryExpression(int opr,
                        Expression expr)
Allocates a new object.

Parameters:
opr - the operator of this unary expression.
expr - the expression.
 o UnaryExpression
 public UnaryExpression(Expression expr,
                        int opr)
Allocates a new object.

Parameters:
expr - the expression.
opr - the operator of this unary expression.

Methods

 o makeRecursiveCopy
 public Ptree makeRecursiveCopy()
Makes a new copy (another object) of this nonleaf-node recursively.

Overrides:
makeRecursiveCopy in class NonLeaf
 o makeCopy
 public Ptree makeCopy()
Makes a new copy of this nonleaf-node as a ptree-node.

Overrides:
makeCopy in class NonLeaf
 o writeCode
 public void writeCode()
Writes the code this parse-tree presents for.

Overrides:
writeCode in class NonLeaf
 o getExpression
 public Expression getExpression()
Gets the expression operated in this expression.

Returns:
the expression.
 o setExpression
 public void setExpression(Expression expr)
Sets the expression operated in this expression.

Parameters:
expr - the expression to set.
 o 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
 o getKind
 public int getKind()
 o 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
 o isPostfix
 public boolean isPostfix()
Tests if the operator of unary expression is a postfix operator.

Returns:
true if the operator is postfix.
 o 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