org.apache.bcel.generic
Class Instruction
java.lang.Object
org.apache.bcel.generic.Instruction
- Cloneable, Serializable
public abstract class Instruction
extends java.lang.Object
implements Cloneable, Serializable
Abstract super class for all Java byte codes.
$Id: Instruction.java 386056 2006-03-15 11:31:56Z tcurdt $
Instruction() - Empty constructor needed for the Class.newInstance() statement in
Instruction.readInstruction().
|
Instruction(short opcode, short length)
|
abstract void | accept(Visitor v) - Call corresponding visitor method(s).
|
private static String | className(short opcode)
|
int | consumeStack(ConstantPoolGen cpg) - This method also gives right results for instructions whose
effect on the stack depends on the constant pool entry they
reference.
|
Instruction | copy() - Use with caution, since `BranchInstruction's have a `target' reference which
is not copied correctly (only basic types are).
|
(package private) void | dispose() - Some instructions may be reused, so don't do anything by default.
|
void | dump(DataOutputStream out) - Dump instruction as byte code to stream out.
|
boolean | equals(Object that) - Check for equality, delegated to comparator
|
static InstructionComparator | getComparator() - Get Comparator object used in the equals() method to determine
equality of instructions.
|
int | getLength()
|
String | getName()
|
short | getOpcode()
|
protected void | initFromFile(ByteSequence bytes, boolean wide) - Read needed data (e.g.
|
int | produceStack(ConstantPoolGen cpg) - This method also gives right results for instructions whose
effect on the stack depends on the constant pool entry they
reference.
|
static Instruction | readInstruction(ByteSequence bytes) - Read an instruction from (byte code) input stream and return the
appropiate object.
|
static void | setComparator(InstructionComparator c) - Set comparator to be used for equals().
|
private void | setOpcode(short opcode) - Needed in readInstruction.
|
String | toString()
|
String | toString(boolean verbose) - Long output format:
<name of opcode> "["<opcode number>"]"
"("<length of instruction>")"
|
String | toString(ConstantPool cp)
|
length
protected short length
opcode
protected short opcode
Instruction
(package private) Instruction()
Empty constructor needed for the Class.newInstance() statement in
Instruction.readInstruction(). Not to be used otherwise.
Instruction
public Instruction(short opcode,
short length)
accept
public abstract void accept(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.
className
private static final String className(short opcode)
consumeStack
public int consumeStack(ConstantPoolGen cpg)
This method also gives right results for instructions whose
effect on the stack depends on the constant pool entry they
reference.
- Number of words consumed from stack by this instruction,
or Constants.UNPREDICTABLE, if this can not be computed statically
copy
public 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.
- (shallow) copy of an instruction
dispose
(package private) void dispose()
Some instructions may be reused, so don't do anything by default.
dump
public void dump(DataOutputStream out)
throws IOException
Dump instruction as byte code to stream out.
equals
public boolean equals(Object that)
Check for equality, delegated to comparator
- true if that is an Instruction and has the same opcode
getComparator
public static InstructionComparator getComparator()
Get Comparator object used in the equals() method to determine
equality of instructions.
- currently used comparator for equals()
getLength
public int getLength()
- length (in bytes) of instruction
getName
public String getName()
- name of instruction, i.e., opcode name
getOpcode
public short getOpcode()
initFromFile
protected void initFromFile(ByteSequence bytes,
boolean wide)
throws IOException
Read needed data (e.g. index) from file.
bytes
- byte sequence to read fromwide
- "wide" instruction flag
produceStack
public int produceStack(ConstantPoolGen cpg)
This method also gives right results for instructions whose
effect on the stack depends on the constant pool entry they
reference.
- Number of words produced onto stack by this instruction,
or Constants.UNPREDICTABLE, if this can not be computed statically
readInstruction
public static final Instruction readInstruction(ByteSequence bytes)
throws IOException
Read an instruction from (byte code) input stream and return the
appropiate object.
bytes
- input stream bytes
- instruction object being read
setComparator
public static void setComparator(InstructionComparator c)
Set comparator to be used for equals().
setOpcode
private void setOpcode(short opcode)
Needed in readInstruction.
toString
public String toString()
- mnemonic for instruction in verbose format
toString
public String toString(boolean verbose)
Long output format:
<name of opcode> "["<opcode number>"]"
"("<length of instruction>")"
verbose
- long/short format switch
toString
public String toString(ConstantPool cp)
- mnemonic for instruction with sumbolic references resolved