proguard.classfile.instruction
Class ConstantInstruction

java.lang.Object
  extended by proguard.classfile.instruction.Instruction
      extended by proguard.classfile.instruction.ConstantInstruction
All Implemented Interfaces:
ConstantVisitor

public class ConstantInstruction
extends Instruction
implements ConstantVisitor

This Instruction represents an instruction that refers to an entry in the constant pool.


Field Summary
 int constant
           
 int constantIndex
           
 
Fields inherited from class proguard.classfile.instruction.Instruction
opcode
 
Constructor Summary
ConstantInstruction()
          Creates an uninitialized ConstantInstruction.
ConstantInstruction(byte opcode, int constantIndex)
          Creates a new ConstantInstruction with the given opcode and constant pool index.
ConstantInstruction(byte opcode, int constantIndex, int constant)
          Creates a new ConstantInstruction with the given opcode, constant pool index, and constant.
 
Method Summary
 void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, InstructionVisitor instructionVisitor)
          Accepts the given visitor.
 byte canonicalOpcode()
          Returns the canonical opcode of this instruction, i.e.
 ConstantInstruction copy(ConstantInstruction constantInstruction)
          Copies the given instruction into this instruction.
 int length(int offset)
          Returns the length in bytes of the instruction.
protected  void readInfo(byte[] code, int offset)
          Reads the data following the instruction opcode.
 Instruction shrink()
          Shrinks this instruction to its shortest possible form.
 int stackPopCount(Clazz clazz)
          Returns the number of entries popped from the stack during the execution of the instruction.
 int stackPushCount(Clazz clazz)
          Returns the number of entries pushed onto the stack during the execution of the instruction.
 java.lang.String toString()
           
 void visitClassConstant(Clazz clazz, ClassConstant classConstant)
           
 void visitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant)
           
 void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
           
 void visitFloatConstant(Clazz clazz, FloatConstant floatConstant)
           
 void visitIntegerConstant(Clazz clazz, IntegerConstant integerConstant)
           
 void visitInterfaceMethodrefConstant(Clazz clazz, InterfaceMethodrefConstant interfaceMethodrefConstant)
           
 void visitLongConstant(Clazz clazz, LongConstant longConstant)
           
 void visitMethodrefConstant(Clazz clazz, MethodrefConstant methodrefConstant)
           
 void visitNameAndTypeConstant(Clazz clazz, NameAndTypeConstant nameAndTypeConstant)
           
 void visitStringConstant(Clazz clazz, StringConstant stringConstant)
           
 void visitUtf8Constant(Clazz clazz, Utf8Constant utf8Constant)
           
protected  void writeInfo(byte[] code, int offset)
          Writes data following the instruction opcode.
 
Methods inherited from class proguard.classfile.instruction.Instruction
getName, isCategory2, isWide, readByte, readInt, readShort, readSignedByte, readSignedShort, readSignedValue, readValue, toString, write, write, writeByte, writeInt, writeShort, writeSignedByte, writeSignedShort, writeSignedValue, writeValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

constantIndex

public int constantIndex

constant

public int constant
Constructor Detail

ConstantInstruction

public ConstantInstruction()
Creates an uninitialized ConstantInstruction.


ConstantInstruction

public ConstantInstruction(byte opcode,
                           int constantIndex)
Creates a new ConstantInstruction with the given opcode and constant pool index.


ConstantInstruction

public ConstantInstruction(byte opcode,
                           int constantIndex,
                           int constant)
Creates a new ConstantInstruction with the given opcode, constant pool index, and constant.

Method Detail

copy

public ConstantInstruction copy(ConstantInstruction constantInstruction)
Copies the given instruction into this instruction.

Parameters:
constantInstruction - the instruction to be copied.
Returns:
this instruction.

canonicalOpcode

public byte canonicalOpcode()
Description copied from class: Instruction
Returns the canonical opcode of this instruction, i.e. typically the opcode whose extension has been removed.

Overrides:
canonicalOpcode in class Instruction

shrink

public Instruction shrink()
Description copied from class: Instruction
Shrinks this instruction to its shortest possible form.

Specified by:
shrink in class Instruction
Returns:
this instruction.

readInfo

protected void readInfo(byte[] code,
                        int offset)
Description copied from class: Instruction
Reads the data following the instruction opcode.

Specified by:
readInfo in class Instruction

writeInfo

protected void writeInfo(byte[] code,
                         int offset)
Description copied from class: Instruction
Writes data following the instruction opcode.

Specified by:
writeInfo in class Instruction

length

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

Specified by:
length in class Instruction

accept

public void accept(Clazz clazz,
                   Method method,
                   CodeAttribute codeAttribute,
                   int offset,
                   InstructionVisitor instructionVisitor)
Description copied from class: Instruction
Accepts the given visitor.

Specified by:
accept in class Instruction

stackPopCount

public int stackPopCount(Clazz clazz)
Description copied from class: Instruction
Returns the number of entries popped from the stack during the execution of the instruction.

Overrides:
stackPopCount in class Instruction

stackPushCount

public int stackPushCount(Clazz clazz)
Description copied from class: Instruction
Returns the number of entries pushed onto the stack during the execution of the instruction.

Overrides:
stackPushCount in class Instruction

visitIntegerConstant

public void visitIntegerConstant(Clazz clazz,
                                 IntegerConstant integerConstant)
Specified by:
visitIntegerConstant in interface ConstantVisitor

visitLongConstant

public void visitLongConstant(Clazz clazz,
                              LongConstant longConstant)
Specified by:
visitLongConstant in interface ConstantVisitor

visitFloatConstant

public void visitFloatConstant(Clazz clazz,
                               FloatConstant floatConstant)
Specified by:
visitFloatConstant in interface ConstantVisitor

visitDoubleConstant

public void visitDoubleConstant(Clazz clazz,
                                DoubleConstant doubleConstant)
Specified by:
visitDoubleConstant in interface ConstantVisitor

visitStringConstant

public void visitStringConstant(Clazz clazz,
                                StringConstant stringConstant)
Specified by:
visitStringConstant in interface ConstantVisitor

visitUtf8Constant

public void visitUtf8Constant(Clazz clazz,
                              Utf8Constant utf8Constant)
Specified by:
visitUtf8Constant in interface ConstantVisitor

visitClassConstant

public void visitClassConstant(Clazz clazz,
                               ClassConstant classConstant)
Specified by:
visitClassConstant in interface ConstantVisitor

visitNameAndTypeConstant

public void visitNameAndTypeConstant(Clazz clazz,
                                     NameAndTypeConstant nameAndTypeConstant)
Specified by:
visitNameAndTypeConstant in interface ConstantVisitor

visitFieldrefConstant

public void visitFieldrefConstant(Clazz clazz,
                                  FieldrefConstant fieldrefConstant)
Specified by:
visitFieldrefConstant in interface ConstantVisitor

visitInterfaceMethodrefConstant

public void visitInterfaceMethodrefConstant(Clazz clazz,
                                            InterfaceMethodrefConstant interfaceMethodrefConstant)
Specified by:
visitInterfaceMethodrefConstant in interface ConstantVisitor

visitMethodrefConstant

public void visitMethodrefConstant(Clazz clazz,
                                   MethodrefConstant methodrefConstant)
Specified by:
visitMethodrefConstant in interface ConstantVisitor

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object