com.pnfsoftware.jeb.core.units.code.asm.decompiler.ir.IEGeneric |
![]() |
Base class for an Intermediate Representation Expression ("IRE") used byJEB's native decompilation pipeline ("GENDEC").
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract boolean | accessesMemory() | ||||||||||
abstract void | addFlags(int addedFlags) | ||||||||||
abstract IECompose | asCompose() | ||||||||||
abstract IECond | asCond() | ||||||||||
abstract IEGroup | asGroup() | ||||||||||
abstract IEGroupElt | asGroupElt() | ||||||||||
abstract IEImm | asImm() | ||||||||||
abstract IEMem | asMem() | ||||||||||
abstract IEOperation | asOperation() | ||||||||||
abstract IERange | asRange() | ||||||||||
abstract IESlice | asSlice() | ||||||||||
abstract IEStatement | asStatement() | ||||||||||
abstract IEVar | asVar() | ||||||||||
abstract IEGeneric |
bit(int pos)
Retrieve a one bit value at the pos position
| ||||||||||
abstract void |
collectSubExpressions(Collection<IEGeneric> sink)
Perform a shallow collection of the sub-expressions of this expression.
| ||||||||||
abstract IECond |
countSuccessiveBits(boolean ones, boolean fromMsb, int bitsize)
Count successive bits in an integer, starting from MSB or LSB.
| ||||||||||
abstract IEGeneric |
duplicate()
Clone (deep copy) the expression.
| ||||||||||
abstract boolean |
equalsEx(Object obj, boolean includeType)
Same as #equals() with the possibility to include the type in the comparisson.
| ||||||||||
abstract IEImm |
evaluate(EState state)
Evaluate the IRE.
| ||||||||||
abstract long |
evaluateAddress(EState state)
Evaluate the IRE as a 64-bit address.@return
| ||||||||||
abstract long |
evaluateUnsignedLong(EState state)
Evaluate the IRE as an unsigned long value.
| ||||||||||
abstract boolean |
examine(Predicate<IEGeneric> tester)
Visit the constituents of this expression, and check if one of them is passing the provided
test.
| ||||||||||
abstract Couple<IEGeneric, IEGeneric> |
find(IEGeneric elt, int start, int comparisonMethod, IEGeneric thisParent)
Find the parent of the the provided child element.
| ||||||||||
abstract <T extends IEGeneric> T |
findByType(Class<T> clazz, int start)
Find a child element by type.
| ||||||||||
abstract <T extends IEGeneric> T |
findByType(Class<T> clazz)
Find the first child element by type.
| ||||||||||
abstract IEGeneric |
findParent(IEGeneric elt, int start)
Find the parent of the the provided child element.
| ||||||||||
abstract IEGeneric |
findParent(IEGeneric elt)
Find the parent of the first instance of the provided child element.
| ||||||||||
abstract ICElement |
generateC(IERoutineContext ectx, ICMethod cctx)
Generate the C abstract syntax tree portion for this expression.
| ||||||||||
abstract int |
getBitsize()
Get the size, in bits, of the IR expression.
| ||||||||||
abstract void |
getDefinedOrUsedAsDestination(EDefUseInfo defuse)
For
non-statements only. | ||||||||||
abstract void |
getExplicitlyUsed(EDefUseInfo defuse)
Get a list of variable or variable bits 'explicitly used' (read) by the instruction.
| ||||||||||
abstract IdRanges |
getExplicitlyUsed()
Convenience method around #getExplictlyUsed(EDefUseInfo).
| ||||||||||
abstract int | getFlags() | ||||||||||
abstract int |
getPriority()
Get the base priority level of the expression.
| ||||||||||
abstract IWildcardType |
getSafeType(IWildcardTypeManager etypeman)
Generate a safe wildcard type for the expression, if it doesn't already have one.
| ||||||||||
abstract void |
getSubExpressions(List<IEGeneric> list)
This method is deprecated.
use
collectSubExpressions(Collection) instead | ||||||||||
abstract IWildcardType |
getType()
Get the currently set intermediate-type.
| ||||||||||
abstract IdRanges |
getUsed()
Convenience method around
getUsed(EDefUseInfo) . | ||||||||||
abstract void |
getUsed(EDefUseInfo defuse)
Retrieve the variables or variable bits 'used' (read) by the instruction.
| ||||||||||
abstract boolean | hasFlags(int checkedFlags) | ||||||||||
abstract boolean | isCompose() | ||||||||||
abstract boolean | isCond() | ||||||||||
abstract boolean | isGroup() | ||||||||||
abstract boolean | isGroupElt() | ||||||||||
abstract boolean | isImm() | ||||||||||
abstract boolean | isMem() | ||||||||||
abstract boolean | isOperation(String name) | ||||||||||
abstract boolean | isOperation() | ||||||||||
abstract boolean | isOperation(OperationType... candidateOps) | ||||||||||
abstract boolean | isOperation(OperationType expectedOp) | ||||||||||
abstract boolean | isRange() | ||||||||||
abstract boolean | isSlice() | ||||||||||
abstract boolean | isSlice(int wantedStart, int wantedEnd) | ||||||||||
abstract boolean | isStatement() | ||||||||||
abstract boolean | isVar() | ||||||||||
abstract boolean | isVar(int wantedVarId) | ||||||||||
abstract IEGeneric |
leftShift(int shift)
left shift of an expression
| ||||||||||
abstract IEGeneric |
leftShift(int shift, int bitsize)
left shift of an expression, with an optional
slice(int, int) | ||||||||||
abstract IEGeneric |
lsb()
Return the least significant bit (lsb) of an expression.
| ||||||||||
abstract IEGeneric |
msb()
Return the most significant bit (msb) of an expression.
| ||||||||||
abstract IEGeneric |
part(int cnt)
Equivalent to
slice(0, cnt) | ||||||||||
abstract void | removeFlags(int removedFlags) | ||||||||||
abstract boolean |
replaceSubExpression(IEGeneric oldExp, IEGeneric newExp)
Shallow replacement, by reference.
| ||||||||||
abstract int |
replaceVar(IEVar var, IEGeneric repl)
Deep replace.
| ||||||||||
abstract IEGeneric |
rightShift(int shift)
right shift of an expression
| ||||||||||
abstract IEGeneric |
rightShift(int shift, int bitsize)
right shift of an expression, with an optional
slice(int, int) | ||||||||||
abstract IWildcardType |
safelyType(IWildcardTypeManager etypeman)
Generate and assign a safe wildcard type to the expression if it doesn't already have one.
| ||||||||||
abstract void | setFlags(int newFlags) | ||||||||||
abstract boolean |
setType(IWildcardType newType, ETypeInfo ti, boolean forceUpdate)
Set a pre-propagation intermediate-type.
| ||||||||||
abstract boolean |
setType(IWildcardType newType, ETypeInfo ti)
Set a pre-propagation intermediate-type.
| ||||||||||
abstract boolean |
setType(IWildcardType type)
Set a pre-propagation intermediate-type.
| ||||||||||
abstract IEGeneric |
signExtend(int newBitsize)
Sign extend the current
IEGeneric . | ||||||||||
abstract IEGeneric |
slice(IERange r)
Slice of an
IEGeneric . | ||||||||||
abstract IEGeneric |
slice(int begin)
Equivalent to
slice(begin, . | ||||||||||
abstract IEGeneric |
slice(int begin, int end)
Slice of an
IEGeneric . | ||||||||||
abstract void |
updateTypes(ETypeInfo ti)
Deep update the types of the constituents of this IRE, update the IRE type as well the direct
constituents if needed.
| ||||||||||
abstract void |
verify()
Verify the legality of this IR expression.
| ||||||||||
abstract boolean |
visitDepthPost(IEVisitor visitor, IEGeneric parent)
Depth-first search, post-order visit of an expression tree or sub-tree.
| ||||||||||
abstract boolean |
visitDepthPost(IEVisitor visitor, IEGeneric parent, EVisitResults results)
Depth-first search, post-order visit of an expression tree or sub-tree.
| ||||||||||
abstract boolean |
visitDepthPost(IEVisitor visitor)
Depth-first search, post-order visit of an expression tree or sub-tree.
| ||||||||||
abstract boolean |
visitDepthPre(IEVisitor visitor, IEGeneric parent)
Depth-first search, pre-order visit of an expression tree or sub-tree.
| ||||||||||
abstract boolean |
visitDepthPre(IEVisitor visitor)
Depth-first search, pre-order visit of an expression tree or sub-tree.
| ||||||||||
abstract boolean |
visitDepthPre(IEVisitor visitor, IEGeneric parent, EVisitResults results)
Depth-first search, pre-order visit of an expression tree or sub-tree.
| ||||||||||
abstract IEGeneric |
zeroExtend(int newBitsize)
Zero extend the current
IEGeneric |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Retrieve a one bit value at the pos position
pos | bit position to be retrieved |
---|
IEGeneric
of size 1 with bit at position `pos`
Perform a shallow collection of the sub-expressions of this expression. All collected expressions are directly rooted in this IRE (i.e. their parent is this IR expression).
This method appends to the provided sink (existing elements are not cleared). The current element (this) is not appended; only the sub-expressions are considered.
Count successive bits in an integer, starting from MSB or LSB.
ones | true if '1's should be counted, false for '0's |
---|---|
fromMsb | true if count should start from MSB, false from LSB |
Clone (deep copy) the expression.
Same as #equals() with the possibility to include the type in the comparisson.
obj | object to compare |
---|
Evaluate the IRE.
state | IR state (input and output) |
---|
EvaluationException | thrown if the state is configured to hard-fail on errors (default) |
---|
Evaluate the IRE as a 64-bit address.@return
EvaluationException | thrown if the state is configured to hard-fail on errors (default) |
---|
Evaluate the IRE as an unsigned long value. This convenience method will throw if the underlying immediate bit size exceeds 63 bits (unsigned value).
EvaluationException | thrown if the state is configured to hard-fail on errors (default) |
---|
Visit the constituents of this expression, and check if one of them is passing the provided test.
tester | a predicate object examining the IEGeneric elements of this expression |
---|
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. IEVar) |
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. IEVar) |
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 C abstract syntax tree portion for this expression.
ectx | IR routine context |
---|---|
cctx | C routine local context |
Get the size, in bits, of the IR expression. It is illegal to query The bitsize of some expressions.
For non-statements
only. Assuming 'this' is a destination value, extract
the variable or variable bits that are used and defined by it.
defuse | sink - both the `def` and `use` field may be modified |
---|
Get a list of variable or variable bits 'explicitly used' (read) by the instruction. This method is inherently deep.
defuse | sink - only the `use` field is modified |
---|
Convenience method around #getExplictlyUsed(EDefUseInfo).
Get the base priority level of the expression. Higher number correlates to lower priority; 0 means "no priority". (Therefore, the highest priority level is 1.)
Generate a safe wildcard type for the expression, if it doesn't already have one. If generated, the type is NOT assigned to the IR expression.
This method is deprecated.
use collectSubExpressions(Collection)
instead
Shallow collection of this expression's constituents, in evaluation order. Appends to `list` (existing elements are not cleared). The current element (this) is not appended, only the descendants are considered.
list | non-null output list |
---|
Convenience method around getUsed(EDefUseInfo)
.
Retrieve the variables or variable bits 'used' (read) by the instruction. This method is inherently deep.
Note that some IRE may implicitly use variables, such as some ECall
,
PC-assigns
, UntranslatedInstruction
. This
method returns those implicit uses.
defuse | sink - only the `use` field is modified |
---|
left shift of an expression
shift | left shift value |
---|
IEGeneric
left shifted by the shift value
left shift of an expression, with an optional slice(int, int)
shift | left shift value |
---|
IEGeneric
left shifted by the shift value
Return the least significant bit (lsb) of an expression. No duplicate is done, it is up to
caller to duplicate current IEGeneric
if needed.
Return the most significant bit (msb) of an expression. No duplicate is done, it is up to
caller to duplicate current IEGeneric
if needed.
Equivalent to slice(0, cnt)
cnt | wanted bit count |
---|
Shallow replacement, by reference. Only the first occurrence is replaced.
Be careful when replacing immediates or variables. Unexpected behaviors may happen if the expression contains multiple instances of the same imm or var.
oldExp | the expression to be replaced |
---|---|
newExp | the new expression, whose type must be consistent with the expression replaced |
Deep replace. All matching variables
are replaced. The implementation is
responsible for duplicating the IR expressions, to ensure that the resulting statement or
group of statement does not contain duplicate references to mutable objects.
right shift of an expression
shift | right shift value |
---|
IEGeneric
right shifted by the shift value
right shift of an expression, with an optional slice(int, int)
shift | right shift value |
---|
IEGeneric
right shifted by the shift value
Generate and assign a safe wildcard type to the expression if it doesn't already have one.
Set a pre-propagation intermediate-type. Does not propagate/update type in the super- or sub-expression.
newType | the new type; may be null |
---|---|
ti | optional type-setting information structure, contains information about how many types were set, the list of type conflicts, etc. |
forceUpdate | true to force a type update even if the new type is less speciialized (has a lesser score) than the currently existing type |
Set a pre-propagation intermediate-type. Does not propagate/update type in the super- or sub-expression. Not forced.
newType | the new type; may be null |
---|---|
ti | optional type-setting information structure, contains information about how many types were set, the list of type conflicts, etc. |
Set a pre-propagation intermediate-type. Does not propagate/update type in the super- or sub-expression.
type | the new type; may be null |
---|
Sign extend the current IEGeneric
. This method will create a valid IEGeneric
(meaning IEGeneric
will not have duplicates id - in particular, in the form C(x,
x.msb()?ones():zeros()) where x will be present in base value and msb predicate)
newBitsize | must be superior to getBitsize()
|
---|
Deep update the types of the constituents of this IRE, update the IRE type as well the direct constituents if needed. Not forced. When this method is called, it is the responsibility to verify that the constituent IREs are typeable, and if not, to make them typeable (eg, EImm updates, EVar copies, etc.).
ti | types update information; provides access to a wildcard
type manager , and used to record typing conflicts
|
---|
Verify the legality of this IR expression.
IllegalIntermediateExpressionException | if the IRE is deemed invalid or illegal |
---|
Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
Pre-order visits offer more options than post order visits: the visitor may decide to skip children; to skip the destination of assignments. However, replacement of nodes requires additional code to register the new node. Conversely, post-order visits do not offer any specific option, but provide the simplest way to replace nodes.
Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
Pre-order visits offer more options than post order visits: the visitor may decide to skip children; to skip the destination of assignments. However, replacement of nodes requires additional code to register the new node. Conversely, post-order visits do not offer any specific option, but provide the simplest way to replace nodes.
visitor | the visitor object |
---|
Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.
Pre-order visits offer more options than post order visits: the visitor may decide to skip children; to skip the destination of assignments. However, replacement of nodes requires additional code to register the new node. Conversely, post-order visits do not offer any specific option, but provide the simplest way to replace nodes.
Depth-first search, pre-order visit of an expression tree or sub-tree. The node being visited may be replaced, but the client code is responsible for EVisitResults#setReplacedNode(IEGeneric) notifying the visitor.
Pre-order visits offer more options than post order visits: the visitor may decide to skip children; to skip the destination of assignments. However, replacement of nodes requires additional code to register the new node. Conversely, post-order visits do not offer any specific option, but provide the simplest way to replace nodes.
Depth-first search, pre-order visit of an expression tree or sub-tree. The node being visited may be replaced, but the client code is responsible for EVisitResults#setReplacedNode(IEGeneric) notifying the visitor.
Pre-order visits offer more options than post order visits: the visitor may decide to skip children; to skip the destination of assignments. However, replacement of nodes requires additional code to register the new node. Conversely, post-order visits do not offer any specific option, but provide the simplest way to replace nodes.
Depth-first search, pre-order visit of an expression tree or sub-tree. The node being visited may be replaced, but the client code is responsible for EVisitResults#setReplacedNode(IEGeneric) notifying the visitor.
Pre-order visits offer more options than post order visits: the visitor may decide to skip children; to skip the destination of assignments. However, replacement of nodes requires additional code to register the new node. Conversely, post-order visits do not offer any specific option, but provide the simplest way to replace nodes.
visitor | the visitor object |
---|
Zero extend the current IEGeneric
newBitsize | must be superior to getBitsize()
|
---|