Interface IJavaAssignment
- All Superinterfaces:
IJavaElement
,IJavaExpression
,IJavaStatement
Java AST interface to represent assignments.
Example of a simple assignment:
left = right
A simple assignment can be modified to represent non-standard assignments:
- A combined-operator assignment
- A unary-operator assignment
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
FLAG_BUILT, FLAG_FIELD_REFERENCES_OUTERCLASS, FLAG_LAMBDA_CLASS, FLAG_LAMBDA_IMPL, FLAG_OPTIONAL_RENDERING, FLAG_SECOND_PARAMETER_IS_OUTER_REF, FLAG_STICKY
-
Method Summary
Modifier and TypeMethodDescriptionDuplicate this element.Retrieve the combined operator of a combined assignment.getLeft()
Get the left part of the assignment.getRight()
Get the right part of the assignment.void
getUnaryOperator
(boolean[] r) Retrieve the unary operator of a unary operator assignment.boolean
Determine if the assignment is a combined assignment.boolean
Determine if the assignment is a regular ('=') assignment.boolean
Determine if the assignment is a unary-operator assignment.void
setCombinedOperator
(IJavaOperator operator) Transform a simple assignment into a combined operator assignment.void
setCombinedOperatorAssignment
(IJavaOperator operator, IJavaExpression right) Transform a simple assignment into a combined operator assignment.void
setLeft
(IJavaLeftExpression left) Set the left part of the assignment.void
setRight
(IJavaExpression right) Set the right part of the assignment.void
setUnaryOperator
(boolean isIncrement, boolean isPrefixed) Transform the non-unary assignment into one of the four unary assignments: postfix increment, postfix decrement, prefix increment, prefix decrement.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaElement
addFlags, addTag, canCauseException, collectAllPhysicalOffsets, generate, getData, getElementType, getFlags, getOrigin, getPhysicalMethodIndex, getPhysicalOffset, getReconAnon, getReconEnum, getReconEnummap, getReconLambda, getSubElements, getTags, hasFlags, hasPhysicalMethodIndex, hasPhysicalOffset, isReconArtifact, removeFlags, removeTag, replaceSubElement, setData, setFlags, setLambdaRecon, setOrigin, setPhysicalMethodIndex, setPhysicalOffset, setReconAnon, setReconEnum, setReconEnummap, toShortString, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPre, visitDepthPre, visitDepthPre
Methods inherited from interface com.pnfsoftware.jeb.core.units.code.java.IJavaStatement
getIntermediateOffset, setIntermediateOffset
-
Method Details
-
getLeft
IJavaLeftExpression getLeft()Get the left part of the assignment.- Returns:
-
setLeft
Set the left part of the assignment.- Parameters:
left
- mandatory left expression
-
getRight
IJavaExpression getRight()Get the right part of the assignment.- Returns:
-
setRight
Set the right part of the assignment. The assignment cannot be a unary assignment.- Parameters:
right
- mandatory right expression
-
isSimpleAssignment
boolean isSimpleAssignment()Determine if the assignment is a regular ('=') assignment.- Returns:
-
isCombinedOperatorAssignment
boolean isCombinedOperatorAssignment()Determine if the assignment is a combined assignment. There are 11 possible types of combined operators. Examples include: '+=', '-=', etc.- Returns:
-
getCombinedOperator
IJavaOperator getCombinedOperator()Retrieve the combined operator of a combined assignment.Example: for "a += b", the operator returned would be "+"
- Returns:
- the basic operator that is used to make the assignment a combined assignment
- Throws:
IllegalStateException
- if the assignment is not a combined assignment
-
setCombinedOperatorAssignment
Transform a simple assignment into a combined operator assignment. The current assignment cannot be a unary assignment, else the method will throw.- Parameters:
operator
- mandatory combined operator, there are eleven possibilities:
MUL, DIV, ADD, SUB, REM, SHL, SHR, USHR, AND, XOR, OR
right
- optional, updated right member of the assignment
-
setCombinedOperator
Transform a simple assignment into a combined operator assignment. The current assignment cannot be a unary assignment, else the method will throw.- Parameters:
operator
- mandatory combined operator, there are eleven possibilities:
MUL, DIV, ADD, SUB, REM, SHL, SHR, USHR, AND, XOR, OR
-
isUnaryOperatorAssignment
boolean isUnaryOperatorAssignment()Determine if the assignment is a unary-operator assignment.Example:
i++
or--j
- Returns:
- true if the assignment is a unary-operator assignment
-
getUnaryOperator
void getUnaryOperator(boolean[] r) Retrieve the unary operator of a unary operator assignment.- Parameters:
r
- mandatory 2-element array, will be set to {is_increment, is_prefixed}- Throws:
IllegalStateException
- if the assignment is not a unary assignment
-
setUnaryOperator
void setUnaryOperator(boolean isIncrement, boolean isPrefixed) Transform the non-unary assignment into one of the four unary assignments: postfix increment, postfix decrement, prefix increment, prefix decrement. The right member of the expression is automatically nullified.- Parameters:
isIncrement
- true for increment, false for decrementisPrefixed
- true for prefixed, false for postfixed
-
duplicate
IJavaAssignment duplicate()Description copied from interface:IJavaElement
Duplicate this element.- Specified by:
duplicate
in interfaceIJavaElement
- Specified by:
duplicate
in interfaceIJavaExpression
- Specified by:
duplicate
in interfaceIJavaStatement
- Returns:
- a (possibly) duplicated object of the same type
-