org.ow2.asmdex.instruction
Class InstructionFormat3RC

java.lang.Object
  extended by org.ow2.asmdex.instruction.Instruction
      extended by org.ow2.asmdex.instruction.InstructionFormat3RC
All Implemented Interfaces:
IIndexInstruction, IRegisterArrayInstruction

public class InstructionFormat3RC
extends Instruction
implements IRegisterArrayInstruction, IIndexInstruction

Encodes and decodes an instruction built with the Dalvik format 3RC. This Instruction can refer to a Type, or a Method. Use the constructor according to what this Instruction is used for. Note that the writing of this Instruction doesn't check the validity of the Registers. They have to be consecutive.

Author:
Julien Névo

Field Summary
 
Fields inherited from class org.ow2.asmdex.instruction.Instruction
lineNumber, opcodeByte, opcodeHighOrderByte
 
Constructor Summary
InstructionFormat3RC(int opcode, Method method, int[] registers)
          Constructor of the Instruction, if it holds a Method.
InstructionFormat3RC(int opcode, java.lang.String type, int[] registers)
          Constructor of the Instruction, if it holds a Type.
 
Method Summary
 int getIndex()
          Returns the Index stored in this Instruction.
static int getIndex(IDalvikValueReader reader)
          Returns the Index encoded where the Reader points.
 int[] getRegisters()
          Return the indexes of the registers
static int[] getRegisters(IDalvikValueReader reader, int opcode)
          Returns the Registers encoded where the Reader points.
 int getSize()
          Returns the size of the instruction in bytes.
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

InstructionFormat3RC

public InstructionFormat3RC(int opcode,
                            Method method,
                            int[] registers)
Constructor of the Instruction, if it holds a Method.

Parameters:
opcode - 8 or 16 bits opcode.
method - Method this Instruction is holding.
registers - the registers. They must be consecutive.

InstructionFormat3RC

public InstructionFormat3RC(int opcode,
                            java.lang.String type,
                            int[] registers)
Constructor of the Instruction, if it holds a Type.

Parameters:
opcode - 8 or 16 bits opcode.
type - the Type this Instruction is holding.
registers - the registers. They must be consecutive.
Method Detail

getRegisters

public int[] getRegisters()
Description copied from interface: IRegisterArrayInstruction
Return the indexes of the registers

Specified by:
getRegisters in interface IRegisterArrayInstruction
Returns:
coded as an array in the order of the registers appearance.

getIndex

public int getIndex()
Description copied from interface: IIndexInstruction
Returns the Index stored in this Instruction.

Specified by:
getIndex in interface IIndexInstruction
Returns:
the Index stored in this Instruction.

getIndex

public static int getIndex(IDalvikValueReader reader)
Returns the Index encoded where the Reader points. It must be performed only once after having read the opcode and getRegisters must be called too.

Parameters:
reader - reader pointing after the 16-bit opcode.
Returns:
the Index.

getRegisters

public static int[] getRegisters(IDalvikValueReader reader,
                                 int opcode)
Returns the Registers encoded where the Reader points. It must be performed only once after having read the opcode and called getIndex.

Parameters:
reader - reader pointing after the 16-bit opcode.
opcode - the 16-bit opcode.
Returns:
the Registers.

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.

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.

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.