Class LocalVariableInstruction
java.lang.Object
org.apache.bcel.generic.Instruction
org.apache.bcel.generic.LocalVariableInstruction
- All Implemented Interfaces:
Cloneable, IndexedInstruction, TypedInstruction
- Direct Known Subclasses:
IINC, LoadInstruction, StoreInstruction
public abstract class LocalVariableInstruction
extends Instruction
implements TypedInstruction, IndexedInstruction
Abstract super class for instructions dealing with local variables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterFields inherited from class Instruction
length, opcode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLocalVariableInstruction(short opcode, short cTag, int n) Constructs a LocalVariableInstruction. -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(DataOutputStream out) Dumps instruction as byte code to stream out.shortGets the canonical tag for instruction, for example, ALOAD for ALOAD_0.final intgetIndex()Gets the index.Returns the type associated with the instruction - in case of ALOAD or ASTORE Type.OBJECT is returned.protected voidinitFromFile(ByteSequence bytes, boolean wide) Reads needed data (for example index) from file.voidsetIndex(int index) Sets the local variable index.toString(boolean verbose) Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"Methods inherited from class Instruction
accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, toString, toString
-
Field Details
-
n
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
-
Constructor Details
-
LocalVariableInstruction
Constructs a LocalVariableInstruction.- Parameters:
opcode- Instruction opcode.cTag- Instruction number for compact version, ALOAD_0, for example.n- local variable index (unsigned short).
-
-
Method Details
-
dump
Dumps instruction as byte code to stream out.- Overrides:
dumpin classInstruction- Parameters:
out- Output stream.- Throws:
IOException- Thrown when an I/O exception of some sort has occurred.
-
getCanonicalTag
Gets the canonical tag for instruction, for example, ALOAD for ALOAD_0.- Returns:
- canonical tag for instruction, for example, ALOAD for ALOAD_0.
-
getIndex
Description copied from interface:IndexedInstructionGets the index.- Specified by:
getIndexin interfaceIndexedInstruction- Returns:
- local variable index (n) referred by this instruction.
-
getType
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.- Specified by:
getTypein interfaceTypedInstruction- Parameters:
cp- The constant pool generator.- Returns:
- type associated with the instruction.
-
initFromFile
Reads needed data (for example index) from file.(ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
- Overrides:
initFromFilein classInstruction- Parameters:
bytes- byte sequence to read from.wide- "wide" instruction flag.- Throws:
IOException- Thrown if the implementation needs to read data from the file
-
setIndex
Sets the local variable index. also updates opcode and length TODO Why?- Specified by:
setIndexin interfaceIndexedInstruction- Parameters:
index- local variable index (unsigned short).- Throws:
ClassGenException- Thrown if index is out of bounds.- See Also:
-
toString
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"- Overrides:
toStringin classInstruction- Parameters:
verbose- long/short format switch.- Returns:
- mnemonic for instruction.
-