All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class espresso.classfile.classgen.Instruction

java.lang.Object
   |
   +----espresso.classfile.classgen.Instruction

public abstract class Instruction
extends Object
implements Constants, Cloneable
This abstract class is the super class for all java byte codes.


Variable Index

 o length
 o position
 o tag

Constructor Index

 o Instruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction().
 o Instruction(short, short)

Method Index

 o consumeStack()
 o copy()
Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are).
 o dump(DataOutputStream)
Dump instruction as byte code to stream out.
 o getLength()
 o getPosition()
 o getTag()
 o initFromFile(ByteSequence, boolean)
Read needed data (e.g.
 o produceStack()
 o readInstruction(ByteSequence)
Read an instruction from (byte code) input stream and return the appropiate object.
 o setPosition(int)
Update position of instruction
 o setTag(short)
Needed in readInstruction.
 o toString()
 o updatePosition(int, int)
Called by InstructionList.setPositions when setting the position for every instruction.

Variables

 o position
 protected int position
 o length
 protected short length
 o tag
 protected short tag

Constructors

 o Instruction
 Instruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.

 o Instruction
 public Instruction(short tag,
                    short length)

Methods

 o dump
 public void dump(DataOutputStream out) throws IOException
Dump instruction as byte code to stream out.

Parameters:
out - Output stream
 o updatePosition
 protected int updatePosition(int offset,
                              int max_offset)
Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable length instructions `setPositions' performs multiple passes over the instruction list to calculate the correct (byte) positions and offsets by calling this function.

Parameters:
offset - additional offset caused by preceding (variable length) instructions
max_offset - the maximum offset that may be caused by these instructions
Returns:
additional offset caused by possible change of this instruction's length
 o toString
 public String toString()
Returns:
mnemonic for instruction
Overrides:
toString in class Object
 o copy
 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. Used by BranchHandle.setTarget()

Returns:
(shallow) copy of an instruction
See Also:
BranchHandle
 o initFromFile
 protected void initFromFile(ByteSequence bytes,
                             boolean wide) throws IOException
Read needed data (e.g. index) from file.

 o readInstruction
 public static final Instruction readInstruction(ByteSequence bytes) throws IOException
Read an instruction from (byte code) input stream and return the appropiate object.

Parameters:
file - file to read from
Returns:
instruction object being read
 o consumeStack
 public int consumeStack()
Returns:
Number of words consumed from stack by this instruction
 o produceStack
 public int produceStack()
Returns:
Number of words produced onto stack by this instruction
 o getTag
 public short getTag()
Returns:
opcode number
 o getLength
 public int getLength()
Returns:
length (in bytes) of instruction
 o getPosition
 public int getPosition()
Returns:
(absolute) position in byte code of this instruction in the current method.
 o setPosition
 public void setPosition(int position)
Update position of instruction

 o setTag
 private void setTag(short tag)
Needed in readInstruction.


All Packages  Class Hierarchy  This Package  Previous  Next  Index