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,v 1.2 2002/08/07 18:01:32 mdahm Exp $
Author:
M. Dahm

Field Summary

protected int
n

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

length, opcode

Constructor Summary

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>">"

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

accept, consumeStack, copy, dump, equals, getComparator, getLength, getName, getOpcode, initFromFile, produceStack, readInstruction, setComparator, toString, toString, toString

Field Details

n

protected int n

Constructor Details

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