public class Assignment extends Statement
This AST element represents an assignment.
Example of a simple assignment: left = right
A simple assignment can be modified to represent non-standard assignments:
ILeftExpression
,
IExpression
Modifier and Type | Method and Description |
---|---|
static Assignment |
build(ILeftExpression left,
IExpression right)
Create a new assignment.
|
Operator |
getCombinedOperator()
Retrieve the combined operator of a combined assignment.
|
Operator |
getCompinedOperator()
Deprecated.
|
ILeftExpression |
getLeft()
Get the left part of the assignment.
|
IExpression |
getRight()
Get the right part of the assignment.
|
void |
getUnaryOperator(boolean[] r)
Retrieve the unary operator of a unary operator assignment.
|
boolean |
isCombinedOperatorAssignment()
Determine if the assignment is a combined assignment.
|
boolean |
isCompinedOperatorAssignment()
Deprecated.
|
boolean |
isSimpleAssignment()
Determine if the assignment is a simple assignment.
|
boolean |
isUnaryOperatorAssignment()
Determine if the assignment is a unary-operator assignment.
|
void |
setCombinedOperator(Operator operator)
Transform a simple assignment into a combined operator assignment.
|
void |
setLeft(ILeftExpression left)
Set the left part of the assignment.
|
void |
setRight(IExpression right)
Set the right part of the assignment.
|
void |
setUnaryOperator(boolean is_increment,
boolean is_prefixed)
Transform the non-unary assignment into one of the four unary assignments: ++e, e++, --e, or e--.
|
attachTag, getSubElements, isCompound, replaceSubElement, retrieveTag
public static Assignment build(ILeftExpression left, IExpression right)
Create a new assignment.
left
- mandatory left operand, being assigned toright
- mandatory right operand, being assigned frompublic ILeftExpression getLeft()
Get the left part of the assignment.
public IExpression getRight()
Get the right part of the assignment.
public void setLeft(ILeftExpression left)
Set the left part of the assignment.
left
- mandatory left expressionpublic void setRight(IExpression right)
Set the right part of the assignment. The assignment cannot be a unary assignment.
right
- mandatory right expressionpublic boolean isSimpleAssignment()
Determine if the assignment is a simple assignment.
Example: a = b
public boolean isCombinedOperatorAssignment()
Determine if the assignment is a combined assignment.
Example: a += b
public boolean isCompinedOperatorAssignment()
Typo, left for legacy purpose. Use isCombinedOperatorAssignment()
.
public void setCombinedOperator(Operator operator)
Transform a simple assignment into a combined operator assignment.
The current assignment cannot be a unary assignment, else the method will throw.
operator
- mandatory combined operator, there are eleven possibilities:MUL, DIV, ADD, SUB, REM, SHL, SHR, USHR, AND, XOR, OR
public Operator getCombinedOperator()
Retrieve the combined operator of a combined assignment.
Example: for "a += b", the operator returned would be "+"
public Operator getCompinedOperator()
Typo, left for legacy purpose. Use getCombinedOperator()
.
public boolean isUnaryOperatorAssignment()
Determine if the assignment is a unary-operator assignment.
Example: i++
or --j
public void setUnaryOperator(boolean is_increment, boolean is_prefixed)
Transform the non-unary assignment into one of the four unary assignments: ++e, e++, --e, or e--.
is_increment
- true for increment, false for decrementis_prefixed
- true for prefixed, false for postfixedpublic void getUnaryOperator(boolean[] r)
Retrieve the unary operator of a unary operator assignment.
r
- mandatory 2-element array, will be set to {is_increment, is_prefixed}