ProGuard

proguard.classfile.instruction
Class Instruction

java.lang.Object
  extended byproguard.classfile.instruction.Instruction
Direct Known Subclasses:
BranchInstruction, CpInstruction, LookUpSwitchInstruction, SimpleInstruction, TableSwitchInstruction, VariableInstruction

public abstract class Instruction
extends Object

Base class for representing instructions.


Field Summary
 byte opcode
           
 
Constructor Summary
Instruction()
           
 
Method Summary
abstract  void accept(ClassFile classFile, MethodInfo methodInfo, CodeAttrInfo codeAttrInfo, int offset, InstructionVisitor instructionVisitor)
          Accepts the given visitor.
 String getName()
          Returns the name of the instruction.
 boolean isCategory2()
          Returns whether the instruction is a Category 2 instruction.
protected  boolean isWide()
          Returns whether the instruction is wide, i.e.
abstract  int length(int offset)
          Returns the length in bytes of the instruction.
protected static int readByte(byte[] code, int offset)
           
protected abstract  void readInfo(byte[] code, int offset)
          Reads the data following the instruction opcode.
protected static int readInt(byte[] code, int offset)
           
protected static int readShort(byte[] code, int offset)
           
protected static int readSignedByte(byte[] code, int offset)
           
protected static int readSignedShort(byte[] code, int offset)
           
protected static int readSignedValue(byte[] code, int offset, int valueSize)
           
protected static int readValue(byte[] code, int offset, int valueSize)
           
abstract  Instruction shrink()
          Shrinks this instruction to its shortest possible form.
 int stackPopCount(ClassFile classFile)
          Returns the number of entries popped from the stack during the execution of the instruction.
 int stackPushCount(ClassFile classFile)
          Returns the number of entries pushed onto the stack during the execution of the instruction.
abstract  String toString(int offset)
          Returns a description of the instruction, at the given offset.
 void write(CodeAttrInfo codeAttrInfo, int offset)
          Writes the Instruction back to the data in the byte array.
protected static void writeByte(byte[] code, int offset, int value)
           
protected abstract  void writeInfo(byte[] code, int offset)
          Writes data following the instruction opcode.
protected static void writeInt(byte[] code, int offset, int value)
           
protected static void writeShort(byte[] code, int offset, int value)
           
protected static void writeValue(byte[] code, int offset, int value, int valueSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

opcode

public byte opcode
Constructor Detail

Instruction

public Instruction()
Method Detail

shrink

public abstract Instruction shrink()
Shrinks this instruction to its shortest possible form.

Returns:
this instruction.

write

public final void write(CodeAttrInfo codeAttrInfo,
                        int offset)
Writes the Instruction back to the data in the byte array.


isWide

protected boolean isWide()
Returns whether the instruction is wide, i.e. preceded by a wide opcode. With the current specifications, only variable instructions can be wide.


readInfo

protected abstract void readInfo(byte[] code,
                                 int offset)
Reads the data following the instruction opcode.


writeInfo

protected abstract void writeInfo(byte[] code,
                                  int offset)
Writes data following the instruction opcode.


length

public abstract int length(int offset)
Returns the length in bytes of the instruction.


accept

public abstract void accept(ClassFile classFile,
                            MethodInfo methodInfo,
                            CodeAttrInfo codeAttrInfo,
                            int offset,
                            InstructionVisitor instructionVisitor)
Accepts the given visitor.


toString

public abstract String toString(int offset)
Returns a description of the instruction, at the given offset.


getName

public String getName()
Returns the name of the instruction.


isCategory2

public boolean isCategory2()
Returns whether the instruction is a Category 2 instruction. This means that it operates on long or double arguments.


stackPopCount

public int stackPopCount(ClassFile classFile)
Returns the number of entries popped from the stack during the execution of the instruction.


stackPushCount

public int stackPushCount(ClassFile classFile)
Returns the number of entries pushed onto the stack during the execution of the instruction.


readByte

protected static int readByte(byte[] code,
                              int offset)

readShort

protected static int readShort(byte[] code,
                               int offset)

readInt

protected static int readInt(byte[] code,
                             int offset)

readValue

protected static int readValue(byte[] code,
                               int offset,
                               int valueSize)

readSignedByte

protected static int readSignedByte(byte[] code,
                                    int offset)

readSignedShort

protected static int readSignedShort(byte[] code,
                                     int offset)

readSignedValue

protected static int readSignedValue(byte[] code,
                                     int offset,
                                     int valueSize)

writeByte

protected static void writeByte(byte[] code,
                                int offset,
                                int value)

writeShort

protected static void writeShort(byte[] code,
                                 int offset,
                                 int value)

writeInt

protected static void writeInt(byte[] code,
                               int offset,
                               int value)

writeValue

protected static void writeValue(byte[] code,
                                 int offset,
                                 int value,
                                 int valueSize)

ProGuard