Package org.apache.bcel.generic
Class LocalVariableInstruction
- java.lang.Object
-
- org.apache.bcel.generic.Instruction
-
- org.apache.bcel.generic.LocalVariableInstruction
-
- All Implemented Interfaces:
java.lang.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
Fields Modifier and Type Field Description private shortcanonTagprivate shortcTagprotected intnDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter-
Fields inherited from class org.apache.bcel.generic.Instruction
EMPTY_ARRAY, length, opcode
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)LocalVariableInstruction()Empty constructor needed for Instruction.readInstruction.(package private)LocalVariableInstruction(short canonTag, short cTag)Empty constructor needed for Instruction.readInstruction.protectedLocalVariableInstruction(short opcode, short cTag, int n)Constructs a LocalVariableInstruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump(java.io.DataOutputStream out)Dumps instruction as byte code to stream out.shortgetCanonicalTag()Gets the canonical tag for instruction, for example, ALOAD for ALOAD_0.intgetIndex()Gets the index.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)Reads needed data (for example index) from file.voidsetIndex(int n)Sets the local variable index.(package private) voidsetIndexOnly(int n)Sets the index of the referenced variable (n) onlyjava.lang.StringtoString(boolean verbose)Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"private booleanwide()-
Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, dispose, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, setLength, setOpcode, toString, toString
-
-
-
-
Constructor Detail
-
LocalVariableInstruction
LocalVariableInstruction()
Empty constructor needed for Instruction.readInstruction. Also used by IINC()!
-
LocalVariableInstruction
LocalVariableInstruction(short canonTag, short cTag)Empty constructor needed for Instruction.readInstruction. Not to be used otherwise. tag and length are defined in readInstruction and initFromFile, respectively.
-
LocalVariableInstruction
protected LocalVariableInstruction(short opcode, short cTag, int n)Constructs a LocalVariableInstruction.- Parameters:
opcode- Instruction opcode.cTag- Instruction number for compact version, ALOAD_0, for example.n- local variable index (unsigned short).
-
-
Method Detail
-
dump
public void dump(java.io.DataOutputStream out) throws java.io.IOExceptionDumps instruction as byte code to stream out.- Overrides:
dumpin classInstruction- Parameters:
out- Output stream.- Throws:
java.io.IOException- Thrown when an I/O exception of some sort has occurred.
-
getCanonicalTag
public short 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
public final int getIndex()
Description copied from interface:IndexedInstructionGets the index.- Specified by:
getIndexin interfaceIndexedInstruction- Returns:
- local variable index (n) 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.- Specified by:
getTypein interfaceTypedInstruction- Parameters:
cp- the constant pool generator.- Returns:
- type associated with the instruction.
-
initFromFile
protected void initFromFile(ByteSequence bytes, boolean wide) throws java.io.IOException
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:
java.io.IOException- may be thrown if the implementation needs to read data from the file
-
setIndex
public void setIndex(int n)
Sets the local variable index. also updates opcode and length TODO Why?- Specified by:
setIndexin interfaceIndexedInstruction- Parameters:
n- the index.- See Also:
setIndexOnly(int)
-
setIndexOnly
final void setIndexOnly(int n)
Sets the index of the referenced variable (n) only- Since:
- 6.0
- See Also:
setIndex(int)
-
toString
public java.lang.String toString(boolean verbose)
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.
-
wide
private boolean wide()
-
-