com.android.dx.io.instructions
Class DecodedInstruction

java.lang.Object
  extended by com.android.dx.io.instructions.DecodedInstruction
Direct Known Subclasses:
FillArrayDataPayloadDecodedInstruction, FiveRegisterDecodedInstruction, FourRegisterDecodedInstruction, OneRegisterDecodedInstruction, PackedSwitchPayloadDecodedInstruction, RegisterRangeDecodedInstruction, SparseSwitchPayloadDecodedInstruction, ThreeRegisterDecodedInstruction, TwoRegisterDecodedInstruction, ZeroRegisterDecodedInstruction

public abstract class DecodedInstruction
extends Object

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
DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal)
          Constructs an instance.
 
Method Summary
static DecodedInstruction decode(CodeInput in)
          Decodes an instruction from the given input source.
static DecodedInstruction[] decodeAll(short[] encodedInstructions)
          Decodes an array of instructions.
 void encode(CodeOutput out)
          Encodes this instance to the given output.
 int getA()
           
 short getAByte()
          Gets the A register number, as a byte.
 short getANibble()
          Gets the A register number, as a nibble.
 short getAUnit()
          Gets the A register number, as a code unit.
 int getB()
           
 short getBByte()
          Gets the B register number, as a byte.
 short getBNibble()
          Gets the B register number, as a nibble.
 short getBUnit()
          Gets the B register number, as a code unit.
 int getC()
           
 short getCByte()
          Gets the C register number, as a byte.
 short getCNibble()
          Gets the C register number, as a nibble.
 short getCUnit()
          Gets the C register number, as a code unit.
 int getD()
           
 short getDByte()
          Gets the D register number, as a byte.
 short getDNibble()
          Gets the D register number, as a nibble.
 short getDUnit()
          Gets the D register number, as a code unit.
 int getE()
           
 short getENibble()
          Gets the E register number, as a nibble.
 InstructionCodec getFormat()
           
 int getIndex()
           
 IndexType getIndexType()
           
 short getIndexUnit()
          Gets the index, as a code unit.
 long getLiteral()
           
 int getLiteralByte()
          Gets the literal value, masked to be a byte in size.
 int getLiteralInt()
          Gets the literal value, masked to be an int in size.
 int getLiteralNibble()
          Gets the literal value, masked to be a nibble in size.
 short getLiteralUnit()
          Gets the literal value, as a code unit.
 int getOpcode()
           
 short getOpcodeUnit()
          Gets the opcode, as a code unit.
abstract  int getRegisterCount()
           
 short getRegisterCountUnit()
          Gets the register count, as a code unit.
 int getTarget()
          Gets the raw target.
 int getTarget(int baseAddress)
          Gets the target as a relative offset from the given address.
 int getTargetByte(int baseAddress)
          Gets the target as a relative offset from the given base address, masked to be a byte in size.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecodedInstruction

public DecodedInstruction(InstructionCodec format,
                          int opcode,
                          int index,
                          IndexType indexType,
                          int target,
                          long literal)
Constructs an instance.

Method Detail

decode

public static DecodedInstruction decode(CodeInput in)
                                 throws EOFException
Decodes an instruction from the given input source.

Throws:
EOFException

decodeAll

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.


getFormat

public final InstructionCodec 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

public final IndexType 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

public final void encode(CodeOutput out)
Encodes this instance to the given output.


withIndex

public abstract DecodedInstruction withIndex(int newIndex)
Returns an instance just like this one, except with the index replaced with the given one.



Copyright © 2013. All Rights Reserved.