joeq.Compiler.BytecodeAnalysis
Class Bytecodes.Instruction

java.lang.Object
  extended by joeq.Compiler.BytecodeAnalysis.Bytecodes.Instruction
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Bytecodes.ACONST_NULL, Bytecodes.ArithmeticInstruction, Bytecodes.ArrayInstruction, Bytecodes.ARRAYLENGTH, Bytecodes.ATHROW, Bytecodes.BIPUSH, Bytecodes.BranchInstruction, Bytecodes.BREAKPOINT, Bytecodes.ConversionInstruction, Bytecodes.CPInstruction, Bytecodes.DCMPG, Bytecodes.DCMPL, Bytecodes.DCONST, Bytecodes.FCMPG, Bytecodes.FCMPL, Bytecodes.FCONST, Bytecodes.ICONST, Bytecodes.LCMP, Bytecodes.LCONST, Bytecodes.LocalVariableInstruction, Bytecodes.MONITORENTER, Bytecodes.MONITOREXIT, Bytecodes.NEWARRAY, Bytecodes.NOP, Bytecodes.RET, Bytecodes.ReturnInstruction, Bytecodes.SIPUSH, Bytecodes.StackInstruction
Enclosing interface:
Bytecodes

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

See Also:
Serialized Form

Constructor Summary
Bytecodes.Instruction(short opcode, short length)
           
 
Method Summary
abstract  void accept(Bytecodes.Visitor v)
          Call corresponding visitor method(s).
 int consumeStack()
           
 Bytecodes.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 getOpcode()
           
 int produceStack()
           
static Bytecodes.Instruction readInstruction(jq_ConstantPool cp, jwutil.io.ByteSequence bytes)
          Read an instruction from (byte code) input stream and return the appropiate object.
 java.lang.String toString()
           
 java.lang.String toString(boolean verbose)
          Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bytecodes.Instruction

public Bytecodes.Instruction(short opcode,
                             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
Throws:
java.io.IOException

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()
Overrides:
toString in class java.lang.Object
Returns:
mnemonic for instruction in verbose format

copy

public Bytecodes.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:
Bytecodes.BranchInstruction

readInstruction

public static final Bytecodes.Instruction readInstruction(jq_ConstantPool cp,
                                                          jwutil.io.ByteSequence bytes)
                                                   throws java.io.IOException
Read an instruction from (byte code) input stream and return the appropiate object.

Parameters:
cp - constant pool of class we are reading from
bytes - sequence of bytes to read
Returns:
instruction object being read
Throws:
java.io.IOException

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

getOpcode

public short getOpcode()
Returns:
this instructions opcode

getLength

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

accept

public abstract void accept(Bytecodes.Visitor v)
Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.

Parameters:
v - Visitor object