jellyj.classfile.classgen
Class Instruction

Direct Known Subclasses:
AALOAD, AASTORE, ACONST_NULL, ARETURN, ARRAYLENGTH, ATHROW, BALOAD, BASTORE, BIPUSH, BranchInstruction, CALOAD, CASTORE, CPInstruction, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST, DDIV, DMUL, DNEG, DREM, DRETURN, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST, FDIV, FMUL, FNEG, FREM, FRETURN, FSUB, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST, IDIV, IINC, IMPDEP1, IMPDEP2, IMUL, INEG, IOR, IREM, IRETURN, ISHL, ISHR, ISUB, IUSHR, IXOR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST, LDIV, LMUL, LNEG, LocalVariableInstruction, LOR, LREM, LRETURN, LSHL, LSHR, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, NEWARRAY, NOP, POP, POP2, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP

public abstract class Instruction
implements Cloneable, Constants

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

Author:
JellyJ Design Group

Constructor Summary
 (package private) Instruction()
          Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction().
 Instruction(short tag, short length)
           

Method Summary
 intconsumeStack()
           
 (package private) Instructioncopy()
          Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are).
 voiddump(DataOutputStream out)
          Dump instruction as byte code to stream out.
 intgetLength()
           
 intgetPosition()
           
 shortgetTag()
           
 intproduceStack()
           
 final static InstructionreadInstruction(ByteSequence bytes)
          Read an instruction from (byte code) input stream and return the appropiate object.
 voidsetPosition(int position)
          Update position of instruction
 StringtoString()
           

Constructor Detail

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)
Method Detail

consumeStack

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

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

dump

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

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.

getTag

public short getTag()
Returns: opcode number

produceStack

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

readInstruction

public final static Instruction readInstruction(ByteSequence bytes)
throws java.io.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

setPosition

public void setPosition(int position)
Update position of instruction

toString

public String toString()
Returns: mnemonic for instruction