org.apache.bcel.generic

Class LocalVariableInstruction

Implemented Interfaces:
Cloneable, IndexedInstruction, Serializable, TypedInstruction
Known Direct Subclasses:
IINC, LoadInstruction, StoreInstruction

public abstract class LocalVariableInstruction
extends Instruction
implements TypedInstruction, IndexedInstruction

Abstract super class for instructions dealing with local variables.
Version:
$Id: LocalVariableInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
Author:
M. Dahm

Field Summary

private short
c_tag
private short
canon_tag
protected int
n

Fields inherited from class org.apache.bcel.generic.Instruction

cmp, length, opcode

Constructor Summary

LocalVariableInstruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction().
LocalVariableInstruction(short canon_tag, short c_tag)
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction().
LocalVariableInstruction(short opcode, short c_tag, int n)

Method Summary

void
dump(DataOutputStream out)
Dump instruction as byte code to stream out.
short
getCanonicalTag()
int
getIndex()
Type
getType(ConstantPoolGen cp)
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)
Set the local variable index
String
toString(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, className, consumeStack, copy, dispose, dump, equals, getComparator, getLength, getName, getOpcode, initFromFile, produceStack, readInstruction, setComparator, setOpcode, toString, toString, toString

Field Details

c_tag

private short c_tag

canon_tag

private short canon_tag

n

protected int n

Constructor Details

LocalVariableInstruction

(package private)  LocalVariableInstruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Also used by IINC()!

LocalVariableInstruction

(package private)  LocalVariableInstruction(short canon_tag,
                                            short c_tag)
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise. tag and length are defined in readInstruction and initFromFile, respectively.

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 Details

dump

public void dump(DataOutputStream out)
            throws IOException
Dump instruction as byte code to stream out.
Overrides:
dump in interface Instruction
Parameters:
out - Output stream

getCanonicalTag

public short getCanonicalTag()
Returns:
canonical tag for instruction, e.g., ALOAD for ALOAD_0

getIndex

public final int getIndex()
Specified by:
getIndex in interface IndexedInstruction
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 .
Specified by:
getType in interface TypedInstruction
Returns:
type associated with the instruction

initFromFile

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

setIndex

public void setIndex(int n)
Set the local variable index
Specified by:
setIndex in interface IndexedInstruction

toString

public String toString(boolean verbose)
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"
Overrides:
toString in interface Instruction
Parameters:
verbose - long/short format switch
Returns:
mnemonic for instruction

wide

private final boolean wide()