com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression |
![]() |
Base interface for all dexdec
IR expressions, such as IR instructions, fields/attributes,
immediates, variables/identifiers, operations, etc.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract IDArrayElt | asArrayElt() | ||||||||||
abstract IDCallInfo | asCallInfo() | ||||||||||
abstract IDReferenceType |
asClassReference()
This method is deprecated.
use
asReferenceType() instead
| ||||||||||
abstract IDImm | asImm() | ||||||||||
abstract IDInstanceField | asInstanceField() | ||||||||||
abstract IDInstruction | asInstruction() | ||||||||||
abstract IDNewArrayInfo | asNewArrayInfo() | ||||||||||
abstract IDNewInfo | asNewInfo() | ||||||||||
abstract IDOperation | asOperation() | ||||||||||
abstract IDPredicate | asPredicate() | ||||||||||
abstract IDReferenceType | asReferenceType() | ||||||||||
abstract IDStaticField | asStaticField() | ||||||||||
abstract IDVar | asVar() | ||||||||||
abstract boolean |
canThrow(IDMethodContext ctx)
Determine whether a hypothetical execution of this IR expression could throw.
| ||||||||||
abstract void |
collectAllPhysicalOffsets(Collection<Integer> physicalOffsets)
Gather all physical offsets for this element and all its constituents.
| ||||||||||
abstract void |
collectSubExpressions(List<IDExpression> sink)
Collect all sub-expressions of this expression, in evaluation order.
| ||||||||||
abstract void |
collectVarIds(Set<Integer> sink)
Recursively collect all the variable ids used and defined by this expression.
| ||||||||||
abstract IDExpression |
copy(DCopyOptions opt)
Copy this element.
| ||||||||||
abstract int |
countIdentifier(IDVar var)
This method is deprecated.
use
countVariable(IDVar) instead
| ||||||||||
abstract int |
countVariable(IDVar var)
Count how many times a given identifier is present in an expression.
| ||||||||||
abstract IDExpression |
duplicate()
Duplicate this element.
| ||||||||||
abstract IDImm |
evaluate(IDState state)
Evaluate this expression.
| ||||||||||
abstract IDImm |
evaluate(IDGlobalContext g, Map<Integer, IDImm> varmap)
Convenience method: evaluate a
non-instruction IR expression using the
provided set a variable values. | ||||||||||
abstract IDImm |
evaluate(IDMethodContext ctx)
Convenience method: Evaluate this expression within the context of the provided method.
| ||||||||||
abstract Couple<IDExpression, IDExpression> |
find(IDExpression elt, int start, int comparisonMethod, IDExpression thisParent)
Find the parent of the the provided child element.
| ||||||||||
abstract <T extends IDExpression> T |
findByType(Class<T> clazz, int start)
Find a child element by type.
| ||||||||||
abstract <T extends IDExpression> T |
findByType(Class<T> clazz)
Find the first child element by type.
| ||||||||||
abstract IDExpression |
findParent(IDExpression elt, int start)
Find the parent of the the provided child element.
| ||||||||||
abstract IDExpression |
findParent(IDExpression elt)
Find the parent of the first instance of the provided child element.
| ||||||||||
abstract IJavaElement |
generateAST(IDMethodContext ctx, IJavaMethod m)
Generate the Java AST element for this IR expression.
| ||||||||||
abstract Boolean |
getCustomCanThrow()
Retrieve the custom override set for
canThrow(IDMethodContext) . | ||||||||||
abstract Object |
getData(String key)
Retrieve a value from this IR element's data map.
| ||||||||||
abstract String |
getOrigin()
Retrieve the origin info string of this IR element, if there is one.
| ||||||||||
abstract int |
getPhysicalOffset()
Retrieve the physical offset (dalvik) associated with this IR.
| ||||||||||
abstract List<IDExpression> |
getSubExpressions()
Convenience method used to retrieve all the sub-expressions of this IR, in evaluation order.
| ||||||||||
abstract IJavaType |
getType()
Get the IR expression type.
| ||||||||||
abstract Set<Integer> |
getVarIds()
Recursively collect all the variable ids used and defined by this expression.
| ||||||||||
abstract boolean |
hasSideEffects(IDMethodContext ctx, boolean includeCanThrow)
Determine whether a hypothetical execution of this IR expression would change the program
internal state.
| ||||||||||
abstract boolean | isArrayElt() | ||||||||||
abstract boolean | isCallInfo(String wantedMsig) | ||||||||||
abstract boolean | isCallInfo() | ||||||||||
abstract boolean | isCastOperation(IJavaType expectedCastType) | ||||||||||
abstract boolean | isCastOperation() | ||||||||||
abstract boolean |
isClassReference()
This method is deprecated.
use
isReferenceType() instead
| ||||||||||
abstract boolean | isConstantImm() | ||||||||||
abstract boolean | isImm() | ||||||||||
abstract boolean | isInstanceField() | ||||||||||
abstract boolean | isInstruction() | ||||||||||
abstract boolean | isNewArrayInfo() | ||||||||||
abstract boolean | isNewInfo() | ||||||||||
abstract boolean | isOperation(JavaOperatorType expectedOperatorType) | ||||||||||
abstract boolean | isOperation(JavaOperatorType expectedOperatorType1, JavaOperatorType expectedOperatorType2, JavaOperatorType expectedOperatorType3) | ||||||||||
abstract boolean | isOperation() | ||||||||||
abstract boolean | isOperation(JavaOperatorType expectedOperatorType1, JavaOperatorType expectedOperatorType2, JavaOperatorType expectedOperatorType3, JavaOperatorType expectedOperatorType4, JavaOperatorType expectedOperatorType5) | ||||||||||
abstract boolean | isOperation(JavaOperatorType expectedOperatorType1, JavaOperatorType expectedOperatorType2, JavaOperatorType expectedOperatorType3, JavaOperatorType expectedOperatorType4) | ||||||||||
abstract boolean | isOperation(JavaOperatorType expectedOperatorType1, JavaOperatorType expectedOperatorType2, JavaOperatorType expectedOperatorType3, JavaOperatorType expectedOperatorType4, JavaOperatorType expectedOperatorType5, JavaOperatorType expectedOperatorType6) | ||||||||||
abstract boolean | isOperation(JavaOperatorType expectedOperatorType1, JavaOperatorType expectedOperatorType2) | ||||||||||
abstract boolean | isPredicate() | ||||||||||
abstract boolean | isReferenceType() | ||||||||||
abstract boolean | isStaticField() | ||||||||||
abstract boolean |
isStringConstant()
This method is deprecated.
use
isStringImm()
| ||||||||||
abstract boolean | isStringImm() | ||||||||||
abstract boolean | isVar() | ||||||||||
abstract boolean | isVar(int wantedVarId) | ||||||||||
abstract void |
removeData(String key)
Remove an entry from this IR element's data map.
| ||||||||||
abstract int |
replaceIdentifier(IDVar var, IDExpression repl)
This method is deprecated.
use
replaceVariable(IDVar, IDExpression) instead
| ||||||||||
abstract boolean |
replaceSubExpression(IDExpression target, IDExpression repl)
Replace an expression of this IR.
| ||||||||||
abstract int |
replaceVariable(IDVar var, IDExpression repl)
Deep replace all matching variables by the provided expression.
| ||||||||||
abstract void |
setCustomCanThrow(Boolean elemenCanThrow)
Set a custom override for
canThrow(IDMethodContext) . | ||||||||||
abstract void |
setData(String key, Object value)
Store a key-value pair in this IR element's data map.
| ||||||||||
abstract void |
setOrigin(String origin)
Set an optional origin info string for this IR element.
| ||||||||||
abstract void |
setPhysicalOffset(int physicalOffset)
Set the main physical offset associated with this IR.
| ||||||||||
abstract boolean |
setType(IJavaType newType)
Update the type of an expression.
| ||||||||||
abstract boolean |
setType(IJavaType newType, DTypeInfo ti)
Update the type of an expression.
| ||||||||||
abstract boolean |
setType(IJavaType newType, DTypeInfo ti, boolean forceUpdate)
Update the type of an expression.
| ||||||||||
abstract void |
transferMetadataFrom(IDExpression srcExp)
Transfer (shallow copy) metadata from a source IR to this IR.
| ||||||||||
abstract void |
updateAllPhysicalOffsets(int physicalOffset)
Update the physical offset of this element and all its constituents.
| ||||||||||
abstract void |
updateTypes(DTypeInfo ti)
Deep update the types of the constituents of this IR expression and update to determine the
IR type as well.
| ||||||||||
abstract boolean |
visitDepthPost(IDVisitor visitor, IDExpression parent, DVisitResults results)
Visit this expression and its constituents, depth-first post-order.
| ||||||||||
abstract boolean |
visitDepthPost(IDVisitor visitor, IDExpression parent)
Visit this expression and its constituents, depth-first post-order.
| ||||||||||
abstract boolean |
visitDepthPost(IDVisitor visitor)
Visit this expression and its constituents, depth-first post-order.
| ||||||||||
abstract boolean |
visitDepthPre(IDVisitor visitor)
Visit this expression and its constituents, depth-first pre-order.
| ||||||||||
abstract boolean |
visitDepthPre(IDVisitor visitor, IDExpression parent, DVisitResults results)
Visit this expression and its constituents, depth-first pre-order.
| ||||||||||
abstract boolean |
visitDepthPre(IDVisitor visitor, IDExpression parent)
Visit this expression and its constituents, depth-first pre-order.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Determine whether a hypothetical execution of this IR expression could throw.
This method is not fail-safe, it works on a best-effort basis.
ctx | mandatory method context |
---|
Gather all physical offsets for this element and all its constituents.
physicalOffsets | sink; it is recommended to provide a Set to avoid the collection of duplicates |
---|
Collect all sub-expressions of this expression, in evaluation order. If the full expression
were to be evaluated at runtime, a sub-expression at index i
in the list would be
evaluated before a sub-expression at index i+1
.
sink | a list to which all sub-expressions will be added |
---|
Recursively collect all the variable ids used and defined by this expression.
sink | collection receiving the variable ids |
---|
Copy this element. This operation can be seen as a custom duplication; the resulting element may not be of the same type as this element.
opt | optional; if one is provided, onDup(IDExpression) will be
tried first to create a copy |
---|
Count how many times a given identifier is present in an expression. Matching is done using
same
.
var | a variable |
---|
Duplicate this element.
Evaluate this expression.
Note about evaluating instructions: When evaluating an IDInstruction
, a context and
frame must be present in the state. The value of PC is not directly updated after the
execution of this instruction. Instead, the next expected PC is stored in the current frame,
and can be retrieved via getNextPC()
. Only the evaluation of
ASSIGN
, RETURN
, INVOKE
IR instructions may return a value; else, the
method will return null.
To perform emulation of a stub of IR with full controls, use methods in IDState
directly.
state | a machine state |
---|
reference-immediate
!)DexDecEvaluationException | on evaluation error |
---|
Convenience method: evaluate a non-instruction
IR expression using the
provided set a variable values.
g | global IR context |
---|---|
varmap | a map of variable values to be used when evaluating the expression |
reference-immediate
!)DexDecEvaluationException |
---|
Convenience method: Evaluate this expression within the context of the provided method.
See important note in evaluate(IDState)
.
ctx | method context |
---|
reference-immediate
!)DexDecEvaluationException | on evaluation error |
---|
Find the parent of the the provided child element.
elt | an IR element; if the element is this , the method will return null |
---|---|
start | count of instances of elt that should be skipped before returning the
parent element; this is useful is the element provided may not be unique within
the tree (e.g. var) |
comparisonMethod | 0= identity, 1= equality, 2= type-less equality |
thisParent | optional parent of this IR element |
Find a child element by type.
clazz | type of the element to be found; careful, if the type is the one of
this , then this object will be returned |
---|---|
start | count of matched elements that should be skipped before returning the element |
Find the first child element by type.
clazz | type of the element to be found; careful, if the type is the one of
this , then this object will be returned |
---|
Find the parent of the the provided child element. The comparison is done by identity.
elt | an IR element; if the element is this , the method will return null |
---|---|
start | count of instances of elt that should be skipped before returning the
parent element; this is useful is the element provided may not be unique within
the tree (e.g. var) |
Find the parent of the first instance of the provided child element. The comparison is done by identity.
elt | an IR element; if the element is this , the method will return null |
---|
Generate the Java AST element for this IR expression.
ctx | IR method context (of which this IR element belongs) |
---|---|
m | AST Method context (of which the resulting AST element will belong) |
Retrieve the custom override set for canThrow(IDMethodContext)
. See
setCustomCanThrow(Boolean)
for details.
Note: Currently, the custom value is only supported by IDArrayElt
.
Retrieve a value from this IR element's data map.
key | mandatory key |
---|
Retrieve the origin info string of this IR element, if there is one.
Retrieve the physical offset (dalvik) associated with this IR.
Convenience method used to retrieve all the sub-expressions of this IR, in evaluation order.
Uses collectSubExpressions(List)
.
Recursively collect all the variable ids used and defined by this expression.
Determine whether a hypothetical execution of this IR expression would change the program internal state.
This method is not fail-safe, it works on a best-effort basis.
ctx | method context |
---|---|
includeCanThrow | if true, the possibility of this IR to raise exceptions is checked and considered to be a side-effect |
IDCallInfo
or its sub-type IDNewInfo
invoking
the provided method signature
IDCallInfo
or its sub-type IDNewInfo
IDImm
holding a non-reference immediate, that is, a
primitive value or a pooled string. (For references, including the null references,
this method will return false.)
expectedOperatorType | an operator type |
---|
operation
of the provided type
expectedOperatorType1 | an operator type |
---|---|
expectedOperatorType2 | an operator type |
expectedOperatorType3 | an operator type |
operation
of any of the provided types
IDOperation
or its sub-type IDPredicate
expectedOperatorType1 | an operator type |
---|---|
expectedOperatorType2 | an operator type |
expectedOperatorType3 | an operator type |
expectedOperatorType4 | an operator type |
expectedOperatorType5 | an operator type |
operation
of any of the provided types
expectedOperatorType1 | an operator type |
---|---|
expectedOperatorType2 | an operator type |
expectedOperatorType3 | an operator type |
expectedOperatorType4 | an operator type |
operation
of any of the provided types
expectedOperatorType1 | an operator type |
---|---|
expectedOperatorType2 | an operator type |
expectedOperatorType3 | an operator type |
expectedOperatorType4 | an operator type |
expectedOperatorType5 | an operator type |
expectedOperatorType6 | an operator type |
operation
of any of the provided types
expectedOperatorType1 | an operator type |
---|---|
expectedOperatorType2 | an operator type |
operation
of any of the provided types
IDImm
holding a pooled String constant. (String
references are not constants.)
Remove an entry from this IR element's data map.
Replace an expression of this IR. This method does not perform deep replacement. The target expression is compared by equality.
target | IR expression to be replaced |
---|---|
repl | replacement expression |
Deep replace all matching variables by the provided expression. Important notes:
- Matching is done by reference equality (IDVar
are factory-created, no two variables
created by the same context can have the same id)
- When a replacement is to be performed, a duplication
of
repl
is done and used as the replacement expression to avoid reuse.
- The exploration is recursive: the constituents are explored for replacement.
- If this expression is itself an identifier, it will not be replaced; only the constituents
are matched for replacement.
var | target variable to be replaced |
---|---|
repl | expression that will replace the identifier |
Set a custom override for canThrow(IDMethodContext)
. If one is set,
canThrow(IDMethodContext)
will return the override value instead of performing
regular verifications to determine whether the IR element may raise.
Note: Currently, the custom value is only supported by IDArrayElt
.
elemenCanThrow | custom value, null to reset |
---|
Store a key-value pair in this IR element's data map.
key | mandatory key |
---|---|
value | mandatory value |
Set an optional origin info string for this IR element. Note that the origin is stored as an entry in the data map.
Set the main physical offset associated with this IR.
physicalOffset | an offset, -1 for none |
---|
Update the type of an expression.
newType | mandatory new type |
---|
Update the type of an expression.
newType | mandatory new type |
---|---|
ti | optional type information object, used to record type update results |
Update the type of an expression.
newType | mandatory new type |
---|---|
ti | optional type information object, used to record type update results |
forceUpdate | if true, the new type will always be set (compatibility checks are bypassed) |
Transfer (shallow copy) metadata from a source IR to this IR. Currently, this includes the physical offset and the data map.
srcExp | source IR expression |
---|
Update the physical offset of this element and all its constituents.
physicalOffset | new physical offset, -1 to reset (to none) |
---|
Deep update the types of the constituents of this IR expression and update to determine the IR type as well.
ti | optional type information object, used to record type updates and conflicts |
---|
Visit this expression and its constituents, depth-first post-order.
visitor | visitor object |
---|---|
parent | the optional parent of this expression |
results | an optional result object provided to the visitor, containing flags used to customize the visiting process |
DVisitResults
when visiting an element
Visit this expression and its constituents, depth-first post-order.
visitor | visitor object |
---|---|
parent | the optional parent of this expression |
DVisitResults
when visiting an element
Visit this expression and its constituents, depth-first post-order.
visitor | visitor object |
---|
DVisitResults
when visiting an element
Visit this expression and its constituents, depth-first pre-order.
If the visitor replaces an element, the new element must be specified by calling DVisitResults#setReplacedNode(IDExpression) setReplacedNode().
visitor | visitor object |
---|
DVisitResults
when visiting an element
Visit this expression and its constituents, depth-first pre-order.
If the visitor replaces an element, the new element must be specified by calling DVisitResults#setReplacedNode(IDExpression) setReplacedNode().
visitor | visitor object |
---|---|
parent | the optional parent of this expression |
results | an optional result object provided to the visitor, containing flags used to customize the visiting process |
DVisitResults
when visiting an element
Visit this expression and its constituents, depth-first pre-order.
If the visitor replaces an element, the new element must be specified by calling DVisitResults#setReplacedNode(IDExpression) setReplacedNode().
visitor | visitor object |
---|---|
parent | the optional parent of this expression |
DVisitResults
when visiting an element