# Interface: com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction

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

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

 When creating IR instructions, the default size is set to 1. The offset is not set \(\-1\), and needs to be set manually. The size of an IR instruction can be set to any strictly positive value. In a CFG, it is important that all instructions be contiguous \(i.e. there is no gap\): if an instruction has offset O and size S, the next instruction must be at offset O\+S.

## Static Field: KEEP_INSTRUCTION
Type: `java.lang.String`

Constant value: `KEEP_INSTRUCTION`
Description: This boolean attribute can be [set](#setData(String, Object)) by optimizers on [jump](DOpcodeType#IR_JUMP) and [jcond](DOpcodeType#IR_JCOND) instructions. When True, optimizers should do their best to not remove the instruction.

## Method: adjustSize
- parameter: `delta`, type: `int`

Description: Adjust this instruction's IR size. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.
parameter: delta: added to the current [size](#getSize())

## Method: copy
- parameter: `opt`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.DCopyOptions`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`


## Method: copyBaseFields
- parameter: `sourceInsn`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`

Description: Copy all base fields, that is **all fields but the opcode and operands** of the source instruction to this instruction.
parameter: sourceInsn: 

## Method: countUsedVariable
- parameter: `var`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`
- return type: `int`

Description: 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
parameter: var: 
return: 

## Method: duplicate
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`

Description: Deep copy of this instruction.

## Method: duplicateForReplacement
- parameter: `replacedInsn`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`

Description: 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.
return: 

## Method: duplicateWithOffsetAndSize
- parameter: `offset`, type: `long`
- parameter: `size`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`

Description: 
parameter: offset: 
parameter: size: 
return: 

## Method: evaluate
- parameter: `varmap`, type: `java.util.Map<java.lang.Integer,com.pnfsoftware.jeb.core.units.code.android.ir.IDImm>`
- return type: `java.lang.Integer`

Description: Convenience method: evaluate the IR instruction using the provided set a variable values.
parameter: varmap: a map of variable values to be used when evaluating the expression \(this map            will not be modified after evaluation of the instruction; for full\-control of the            emulation, use [#evaluate(IDState)](#evaluate(IDState)) instead of this method\)
return: the offset of the next IR instruction to be executed; null if none \(e.g. a Return was         executed\)
throws: 

## Method: getAssignDestination
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: getAssignSource
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: getBranchTarget
- return type: `int`


## Method: getContext
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`

Description: 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](IDInstruction) objects.
return: 

## Method: getDefinedVariable
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`

Description: Get the identifier defined \(written\) by this method, if there is one. Only [DOpcodeType#IR_ASSIGN](DOpcodeType#IR_ASSIGN) and [DOpcodeType#IR_STORE_EXCEPTION](DOpcodeType#IR_STORE_EXCEPTION) may define \(write\) identifiers.
return: 

## Method: getInvokeData
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInvokeInfo`

Description: 
return: the invocation information, if the instruction [is an invocation](#isInvoke())

## Method: getJcondCondition
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`

Description: Get the condition predicate \(if the instruction is a JCOND\).
return: 

## Method: getOffset
- return type: `long`

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

## Method: getOffsetEnd
- return type: `long`

Description: Retrieve the end offset \(exclusive\) of this instruction
return: [#getOffset()](#getOffset()) \+ [#getSize()](#getSize())

## Method: getOpcode
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.DOpcodeType`

Description: Get this instruction opcode.
return: 

## Method: getOperand1
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDElement`

Description: Get the first operand. May be null if the opcode does not specify one. Refer to [#getOpcode()](#getOpcode()) and [DOpcodeType](DOpcodeType).
return: 

## Method: getOperand2
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDElement`

Description: Get the second operand. May be null if the opcode does not specify one. Refer to [#getOpcode()](#getOpcode()) and [DOpcodeType](DOpcodeType).
return: 

## Method: getReturnExpression
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: getStoredExceptionVariable
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`

Description: 
return: the exception variable set up by a [store\-exception](DOpcodeType#IR_STORE_EXCEPTION) instruction

## Method: getSwitchData
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDSwitchData`


## Method: getSwitchExpression
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: getThrowExpression
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: getUsedVariables
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.ir.IDVar>`

Description: Get the variables used \(read\) by this instruction.
return: the list of all variables used, which may contain duplicates variables if the         instruction uses the same variable multiple times \(example: `z = x + (y * x)`         would return `[y, x, x]`.

## Method: hasUseSideEffects
- parameter: `includeCanThrow`, type: `boolean`
- return type: `boolean`

Description: Determine whether the used components of the statement may have side\-effects. 

 This method is not fail\-safe, it works on a best\-effort basis. Refer to [#hasSideEffects(IDMethodContext, boolean)](#hasSideEffects(IDMethodContext, boolean)) for more information.
parameter: includeCanThrow: 
return: 

## Method: isAssign
- return type: `boolean`

Description: 
return: true if this instruction is an [assignment](DOpcodeType#IR_ASSIGN)

## Method: isAssignFromVar
- return type: `boolean`


## Method: isAssignFromVar
- parameter: `wantedVarId`, type: `int`
- return type: `boolean`


## Method: isAssignFromVarToVar
- return type: `boolean`


## Method: isAssignFromVarToVar
- parameter: `wantedSrcVarId`, type: `int`
- parameter: `wantedDstVarId`, type: `int`
- return type: `boolean`


## Method: isAssignToVar
- return type: `boolean`


## Method: isAssignToVar
- parameter: `wantedVarId`, type: `int`
- return type: `boolean`


## Method: isInvoke
- return type: `boolean`

Description: 
return: true if this instruction is an [invocation](DOpcodeType#IR_INVOKE) \(call, new,         new\-array, alloc\-object\)

## Method: isJcond
- return type: `boolean`

Description: 
return: true if this instruction is a [conditional jump](DOpcodeType#IR_JCOND)

## Method: isJcondOrSwitch
- return type: `boolean`


## Method: isJcondTo
- parameter: `wantedTarget`, type: `int`
- return type: `boolean`


## Method: isJump
- return type: `boolean`

Description: 
return: true if this instruction is a [jump](DOpcodeType#IR_JUMP) \(goto\)

## Method: isJumpOrJcond
- return type: `boolean`


## Method: isJumpOrJcondTo
- parameter: `wantedTarget`, type: `int`
- return type: `boolean`


## Method: isJumpTo
- parameter: `wantedTarget`, type: `int`
- return type: `boolean`


## Method: isMonitorEnter
- return type: `boolean`

Description: 
return: true if this instruction is a [monitor\-enter](DOpcodeType#IR_MONITOR_ENTER)

## Method: isMonitorExit
- return type: `boolean`

Description: 
return: true if this instruction is a [monitor\-exit](DOpcodeType#IR_MONITOR_EXIT)

## Method: isNop
- return type: `boolean`

Description: 
return: true if this instruction is a [nop](DOpcodeType#IR_NOP)

## Method: isOpcode
- parameter: `candidateOpcodes`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.DOpcodeType[]`
- return type: `boolean`

Description: Determine if this instruction's opcode is any of the provided candidates.
parameter: candidateOpcodes: a list of candidate opcodes
return: true if this instruction's opcode was one of the candidates

## Method: isReturn
- return type: `boolean`

Description: 
return: true if this instruction is a [return](DOpcodeType#IR_RETURN)

## Method: isReturnOrThrow
- return type: `boolean`


## Method: isStoreException
- return type: `boolean`

Description: 
return: true if this instruction is a [store\-exception](DOpcodeType#IR_STORE_EXCEPTION)         \(special opcode\)

## Method: isSwitch
- return type: `boolean`

Description: 
return: true if this instruction is a [switch](DOpcodeType#IR_SWITCH)

## Method: isSwitchOnInt
- return type: `boolean`


## Method: isSwitchOnString
- return type: `boolean`


## Method: isThrow
- return type: `boolean`

Description: 
return: true if this instruction is a [throw](DOpcodeType#IR_THROW)

## Method: morph
- parameter: `opcode`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.DOpcodeType`
- parameter: `opnd1`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDElement`
- parameter: `opnd2`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDElement`

Description: This dangerous method allows changing an IR instruction into a different one, while keeping metadata \(e.g. offset, size, etc.\) intact. If possible, use one of the `transformXxx` instructions instead.
parameter: opcode: new opcode
parameter: opnd1: new operand 1 \(if any\) \- refer to [DOpcodeType](DOpcodeType)'s type for operand type
parameter: opnd2: new operand 2 \(if any\) \- refer to [DOpcodeType](DOpcodeType)'s type for operand type

## Method: replaceDefinedVariable
- parameter: `var`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`
- parameter: `repl`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `int`

Description: Replace the variable defined by this statement \(if there is any\).
parameter: var: target variable to be replaced
parameter: repl: expression that will replace the variable
return: the number of replacements \(usually 0, potentially 1 for an assigment\-like         instruction\)

## Method: replaceUsedVariable
- parameter: `var`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`
- parameter: `repl`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `int`

Description: Deep replace all matching used variables of this instruction. The replacement expression is duplicated to avoid reuse. Defined identifiers \(if any\) are not replaced.
parameter: var: target variable to be replaced
parameter: repl: expression that will replace the variable
return: the number of replacements

## Method: reverseJcondCondition


## Method: setAssignDestination
- parameter: `dst`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: setAssignSource
- parameter: `src`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: setBranchTarget
- parameter: `offset`, type: `int`
- return type: `int`

Description: Update the branch target for unconditional and conditional jumps only. This function fails for all other opcodes, including switches.
parameter: offset: the new offset
return: previous value

## Method: setContext
- parameter: `ctx`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`

Description: Update the instruction context. It is important to update the context when transferring the instructions from a CFG \(from context A\) to another CFG \(of contextB\).
parameter: ctx: new context
return: the previous context

## Method: setJcondCondition
- parameter: `cond`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`

Description: 
parameter: cond: 
return: 

## Method: setOffset
- parameter: `offset`, type: `long`

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

## Method: setOpcode
- parameter: `opcode`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.DOpcodeType`

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

## Method: setOperand1
- parameter: `opnd`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDElement`

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

## Method: setOperand2
- parameter: `opnd`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDElement`

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

## Method: setReturnExpression
- parameter: `exp`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: setSize
- parameter: `size`, type: `int`

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

## Method: setStoredExceptionVariable
- parameter: `ex`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`

Description: 
parameter: ex: a new exception variable for a [store\-exception](DOpcodeType#IR_STORE_EXCEPTION) instruction
return: the previous variable

## Method: setSwitchData
- parameter: `swdata`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDSwitchData`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDSwitchData`


## Method: setSwitchExpression
- parameter: `exp`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: setThrowExpression
- parameter: `exp`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression`


## Method: transformJcondToAssign
- parameter: `dst`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVar`

Description: 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
 
```
parameter: dst: the destination operand for the predicate

## Method: transformJcondToJump

Description: 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
 
```

## Method: transformSwitchToJcond
- return type: `boolean`

Description: Transform a single\-case switch into a conditional jump.  

```

 SWITCH(VAR) {
 CASE X: GOTO target;
 }
 // fall-through
 =>
 IF VAR==X GOTO target;
 // fall-through
 
```
return: success indicators \(if the switch has several cases, this method will fail\)

## Method: transformToJump
- parameter: `offset`, type: `int`

Description: Transform any instruction to a jump, and update the jump target.
parameter: offset: target offset

## Method: transformToJump
- parameter: `target`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDTarget`

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

## Method: transformToNop

Description: Transform any instruction to a NOP.

## Method: updateTargets
- parameter: `oldToNewOffsets`, type: `java.util.Map<java.lang.Integer,java.lang.Integer>`
- return type: `int`

Description: Update the targets of a branching instruction. This method has no effect on IR opcodes other than `JUMP`, `JCOND`, and `SWITCH`.
parameter: oldToNewOffsets: a map of current IR offsets to new IR offsets
return: the number of updated targets

## Method: updateTargets
- parameter: `oldToNewOffsets`, type: `java.util.Map<java.lang.Integer,java.lang.Integer>`
- parameter: `failOnMissedEntry`, type: `boolean`
- return type: `int`

Description: Update the targets of a branching instruction. This method has no effect on IR opcodes other than `JUMP`, `JCOND`, and `SWITCH`.
parameter: oldToNewOffsets: a map of current IR offsets to new IR offsets
parameter: failOnMissedEntry: if true, the method will raise if a \(current\) branch target cannot            be mapped to a new target \(i.e., if there is no entry for a branch target in the            map\)
return: the number of updated targets

## Method: verify

Description: Verify this instruction. 

 Currently, this method verifies that the instruction operands match the [current opcode](#getOpcode()) specifications \(see [DOpcodeType](DOpcodeType)\).
throws: throw on error

## Method: visitInstruction
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVisitor`
- return type: `boolean`

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

 Same as `visitInstructionPreOrder`. Replacements must be reported \(refer to [IDExpression#visitDepthPre(IDVisitor)](IDExpression#visitDepthPre(IDVisitor)) for details\).
parameter: visitor: visitor object
return: success indicator; true unless a different value was specified in         [DVisitResults](DVisitResults) when visiting an element

## Method: visitInstruction
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVisitor`
- parameter: `skipAssignmentDestination`, type: `boolean`
- return type: `boolean`

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

 Same as `visitInstructionPreOrder`. Replacements must be reported \(refer to [IDExpression#visitDepthPre(IDVisitor)](IDExpression#visitDepthPre(IDVisitor)) for details\).
parameter: visitor: visitor object
parameter: skipAssignmentDestination: true to skip visiting the destination of            [DOpcodeType#IR_ASSIGN](DOpcodeType#IR_ASSIGN) or [DOpcodeType#IR_STORE_EXCEPTION](DOpcodeType#IR_STORE_EXCEPTION)
return: success indicator; true unless a different value was specified in         [DVisitResults](DVisitResults) when visiting an element

## Method: visitInstructionPostOrder
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVisitor`
- parameter: `skipAssignmentDestination`, type: `boolean`
- return type: `boolean`

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

 Replacements need not be reported.
parameter: visitor: visitor object
parameter: skipAssignmentDestination: true to skip visiting the destination of            [DOpcodeType#IR_ASSIGN](DOpcodeType#IR_ASSIGN) or [DOpcodeType#IR_STORE_EXCEPTION](DOpcodeType#IR_STORE_EXCEPTION)
return: success indicator; true unless a different value was specified in         [DVisitResults](DVisitResults) when visiting an element

## Method: visitInstructionPreOrder
- parameter: `visitor`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDVisitor`
- parameter: `skipAssignmentDestination`, type: `boolean`
- return type: `boolean`

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

 Replacements must be reported \(refer to [IDExpression#visitDepthPre(IDVisitor)](IDExpression#visitDepthPre(IDVisitor)) for details\).
parameter: visitor: visitor object
parameter: skipAssignmentDestination: true to skip visiting the destination of            [DOpcodeType#IR_ASSIGN](DOpcodeType#IR_ASSIGN) or [DOpcodeType#IR_STORE_EXCEPTION](DOpcodeType#IR_STORE_EXCEPTION)
return: success indicator; true unless a different value was specified in         [DVisitResults](DVisitResults) when visiting an element

## Method: withOffset
- parameter: `offset`, type: `long`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`

Description: Update the instruction offset.
parameter: offset: new offset
return: this object

## Method: withSize
- parameter: `size`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction`

Description: Update the instruction size.
parameter: size: new size
return: this object

