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
Field Summary |
static int |
BIT_NOT
Post increment operator like:
|
static int |
MINUS
Post increment operator like:
|
static int |
NOT
Post increment operator like:
|
static int |
PLUS
Post increment operator like:
|
static int |
POST_DECREMENT
Post decrement operator like:
|
static int |
POST_INCREMENT
Post increment operator like:
|
static int |
PRE_DECREMENT
Post increment operator like:
|
static int |
PRE_INCREMENT
Pre increment operator like:
|
Methods inherited from class openjava.ptree.NonLeaf |
childrenAccept, elementAt, equals, getComment, getContents, getLength, replaceChildWith, set, set, set, set, set, set, set, set, set, setComment, setElementAt |
Methods inherited from class openjava.ptree.ParseTreeObject |
clone, eq, eq, equal, flushPrintWriter, getDebugFlag, getNest, getObjectID, getParent, getPrintWriter, getTab, hashCode, lastObjectID, popNest, popPrintWriter, pushNest, pushPrintWriter, replace, setDebugFlag, setDebugLevel, setNest, setParent, setPrintStream, setTab, toFlattenString, toString, writeDebug, writeDebugL, writeDebugLln, writeDebugln, writeDebugLR, writeDebugR, writeDebugRln, writeTab |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
POST_INCREMENT
public static final int POST_INCREMENT
- Post increment operator like:
i++
POST_DECREMENT
public static final int POST_DECREMENT
- Post decrement operator like:
i--
PRE_INCREMENT
public static final int PRE_INCREMENT
- Pre increment operator like:
++i
PRE_DECREMENT
public static final int PRE_DECREMENT
- Post increment operator like:
--i
BIT_NOT
public static final int BIT_NOT
- 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 ParseTree makeRecursiveCopy()
- Description copied from interface:
ParseTree
- Makes a new copy (another object) of this nonleaf-node recursively.
The objects contained by this object will also be copied.
- Specified by:
makeRecursiveCopy
in interface ParseTree
- Overrides:
makeRecursiveCopy
in class NonLeaf
- Following copied from interface:
openjava.ptree.ParseTree
- Returns:
- the copy of this nonleaf-node as a ptree-node.
makeCopy
public ParseTree makeCopy()
- Description copied from interface:
ParseTree
- Makes a new copy of this nonleaf-node as a ptree-node.
The objects contained by the new object are same as
these contained by the original object.
- Specified by:
makeCopy
in interface ParseTree
- Overrides:
makeCopy
in class ParseTreeObject
- Following copied from interface:
openjava.ptree.ParseTree
- Returns:
- the copy of this nonleaf-node as a ptree-node.
writeCode
public void writeCode()
- Description copied from class:
NonLeaf
- Writes the code this parse-tree presents for.
- Specified by:
writeCode
in interface ParseTree
- 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_INCREMENT
,
POST_DECREMENT
,
PRE_INCREMENT
,
PRE_DECREMENT
,
BIT_NOT
,
NOT
,
PLUS
,
MINUS
setOperator
public void setOperator(int opr)
- Sets the operator of this unary expression.
- Parameters:
opr
- the operator id to set.- See Also:
POST_INCREMENT
,
POST_DECREMENT
,
PRE_INCREMENT
,
PRE_DECREMENT
,
BIT_NOT
,
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.
operatorString
public java.lang.String operatorString()
accept
public void accept(ParseTreeVisitor v)
throws ParseTreeException
- Description copied from interface:
ParseTree
- Accepts a
ParseTreeVisitor
object as the role of a
Visitor in the Visitor pattern, as the role of an Element in the
Visitor pattern.
This invoke an appropriate visit()
method on the
accepted visitor.
- Specified by:
accept
in interface ParseTree
- Overrides:
accept
in class ParseTreeObject
- Following copied from interface:
openjava.ptree.ParseTree
- Parameters:
visitor
- a visitor
getType
public OJClass getType(Environment env)
throws java.lang.Exception
- Specified by:
getType
in interface Expression