org.apache.bcel.generic

Class LocalVariableInstruction

public abstract class LocalVariableInstruction extends Instruction implements TypedInstruction, IndexedInstruction

Abstract super class for instructions dealing with local variables.
Field Summary
protected intn
Constructor Summary
protected LocalVariableInstruction(short opcode, short c_tag, int n)
Method Summary
voiddump(DataOutputStream out)
Dump instruction as byte code to stream out.
shortgetCanonicalTag()
intgetIndex()
TypegetType(ConstantPoolGen cp)
Returns the type associated with the instruction - in case of ALOAD or ASTORE Type.OBJECT is returned.
protected voidinitFromFile(ByteSequence bytes, boolean wide)
Read needed data (e.g. index) from file.
voidsetIndex(int n)
Set the local variable index
StringtoString(boolean verbose)
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"

Field Detail

n

protected int n

Constructor Detail

LocalVariableInstruction

protected LocalVariableInstruction(short opcode, short c_tag, int n)

Parameters: opcode Instruction opcode c_tag Instruction number for compact version, ALOAD_0, e.g. n local variable index (unsigned short)

Method Detail

dump

public void dump(DataOutputStream out)
Dump instruction as byte code to stream out.

Parameters: out Output stream

getCanonicalTag

public short getCanonicalTag()

Returns: canonical tag for instruction, e.g., ALOAD for ALOAD_0

getIndex

public final int getIndex()

Returns: local variable index referred by this instruction.

getType

public Type getType(ConstantPoolGen cp)
Returns the type associated with the instruction - in case of ALOAD or ASTORE Type.OBJECT is returned. This is just a bit incorrect, because ALOAD and ASTORE may work on every ReferenceType (including Type.NULL) and ASTORE may even work on a ReturnaddressType .

Returns: type associated with the instruction

initFromFile

protected void initFromFile(ByteSequence bytes, boolean wide)
Read needed data (e.g. index) from file. PRE: (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)

setIndex

public void setIndex(int n)
Set the local variable index

toString

public String toString(boolean verbose)
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"

Parameters: verbose long/short format switch

Returns: mnemonic for instruction