public interface

IDInstruction

implements ILocatedInstruction IDExpression
com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction

Class Overview

dexdec IR instruction object. Each intermediate representation instruction has:
- an opcode: refer to DOpcodeType
- zero, one, or two operands, of type IDElement
- an offset (in the IR)
- a size

IR CFGs consist of basic blocks made of IR instructions. An IDMethodContext references it IR CFG. IR instructions can also be created via the createXxx methods of the context object.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
Public Methods
abstract void adjustSize(int delta)
Adjust this instruction's IR size.
abstract IDInstruction copy(DCopyOptions opt)
Copy this element.
abstract void copyBaseFields(IDInstruction sourceInsn)
Copy all base fields, that is all fields but the opcode and operands of the source instruction to this instruction.
abstract int countUsedIdentifier(IDVar var)
Count the number of times the provided variable is used (read) by this instruction.
abstract IDInstruction duplicate()
Deep copy of this instruction.
abstract IDInstruction duplicateForReplacement(IDInstruction replacedInsn)
Duplicate this instruction with the intent to replace the source instruction.
abstract IDExpression getAssignDestination()
abstract IDExpression getAssignSource()
abstract int getBranchTarget()
abstract IDMethodContext getContext()
Retrieve the IR method context to which this instruction belongs.
abstract IDVar getDefinedIdentifier()
Get the identifier defined (written) by this method, if there is one.
abstract IDInvokeInfo getInvokeData()
abstract IDPredicate getJcondCondition()
abstract long getOffset()
IR offsets are 32-bit integers; they can be safely cast to int.
abstract long getOffsetEnd()
Retrieve the end offset (exclusive) of this instruction
abstract DOpcodeType getOpcode()
Get this instruction opcode.
abstract IDElement getOperand1()
Get the first operand.
abstract IDElement getOperand2()
Get the second operand.
abstract IDExpression getReturnExpression()
abstract IDSwitchData getSwitchData()
abstract IDExpression getSwitchExpression()
abstract IDExpression getThrowExpression()
abstract IJavaType getTypeForDefinedIdentifier(IDVar var)
Retrieve the type of the identifier defined by this instruction, if any.
abstract IJavaType getTypeForUsedIdentifier(IDVar var)
Retrieve the type of an identifier used by this instruction.
abstract List<IDVar> getUsedIdentifiers()
Get the identifiers used (read) by this method.
abstract boolean isAssign()
abstract boolean isInvoke()
abstract boolean isJcond()
abstract boolean isJump()
abstract boolean isMonitorEnter()
abstract boolean isMonitorExit()
abstract boolean isNop()
abstract boolean isReturn()
abstract boolean isStoreException()
abstract boolean isSwitch()
abstract boolean isThrow()
abstract void morph(DOpcodeType opcode, IDElement opnd1, IDElement opnd2)
This dangerous method allows changing an IR instruction into a different one, while keeping metadata (e.g.
abstract int replaceUsedIdentifier(IDVar var, IDExpression repl)
Replace all used identifiers (per same()) of this instruction.
abstract IDExpression setAssignDestination(IDExpression dst)
abstract IDExpression setAssignSource(IDExpression src)
abstract int setBranchTarget(int offset)
Update the branch target for unconditional and conditional jumps only.
abstract IDPredicate setJcondCondition(IDPredicate cond)
abstract void setOffset(long offset)
Set this instruction's IR offset.
abstract void setOpcode(DOpcodeType opcode)
Change the instruction opcode.
abstract void setOperand1(IDElement opnd)
Change the instruction first operand.
abstract void setOperand2(IDElement opnd)
Change the instruction second operand.
abstract IDExpression setReturnExpression(IDExpression exp)
abstract void setSize(int size)
Set this instruction's IR size.
abstract IDSwitchData setSwitchData(IDSwitchData swdata)
abstract IDExpression setSwitchExpression(IDExpression exp)
abstract IDExpression setThrowExpression(IDExpression exp)
abstract boolean setTypeForDefinedIdentifier(IDVar var, IJavaType type)
Set the type of the identifier defined by this instruction, if any.
abstract boolean setTypeForUsedIdentifier(IDVar var, IJavaType type)
Set the type of an identifier used by this instruction.
abstract void transformJcondToAssign(IDVar dst)
Transform a conditional jump instruction to a conditional-predicate assignment.
abstract void transformJcondToJump()
Transform a conditional jump instruction to a jump.
abstract void transformToJump(IDTarget target)
Transform any instruction to a jump, and update the jump target.
abstract void transformToNop()
Transform any instruction to a NOP.
abstract void verify()
Verify this instruction.
abstract boolean visitInstruction(IDVisitor visitor, boolean skipAssignmentDestination)
Visit this instruction and its constituents.
abstract boolean visitInstruction(IDVisitor visitor)
Visit this instruction and its constituents.
abstract boolean visitInstructionPostOrder(IDVisitor visitor, boolean skipAssignmentDestination)
Visit this instruction and its constituents.
abstract boolean visitInstructionPreOrder(IDVisitor visitor, boolean skipAssignmentDestination)
Visit this instruction and its constituents.
[Expand]
Inherited Methods
From interface com.pnfsoftware.jeb.core.units.code.IInstruction
From interface com.pnfsoftware.jeb.core.units.code.IInstructionOperand
From interface com.pnfsoftware.jeb.core.units.code.ILocatedInstruction
From interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
From interface com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression

Public Methods

public abstract void adjustSize (int delta)

Adjust this instruction's IR size. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.

Parameters
delta added to the current size

public abstract IDInstruction copy (DCopyOptions opt)

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.

Parameters
opt optional; if one is provided, onDup(IDExpression) will be tried first to create a copy
Returns
  • the copied element

public abstract void copyBaseFields (IDInstruction sourceInsn)

Copy all base fields, that is all fields but the opcode and operands of the source instruction to this instruction.

public abstract int countUsedIdentifier (IDVar var)

Count the number of times the provided variable is used (read) by this instruction.

Example (ASSIGN opcode): x = y * (y + z) => x is not used; y is used twice; z is used once

public abstract IDInstruction duplicate ()

Deep copy of this instruction.

Returns
  • a deep copy of this element; the type of the duplicated element should be the same as this element's type

public abstract IDInstruction duplicateForReplacement (IDInstruction replacedInsn)

Duplicate this instruction with the intent to replace the source instruction. The offset and size of the source instruction are copied over to the newly created instruction.

public abstract IDExpression getAssignDestination ()

public abstract IDExpression getAssignSource ()

public abstract int getBranchTarget ()

public abstract IDMethodContext getContext ()

Retrieve the IR method context to which this instruction belongs. The method context holds all information regarding a current method decompilation. It is also a factory to create more IDInstruction objects.

public abstract IDVar getDefinedIdentifier ()

Get the identifier defined (written) by this method, if there is one. Only IR_ASSIGN and IR_STORE_EXCEPTION may define (write) identifiers.

public abstract IDInvokeInfo getInvokeData ()

public abstract IDPredicate getJcondCondition ()

public abstract long getOffset ()

IR offsets are 32-bit integers; they can be safely cast to int.

Returns
  • the instruction offset/address

public abstract long getOffsetEnd ()

Retrieve the end offset (exclusive) of this instruction

public abstract DOpcodeType getOpcode ()

Get this instruction opcode.

public abstract IDElement getOperand1 ()

Get the first operand. May be null if the opcode does not specify one. Refer to getOpcode() and DOpcodeType.

public abstract IDElement getOperand2 ()

Get the second operand. May be null if the opcode does not specify one. Refer to getOpcode() and DOpcodeType.

public abstract IDExpression getReturnExpression ()

public abstract IDSwitchData getSwitchData ()

public abstract IDExpression getSwitchExpression ()

public abstract IDExpression getThrowExpression ()

public abstract IJavaType getTypeForDefinedIdentifier (IDVar var)

Retrieve the type of the identifier defined by this instruction, if any. Convenience method.

public abstract IJavaType getTypeForUsedIdentifier (IDVar var)

Retrieve the type of an identifier used by this instruction. Convenience method.

public abstract List<IDVar> getUsedIdentifiers ()

Get the identifiers used (read) by this method.

public abstract boolean isAssign ()

Returns

public abstract boolean isInvoke ()

Returns
  • true if this instruction is an invocation (call, new)

public abstract boolean isJcond ()

Returns

public abstract boolean isJump ()

Returns
  • true if this instruction is a jump (goto)

public abstract boolean isMonitorEnter ()

Returns

public abstract boolean isMonitorExit ()

Returns

public abstract boolean isNop ()

Returns
  • true if this instruction is a nop

public abstract boolean isReturn ()

Returns
  • true if this instruction is a return

public abstract boolean isStoreException ()

Returns

public abstract boolean isSwitch ()

Returns
  • true if this instruction is a switch

public abstract boolean isThrow ()

Returns
  • true if this instruction is a throw

public abstract void morph (DOpcodeType opcode, IDElement opnd1, IDElement opnd2)

This dangerous method allows changing an IR instruction into a different one, while keeping metadata (e.g. offset, size, etc.) intact.

public abstract int replaceUsedIdentifier (IDVar var, IDExpression repl)

Replace all used identifiers (per same()) of this instruction. Recursive method. Note: the replacement expression is duplicated to avoid reuse. Defined identifiers (if any) are not replaced.

Parameters
var identifier
repl expression that will replace the identifier
Returns
  • the number of replacements

public abstract IDExpression setAssignDestination (IDExpression dst)

public abstract IDExpression setAssignSource (IDExpression src)

public abstract int setBranchTarget (int offset)

Update the branch target for unconditional and conditional jumps only. This function fails for all other opcodes, including switches.

Parameters
offset the new offset
Returns
  • previous value

public abstract IDPredicate setJcondCondition (IDPredicate cond)

public abstract void setOffset (long offset)

Set this instruction's IR offset. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.

public abstract void setOpcode (DOpcodeType opcode)

Change the instruction opcode. This method is dangerous. Instruction operands may require an update as well.

public abstract void setOperand1 (IDElement opnd)

Change the instruction first operand. This method is dangerous. Other instruction attributes may require an update as well.

public abstract void setOperand2 (IDElement opnd)

Change the instruction second operand. This method is dangerous. Other instruction attributes may require an update as well.

public abstract IDExpression setReturnExpression (IDExpression exp)

public abstract void setSize (int size)

Set this instruction's IR size. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.

public abstract IDSwitchData setSwitchData (IDSwitchData swdata)

public abstract IDExpression setSwitchExpression (IDExpression exp)

public abstract IDExpression setThrowExpression (IDExpression exp)

public abstract boolean setTypeForDefinedIdentifier (IDVar var, IJavaType type)

Set the type of the identifier defined by this instruction, if any. Convenience method.

public abstract boolean setTypeForUsedIdentifier (IDVar var, IJavaType type)

Set the type of an identifier used by this instruction. Convenience method.

public abstract void transformJcondToAssign (IDVar dst)

Transform a conditional jump instruction to a conditional-predicate assignment. It is the caller's responsibility to verify that the instruction is a JCOND.

 IF pred GOTO target ==> dst = pred
 

Parameters
dst the destination operand for the predicate

public abstract void transformJcondToJump ()

Transform a conditional jump instruction to a jump. It is the caller's responsibility to verify that the instruction is a JCOND.

 IF pred GOTO target ==> GOTO target
 

public abstract void transformToJump (IDTarget target)

Transform any instruction to a jump, and update the jump target.

public abstract void transformToNop ()

Transform any instruction to a NOP.

public abstract void verify ()

Verify this instruction.

Currently, this method verifies that the instruction operands match the current opcode specifications (see DOpcodeType).

Throws
IllegalStateException throw on error

public abstract boolean visitInstruction (IDVisitor visitor, boolean skipAssignmentDestination)

Visit this instruction and its constituents. The visit is made depth-first, pre-order, and parents are recorded. (Refer to IVisitResults for details.)

Same as visitInstructionPreOrder. Replacements must be reported (refer to visitDepthPre(IDVisitor) for details).

Parameters
visitor visitor object
skipAssignmentDestination true to skip visiting the destination of IR_ASSIGN or IR_STORE_EXCEPTION
Returns
  • success indicator; true unless a different value was specified in DTreeVisitResults when visiting an element

public abstract boolean visitInstruction (IDVisitor visitor)

Visit this instruction and its constituents. The visit is made depth-first, pre-order, and parents are recorded. (Refer to IVisitResults for details.)

Same as visitInstructionPreOrder. Replacements must be reported (refer to visitDepthPre(IDVisitor) for details).

Parameters
visitor visitor object
Returns
  • success indicator; true unless a different value was specified in DTreeVisitResults when visiting an element

public abstract boolean visitInstructionPostOrder (IDVisitor visitor, boolean skipAssignmentDestination)

Visit this instruction and its constituents. The visit is made depth-first, post-order, and parents are recorded. (Refer to IVisitResults for details.)

Replacements need not be reported.

Parameters
visitor visitor object
skipAssignmentDestination true to skip visiting the destination of IR_ASSIGN or IR_STORE_EXCEPTION
Returns
  • success indicator; true unless a different value was specified in DTreeVisitResults when visiting an element

public abstract boolean visitInstructionPreOrder (IDVisitor visitor, boolean skipAssignmentDestination)

Visit this instruction and its constituents. The visit is made depth-first, pre-order, and parents are recorded. (Refer to IVisitResults for details.)

Replacements must be reported (refer to visitDepthPre(IDVisitor) for details).

Parameters
visitor visitor object
skipAssignmentDestination true to skip visiting the destination of IR_ASSIGN or IR_STORE_EXCEPTION
Returns
  • success indicator; true unless a different value was specified in DTreeVisitResults when visiting an element