alt.jiapi.reflect
Class Instruction

java.lang.Object
  extended by alt.jiapi.reflect.Instruction
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
BranchInstruction, CPInstruction, SwitchInstruction

public class Instruction
extends java.lang.Object
implements java.lang.Cloneable

This class represents an entry in InstructionList.

Version:
$Revision: 1.20 $ $Date: 2010/03/05 10:22:25 $
Author:
Mika Riekkinen, Joni Suominen
See Also:
InstructionList

Constructor Summary
Instruction(byte[] bytes)
          Constructor.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Gets a named attribute.
 byte[] getBytes()
          Gets the bytes of this instruction.
protected  short getOffset()
          Gets the offset of this instruction.
 byte getOpcode()
          Gets the opcode of this Instruction.
 int length()
          Get the length of this instruction.
 void setAttribute(java.lang.String name)
          Sets a named attribute to this Instruction.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets a named attribute to this Instruction.
protected  void setBytes(byte[] bytes)
          Set the bytes of this Instruction.
protected  void setOffset(short offset)
          Sets the offset of this instruction.
 short stackConsumption()
          Get the stack consumption of this Instruction.
 short stackUsage()
          Get the stack usage this Instruction uses.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Instruction

public Instruction(byte[] bytes)
Constructor. Byte array given, must hold all the data for this Instruction. First byte must be the opcode of this Instruction.

Parameters:
bytes - Byte array representing this instruction. May not be null. Bytes must have at least one byte in it.
Throws:
java.lang.IllegalArgumentException - is thrown, if byte[].length == 0
NullpointerException - is thrown, if byte[] == null
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Gets a named attribute.

Returns:
null, if no such attribute is found

getBytes

public byte[] getBytes()
Gets the bytes of this instruction. First byte in array is its opcode.

Returns:
bytes of this instruction.

getOffset

protected short getOffset()
Gets the offset of this instruction. Offset is calculated as bytes from the beginning of the method.


getOpcode

public byte getOpcode()
Gets the opcode of this Instruction.

Returns:
opcode of this instruction.

length

public int length()
Get the length of this instruction. This is the same as getBytes().length


setAttribute

public void setAttribute(java.lang.String name)
Sets a named attribute to this Instruction.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets a named attribute to this Instruction.


setBytes

protected void setBytes(byte[] bytes)
Set the bytes of this Instruction.

Parameters:
bytes -

setOffset

protected void setOffset(short offset)
Sets the offset of this instruction. Offset is calculated as bytes from the beginning of the method.


stackConsumption

public short stackConsumption()
Get the stack consumption of this Instruction. Stack consumption is allways positive, or zero, and indicates how many elements of data this instruction needs for its execution.

Returns:
Stack consumption

stackUsage

public short stackUsage()
Get the stack usage this Instruction uses. Negative stack usage means this Instruction consumes(pops) data from stack. Positive stack usage means this Instructions produces(pushes) data on stack.

Some instructions may both consume and produce data on stack. This method returns the total usage after instruction has been executed.

Returns:
Stack usage

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2001. Documenation generated August 26 2011.