org.ow2.asmdex.instruction
Class InstructionFormat21T

java.lang.Object
  extended by org.ow2.asmdex.instruction.Instruction
      extended by org.ow2.asmdex.instruction.InstructionFormat21T
All Implemented Interfaces:
IOffsetInstruction, IOneRegisterInstruction

public class InstructionFormat21T
extends Instruction
implements IOneRegisterInstruction, IOffsetInstruction

Encodes and decodes an instruction built with the Dalvik format 21T.

Author:
Julien Névo

Field Summary
 
Fields inherited from class org.ow2.asmdex.instruction.Instruction
lineNumber, opcodeByte, opcodeHighOrderByte
 
Constructor Summary
InstructionFormat21T(int opcode, Label label, int registerA, int instructionOffset)
          Constructor of the Instruction by providing all the elements it's composed of.
 
Method Summary
 int getInstructionOffset()
          Offset in bytes of the Instruction from the beginning of the method.
 Label getLabel()
          Returns the label to which the instruction jumps.
 int getOffset()
          Returns the offset of the instruction this instruction is related to.
static int getOffset(IDalvikValueReader reader, int opcode)
          Returns the Offset encoded in the given 16-bit opcode.
 int getRegisterA()
          The index of the register (called A value in Dalvik documentation)
static int getRegisterA(int opcode)
          Returns the RegisterA encoded in the given 16-bit opcode.
 int getSize()
          Returns the size of the instruction in bytes.
 void setInstructionOffset(int instructionOffset)
          Sets the offset in bytes of the Instruction from the beginning of the method.
static void skip(IDalvikValueReader reader)
          Skips the data of this Instruction.
 void write(ByteVector out, ConstantPool constantPool)
          Encodes the instruction, in the Dalvik format, to an output buffer.
 
Methods inherited from class org.ow2.asmdex.instruction.Instruction
getInstructionSizeInByte, getLineNumber, getOpcodeByte, getOpcodeHighOrderByte, setLineNumber, test4BitsLimit, test4BitsLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstructionFormat21T

public InstructionFormat21T(int opcode,
                            Label label,
                            int registerA,
                            int instructionOffset)
Constructor of the Instruction by providing all the elements it's composed of.

Parameters:
opcode - 8 or 16 bits opcode.
label - Label to which is linked this Instruction.
registerA - the register to store.
instructionOffset - offset of this Instruction from the beginning of its Method.
Method Detail

getLabel

public Label getLabel()
Returns the label to which the instruction jumps.

Specified by:
getLabel in interface IOffsetInstruction
Returns:
the label to which the instruction jumps.

getRegisterA

public static int getRegisterA(int opcode)
Returns the RegisterA encoded in the given 16-bit opcode.

Returns:
the RegisterA.

getOffset

public static int getOffset(IDalvikValueReader reader,
                            int opcode)
Returns the Offset encoded in the given 16-bit opcode. It must be performed only once after having read the opcode.

Parameters:
reader - reader on the Instruction to parse, pointing after the 16-bit opcode.
opcode - the 16-bit opcode.
Returns:
the Offset from the beginning of the Dex file.

skip

public static void skip(IDalvikValueReader reader)
Skips the data of this Instruction.

Parameters:
reader - reader on the Instruction to parse, pointing after the 16-bit opcode.

getRegisterA

public int getRegisterA()
Description copied from interface: IOneRegisterInstruction
The index of the register (called A value in Dalvik documentation)

Specified by:
getRegisterA in interface IOneRegisterInstruction
Returns:
regoster A index

getOffset

public int getOffset()
Description copied from interface: IOffsetInstruction
Returns the offset of the instruction this instruction is related to.

Specified by:
getOffset in interface IOffsetInstruction
Returns:
the offset of the instruction this instruction is related to.

getSize

public int getSize()
Description copied from class: Instruction
Returns the size of the instruction in bytes.

Specified by:
getSize in class Instruction
Returns:
the size of the instruction in bytes.

getInstructionOffset

public int getInstructionOffset()
Description copied from interface: IOffsetInstruction
Offset in bytes of the Instruction from the beginning of the method. This is only useful for the Instruction that refers to Labels, so that we can know if the range of the Instruction is valid to reach the Label.

Specified by:
getInstructionOffset in interface IOffsetInstruction
Returns:
offset in bytes of the Instruction from the beginning of the method.

setInstructionOffset

public void setInstructionOffset(int instructionOffset)
Description copied from interface: IOffsetInstruction
Sets the offset in bytes of the Instruction from the beginning of the method.

Specified by:
setInstructionOffset in interface IOffsetInstruction
Parameters:
instructionOffset - offset in bytes of the Instruction from the beginning of the method.

write

public void write(ByteVector out,
                  ConstantPool constantPool)
Description copied from class: Instruction
Encodes the instruction, in the Dalvik format, to an output buffer.

Specified by:
write in class Instruction
Parameters:
out - output buffer.
constantPool - the constantPool.