Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.io.instructions

public abstract Class DecodedInstruction

extends Object
Class Inheritance
Known Direct Subclasses
org.droidparts.dexmaker.dx.io.instructions.FillArrayDataPayloadDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.FiveRegisterDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.FourRegisterDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.OneRegisterDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.PackedSwitchPayloadDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.RegisterRangeDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.SparseSwitchPayloadDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.ThreeRegisterDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.TwoRegisterDecodedInstruction, org.droidparts.dexmaker.dx.io.instructions.ZeroRegisterDecodedInstruction
Imports
org.droidparts.dexmaker.dx.io.IndexType, .OpcodeInfo, .Opcodes, org.droidparts.dexmaker.dx.util.DexException, .Hex, java.io.EOFException

A decoded Dalvik instruction. This consists of a format codec, a numeric opcode, an optional index type, and any additional arguments of the instruction. The additional arguments (if any) are represented as uninterpreted data.

Note

The names of the arguments are not meant to match the names given in the Dalvik instruction format specification, specification which just names fields (somewhat) arbitrarily alphabetically from A. In this class, non-register fields are given descriptive names and register fields are consistently named alphabetically.

Field Summary

Modifier and TypeField and Description
private final InstructionCodec
format

non-null; instruction format / codec

private final int
index

constant index argument

private final IndexType
indexType

null-ok; index type

private final long
literal

literal value argument; also used for special verification error constants (formats 20bc and 40sc) as well as should-be-zero values (formats 10x, 20t, 30t, and 32x)

private final int
opcode

opcode number

private final int
target

target address argument.

Constructor Summary

AccessConstructor and Description
public
DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public static DecodedInstruction
decode(CodeInput in)

Decodes an instruction from the given input source.

public static DecodedInstruction[]
decodeAll(short[] encodedInstructions)

Decodes an array of instructions.

public final void
encode(CodeOutput out)

Encodes this instance to the given output.

public int
getA()

public final short
getAByte()

Gets the A register number, as a byte.

public final short
getANibble()

Gets the A register number, as a nibble.

public final short
getAUnit()

Gets the A register number, as a code unit.

public int
getB()

public final short
getBByte()

Gets the B register number, as a byte.

public final short
getBNibble()

Gets the B register number, as a nibble.

public final short
getBUnit()

Gets the B register number, as a code unit.

public int
getC()

public final short
getCByte()

Gets the C register number, as a byte.

public final short
getCNibble()

Gets the C register number, as a nibble.

public final short
getCUnit()

Gets the C register number, as a code unit.

public int
getD()

public final short
getDByte()

Gets the D register number, as a byte.

public final short
getDNibble()

Gets the D register number, as a nibble.

public final short
getDUnit()

Gets the D register number, as a code unit.

public int
getE()

public final short
getENibble()

Gets the E register number, as a nibble.

public final InstructionCodec
public final int
public final IndexType
public final short
getIndexUnit()

Gets the index, as a code unit.

public final long
public final int
getLiteralByte()

Gets the literal value, masked to be a byte in size.

public final int
getLiteralInt()

Gets the literal value, masked to be an int in size.

public final int
getLiteralNibble()

Gets the literal value, masked to be a nibble in size.

public final short
getLiteralUnit()

Gets the literal value, as a code unit.

public final int
public final short
getOpcodeUnit()

Gets the opcode, as a code unit.

public abstract int
public final short
getRegisterCountUnit()

Gets the register count, as a code unit.

public final int
getTarget()

Gets the raw target.

public final int
getTarget(int baseAddress)

Gets the target as a relative offset from the given address.

public final int
getTargetByte(int baseAddress)

Gets the target as a relative offset from the given base address, masked to be a byte in size.

public final short
getTargetUnit(int baseAddress)

Gets the target as a relative offset from the given base address, as a code unit.

public abstract DecodedInstruction
withIndex(int newIndex)

Returns an instance just like this one, except with the index replaced with the given one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

formatback to summary
private final InstructionCodec format

non-null; instruction format / codec

indexback to summary
private final int index

constant index argument

indexTypeback to summary
private final IndexType indexType

null-ok; index type

literalback to summary
private final long literal

literal value argument; also used for special verification error constants (formats 20bc and 40sc) as well as should-be-zero values (formats 10x, 20t, 30t, and 32x)

opcodeback to summary
private final int opcode

opcode number

targetback to summary
private final int target

target address argument. This is an absolute address, not just a signed offset

Note

The address is unsigned, even though it is stored in an int.

Constructor Detail

DecodedInstructionback to summary
public DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal)

Constructs an instance.

Method Detail

decodeback to summary
public static DecodedInstruction decode(CodeInput in) throws EOFException

Decodes an instruction from the given input source.

decodeAllback to summary
public static DecodedInstruction[] decodeAll(short[] encodedInstructions)

Decodes an array of instructions. The result has non-null elements at each offset that represents the start of an instruction.

encodeback to summary
public final void encode(CodeOutput out)

Encodes this instance to the given output.

getAback to summary
public int getA()
getAByteback to summary
public final short getAByte()

Gets the A register number, as a byte. This will throw if the value is out of the range of an unsigned byte.

getANibbleback to summary
public final short getANibble()

Gets the A register number, as a nibble. This will throw if the value is out of the range of an unsigned nibble.

getAUnitback to summary
public final short getAUnit()

Gets the A register number, as a code unit. This will throw if the value is out of the range of an unsigned code unit.

getBback to summary
public int getB()
getBByteback to summary
public final short getBByte()

Gets the B register number, as a byte. This will throw if the value is out of the range of an unsigned byte.

getBNibbleback to summary
public final short getBNibble()

Gets the B register number, as a nibble. This will throw if the value is out of the range of an unsigned nibble.

getBUnitback to summary
public final short getBUnit()

Gets the B register number, as a code unit. This will throw if the value is out of the range of an unsigned code unit.

getCback to summary
public int getC()
getCByteback to summary
public final short getCByte()

Gets the C register number, as a byte. This will throw if the value is out of the range of an unsigned byte.

getCNibbleback to summary
public final short getCNibble()

Gets the C register number, as a nibble. This will throw if the value is out of the range of an unsigned nibble.

getCUnitback to summary
public final short getCUnit()

Gets the C register number, as a code unit. This will throw if the value is out of the range of an unsigned code unit.

getDback to summary
public int getD()
getDByteback to summary
public final short getDByte()

Gets the D register number, as a byte. This will throw if the value is out of the range of an unsigned byte.

getDNibbleback to summary
public final short getDNibble()

Gets the D register number, as a nibble. This will throw if the value is out of the range of an unsigned nibble.

getDUnitback to summary
public final short getDUnit()

Gets the D register number, as a code unit. This will throw if the value is out of the range of an unsigned code unit.

getEback to summary
public int getE()
getENibbleback to summary
public final short getENibble()

Gets the E register number, as a nibble. This will throw if the value is out of the range of an unsigned nibble.

getFormatback to summary
public final InstructionCodec getFormat()
getIndexback to summary
public final int getIndex()
getIndexTypeback to summary
public final IndexType getIndexType()
getIndexUnitback to summary
public final short getIndexUnit()

Gets the index, as a code unit.

getLiteralback to summary
public final long getLiteral()
getLiteralByteback to summary
public final int getLiteralByte()

Gets the literal value, masked to be a byte in size. This will throw if the value is out of the range of a signed byte.

getLiteralIntback to summary
public final int getLiteralInt()

Gets the literal value, masked to be an int in size. This will throw if the value is out of the range of a signed int.

getLiteralNibbleback to summary
public final int getLiteralNibble()

Gets the literal value, masked to be a nibble in size. This will throw if the value is out of the range of a signed nibble.

getLiteralUnitback to summary
public final short getLiteralUnit()

Gets the literal value, as a code unit. This will throw if the value is out of the range of a signed code unit.

getOpcodeback to summary
public final int getOpcode()
getOpcodeUnitback to summary
public final short getOpcodeUnit()

Gets the opcode, as a code unit.

getRegisterCountback to summary
public abstract int getRegisterCount()
getRegisterCountUnitback to summary
public final short getRegisterCountUnit()

Gets the register count, as a code unit. This will throw if the value is out of the range of an unsigned code unit.

getTargetback to summary
public final int getTarget()

Gets the raw target.

getTargetback to summary
public final int getTarget(int baseAddress)

Gets the target as a relative offset from the given address.

getTargetByteback to summary
public final int getTargetByte(int baseAddress)

Gets the target as a relative offset from the given base address, masked to be a byte in size. This will throw if the value is out of the range of a signed byte.

getTargetUnitback to summary
public final short getTargetUnit(int baseAddress)

Gets the target as a relative offset from the given base address, as a code unit. This will throw if the value is out of the range of a signed code unit.

withIndexback to summary
public abstract DecodedInstruction withIndex(int newIndex)

Returns an instance just like this one, except with the index replaced with the given one.