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.
-
length
-
-
position
-
-
tag
-
-
Instruction()
- Empty constructor needed for the Class.newInstance() statement in
Instruction.readInstruction().
-
Instruction(short, short)
-
-
consumeStack()
-
-
copy()
- Use with caution, since `BranchInstruction's have a `target' reference which
is not copied correctly (only basic types are).
-
dump(DataOutputStream)
- Dump instruction as byte code to stream out.
-
getLength()
-
-
getPosition()
-
-
getTag()
-
-
initFromFile(ByteSequence, boolean)
- Read needed data (e.g.
-
produceStack()
-
-
readInstruction(ByteSequence)
- Read an instruction from (byte code) input stream and return the
appropiate object.
-
setPosition(int)
- Update position of instruction
-
setTag(short)
- Needed in readInstruction.
-
toString()
-
-
updatePosition(int, int)
- Called by InstructionList.setPositions when setting the position for every
instruction.
position
protected int position
length
protected short length
tag
protected short tag
Instruction
Instruction()
- Empty constructor needed for the Class.newInstance() statement in
Instruction.readInstruction(). Not to be used otherwise.
Instruction
public Instruction(short tag,
short length)
dump
public void dump(DataOutputStream out) throws IOException
- Dump instruction as byte code to stream out.
- Parameters:
- out - Output stream
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
toString
public String toString()
- Returns:
- mnemonic for instruction
- Overrides:
- toString in class Object
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
initFromFile
protected void initFromFile(ByteSequence bytes,
boolean wide) throws IOException
- Read needed data (e.g. index) from file.
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
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
getTag
public short getTag()
- Returns:
- opcode number
getLength
public int getLength()
- Returns:
- length (in bytes) of instruction
getPosition
public int getPosition()
- Returns:
- (absolute) position in byte code of this instruction in the current
method.
setPosition
public void setPosition(int position)
- Update position of instruction
setTag
private void setTag(short tag)
- Needed in readInstruction.
All Packages Class Hierarchy This Package Previous Next Index