joeq.Compiler.BytecodeAnalysis
Class Bytecodes.Instruction

java.lang.Object
  extended by joeq.Compiler.BytecodeAnalysis.Bytecodes.Instruction
All Implemented Interfaces:
Serializable, 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 Object
implements Cloneable, Serializable

See Also:
Serialized Form

Field Summary
protected  short length
           
protected  short opcode
           
 
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(DataOutputStream out)
          Dump instruction as byte code to stream out.
 int getLength()
           
 short getOpcode()
           
protected  void initFromFile(jq_ConstantPool cp, jwutil.io.ByteSequence bytes, boolean wide)
          Read needed data (e.g.
 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.
 String toString()
           
 String toString(boolean verbose)
          Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

length

protected short length

opcode

protected short opcode
Constructor Detail

Bytecodes.Instruction

public Bytecodes.Instruction(short opcode,
                             short length)
Method Detail

dump

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

Parameters:
out - Output stream
Throws:
IOException

toString

public 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 String toString()
Overrides:
toString in class 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

initFromFile

protected void initFromFile(jq_ConstantPool cp,
                            jwutil.io.ByteSequence bytes,
                            boolean wide)
                     throws IOException
Read needed data (e.g. index) from file.

Parameters:
cp - constant pool of class we are reading
bytes - byte sequence to read from
wide - "wide" instruction flag
Throws:
IOException

readInstruction

public static final Bytecodes.Instruction readInstruction(jq_ConstantPool cp,
                                                          jwutil.io.ByteSequence bytes)
                                                   throws 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:
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


Copyright © 2001-2008 John Whaley. All Rights Reserved.