Package org.apache.bcel.generic
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 TypeFieldDescriptionprivate short
private short
protected int
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setterFields inherited from class org.apache.bcel.generic.Instruction
EMPTY_ARRAY, length, opcode
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Empty constructor needed for Instruction.readInstruction.(package private)
LocalVariableInstruction
(short canonTag, short cTag) Empty constructor needed for Instruction.readInstruction.protected
LocalVariableInstruction
(short opcode, short cTag, int n) -
Method Summary
Modifier and TypeMethodDescriptionvoid
dump
(DataOutputStream out) Dump instruction as byte code to stream out.short
final int
getIndex()
Returns the type associated with the instruction - in case of ALOAD or ASTORE Type.OBJECT is returned.protected void
initFromFile
(ByteSequence bytes, boolean wide) Read needed data (e.g.void
setIndex
(int n) Sets the local variable index.(package private) final void
setIndexOnly
(int n) Sets the index of the referenced variable (n) onlytoString
(boolean verbose) Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"private boolean
wide()
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
-
Field Details
-
n
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter -
cTag
private short cTag -
canonTag
private short canonTag
-
-
Constructor Details
-
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) - Parameters:
opcode
- Instruction opcodecTag
- Instruction number for compact version, ALOAD_0, e.g.n
- local variable index (unsigned short)
-
-
Method Details
-
dump
Dump instruction as byte code to stream out.- Overrides:
dump
in classInstruction
- Parameters:
out
- Output stream- Throws:
IOException
- Thrown when an I/O exception of some sort has occurred.
-
getCanonicalTag
public short getCanonicalTag()- Returns:
- canonical tag for instruction, e.g., ALOAD for ALOAD_0
-
getIndex
public final int getIndex()- Specified by:
getIndex
in 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:
getType
in interfaceTypedInstruction
- Returns:
- type associated with the instruction
-
initFromFile
Read needed data (e.g. index) from file.(ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
- Overrides:
initFromFile
in classInstruction
- Parameters:
bytes
- byte sequence to read fromwide
- "wide" instruction flag- Throws:
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:
setIndex
in interfaceIndexedInstruction
- See Also:
-
setIndexOnly
final void setIndexOnly(int n) Sets the index of the referenced variable (n) only- Since:
- 6.0
- See Also:
-
toString
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"- Overrides:
toString
in classInstruction
- Parameters:
verbose
- long/short format switch- Returns:
- mnemonic for instruction
-
wide
private boolean wide()
-