Package com.android.dx.io.instructions
Class DecodedInstruction
java.lang.Object
com.android.dx.io.instructions.DecodedInstruction
- Direct Known Subclasses:
FillArrayDataPayloadDecodedInstruction
,FiveRegisterDecodedInstruction
,FourRegisterDecodedInstruction
,InvokePolymorphicDecodedInstruction
,InvokePolymorphicRangeDecodedInstruction
,OneRegisterDecodedInstruction
,PackedSwitchPayloadDecodedInstruction
,RegisterRangeDecodedInstruction
,SparseSwitchPayloadDecodedInstruction
,ThreeRegisterDecodedInstruction
,TwoRegisterDecodedInstruction
,ZeroRegisterDecodedInstruction
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.
-
Constructor Summary
ConstructorDescriptionDecodedInstruction
(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic DecodedInstruction
Decodes an instruction from the given input source.static DecodedInstruction[]
decodeAll
(short[] encodedInstructions) Decodes an array of instructions.final void
encode
(CodeOutput out) Encodes this instance to the given output.int
getA()
final short
getAByte()
Gets the A register number, as a byte.final short
Gets the A register number, as a nibble.final short
getAUnit()
Gets the A register number, as a code unit.int
getB()
final short
getBByte()
Gets the B register number, as a byte.final short
Gets the B register number, as a nibble.final short
getBUnit()
Gets the B register number, as a code unit.int
getC()
final short
getCByte()
Gets the C register number, as a byte.final short
Gets the C register number, as a nibble.final short
getCUnit()
Gets the C register number, as a code unit.int
getD()
final short
getDByte()
Gets the D register number, as a byte.final short
Gets the D register number, as a nibble.final short
getDUnit()
Gets the D register number, as a code unit.int
getE()
final short
Gets the E register number, as a nibble.final InstructionCodec
final int
getIndex()
final IndexType
final short
Gets the index, as a code unit.final long
final int
Gets the literal value, masked to be a byte in size.final int
Gets the literal value, masked to be an int in size.final int
Gets the literal value, masked to be a nibble in size.final short
Gets the literal value, as a code unit.final int
final short
Gets the opcode, as a code unit.short
Returns a 45cc or 4rcc proto index.abstract int
final short
Gets the register count, as a code unit.final int
Gets the raw target.final int
getTarget
(int baseAddress) Gets the target as a relative offset from the given address.final int
getTargetByte
(int baseAddress) Gets the target as a relative offset from the given base address, masked to be a byte in size.final short
getTargetUnit
(int baseAddress) Gets the target as a relative offset from the given base address, as a code unit.abstract DecodedInstruction
withIndex
(int newIndex) Returns an instance just like this one, except with the index replaced with the given one.withProtoIndex
(int newIndex, int newProtoIndex) Update the instruction with a new 45cc or 4rcc proto index.
-
Constructor Details
-
DecodedInstruction
public DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal) Constructs an instance.
-
-
Method Details
-
decode
Decodes an instruction from the given input source.- Throws:
EOFException
-
decodeAll
Decodes an array of instructions. The result has non-null elements at each offset that represents the start of an instruction. -
getFormat
-
getOpcode
public final int getOpcode() -
getOpcodeUnit
public final short getOpcodeUnit()Gets the opcode, as a code unit. -
getIndex
public final int getIndex() -
getIndexUnit
public final short getIndexUnit()Gets the index, as a code unit. -
getIndexType
-
getTarget
public final int getTarget()Gets the raw target. -
getTarget
public final int getTarget(int baseAddress) Gets the target as a relative offset from the given address. -
getTargetUnit
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. -
getTargetByte
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. -
getLiteral
public final long getLiteral() -
getLiteralInt
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. -
getLiteralUnit
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. -
getLiteralByte
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. -
getLiteralNibble
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. -
getRegisterCount
public abstract int getRegisterCount() -
getA
public int getA() -
getB
public int getB() -
getC
public int getC() -
getD
public int getD() -
getE
public int getE() -
getRegisterCountUnit
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. -
getAUnit
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. -
getAByte
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. -
getANibble
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. -
getBUnit
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. -
getBByte
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. -
getBNibble
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. -
getCUnit
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. -
getCByte
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. -
getCNibble
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. -
getDUnit
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. -
getDByte
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. -
getDNibble
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. -
getENibble
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. -
encode
Encodes this instance to the given output. -
withIndex
Returns an instance just like this one, except with the index replaced with the given one. -
withProtoIndex
Update the instruction with a new 45cc or 4rcc proto index. -
getProtoIndex
public short getProtoIndex()Returns a 45cc or 4rcc proto index.
-