de.fub.bytecode.generic
Class LocalVariableInstruction

java.lang.Object
  |
  +--de.fub.bytecode.generic.Instruction
        |
        +--de.fub.bytecode.generic.LocalVariableInstruction
All Implemented Interfaces:
java.lang.Cloneable, IndexedInstruction, java.io.Serializable, 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.

Version:
$Id: LocalVariableInstruction.java,v 1.10 2001/08/28 10:28:05 dahm Exp $
Author:
M. Dahm
See Also:
Serialized Form

Field Summary
protected  int n
           
 
Fields inherited from class de.fub.bytecode.generic.Instruction
length, opcode
 
Constructor Summary
protected LocalVariableInstruction(short opcode, short c_tag, int n)
           
 
Method Summary
 void dump(java.io.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
 java.lang.String toString(boolean verbose)
          Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"< local variable index>">"
 
Methods inherited from class de.fub.bytecode.generic.Instruction
accept, consumeStack, consumeStack, copy, getLength, getOpcode, getTag, produceStack, produceStack, readInstruction, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

n

protected int n
Constructor Detail

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 Detail

dump

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

toString

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

initFromFile

protected void initFromFile(ByteSequence bytes,
                            boolean wide)
                     throws java.io.IOException
Read needed data (e.g. index) from file. PRE: (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
Overrides:
initFromFile in class Instruction
Following copied from class: de.fub.bytecode.generic.Instruction
Parameters:
bytes - byte sequence to read from
wide - "wide" instruction flag

getIndex

public final int getIndex()
Specified by:
getIndex in interface IndexedInstruction
Returns:
local variable index referred by this instruction.

setIndex

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

getCanonicalTag

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

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