de.fub.bytecode.generic
Class Instruction

java.lang.Object
  |
  +--de.fub.bytecode.generic.Instruction
Direct Known Subclasses:
ACONST_NULL, ArithmeticInstruction, ArrayInstruction, ARRAYLENGTH, ATHROW, BIPUSH, BranchInstruction, ConversionInstruction, CPInstruction, DCMPG, DCMPL, DCONST, FCMPG, FCMPL, FCONST, ICONST, IINC, IMPDEP1, IMPDEP2, LCMP, LCONST, LocalVariableInstruction, MONITORENTER, MONITOREXIT, NEWARRAY, NOP, RET, ReturnInstruction, SIPUSH, StackInstruction

public abstract class Instruction
extends java.lang.Object
implements Constants, java.lang.Cloneable, java.io.Serializable

This abstract class is the super class for all java byte codes.

Version:
$Id: Instruction.java,v 1.13 1999/09/22 13:00:09 dahm Exp $
Author:
M. Dahm
See Also:
Serialized Form

Field Summary
protected  short length
           
protected  short tag
           
 
Constructor Summary
Instruction(short tag, short length)
           
 
Method Summary
 int consumeStack()
           
 int consumeStack(ConstantPoolGen cpg)
          Also works for instructions whose stack effect depends on the constant pool entry they reference.
 Instruction copy()
          Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are).
 void dump(java.io.DataOutputStream out)
          Dump instruction as byte code to stream out.
 int getLength()
           
 short getTag()
           
protected  void initFromFile(ByteSequence bytes, boolean wide)
          Read needed data (e.g.
 int produceStack()
           
 int produceStack(ConstantPoolGen cpg)
          Also works for instructions whose stack effect depends on the constant pool entry they reference.
 java.lang.String toString()
           
 java.lang.String toString(boolean verbose)
          Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"
 java.lang.String toString(ConstantPool cp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

length

protected short length

tag

protected short tag
Constructor Detail

Instruction

public Instruction(short tag,
                   short length)
Method Detail

dump

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

toString

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

toString

public java.lang.String toString()
Returns:
mnemonic for instruction in verbose format
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(ConstantPool cp)
Returns:
mnemonic for instruction with sumbolic references resolved

copy

public Instruction copy()
Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are). This also applies for `Select' instructions with their multiple branch targets.
Returns:
(shallow) copy of an instruction
See Also:
BranchInstruction

initFromFile

protected void initFromFile(ByteSequence bytes,
                            boolean wide)
                     throws java.io.IOException
Read needed data (e.g. index) from file.

consumeStack

public int consumeStack()
Returns:
Number of words consumed from stack by this instruction

produceStack

public int produceStack()
Returns:
Number of words produced onto stack by this instruction

consumeStack

public int consumeStack(ConstantPoolGen cpg)
Also works for instructions whose stack effect depends on the constant pool entry they reference.
Returns:
Number of words consumed from stack by this instruction

produceStack

public int produceStack(ConstantPoolGen cpg)
Also works for instructions whose stack effect depends on the constant pool entry they reference.
Returns:
Number of words produced onto stack by this instruction

getTag

public short getTag()
Returns:
opcode number

getLength

public int getLength()
Returns:
length (in bytes) of instruction