org.apache.bcel.generic
public abstract class Instruction extends Object implements Cloneable, Serializable
Modifier and Type | Field and Description |
---|---|
private static InstructionComparator |
cmp |
protected short |
length |
protected short |
opcode |
Constructor and Description |
---|
Instruction()
Empty constructor needed for the Class.newInstance() statement in
Instruction.readInstruction().
|
Instruction(short opcode,
short length) |
Modifier and Type | Method and Description |
---|---|
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) |
protected short length
protected short opcode
private static InstructionComparator cmp
Instruction()
public Instruction(short opcode, short length)
public void dump(DataOutputStream out) throws IOException
out
- Output streamIOException
public String getName()
public String toString(boolean verbose)
verbose
- long/short format switchpublic String toString()
public String toString(ConstantPool cp)
public Instruction copy()
BranchInstruction
protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
bytes
- byte sequence to read fromwide
- "wide" instruction flagIOException
public static final Instruction readInstruction(ByteSequence bytes) throws IOException
bytes
- input stream bytesIOException
private static final String className(short opcode)
public int consumeStack(ConstantPoolGen cpg)
public int produceStack(ConstantPoolGen cpg)
public short getOpcode()
public int getLength()
private void setOpcode(short opcode)
void dispose()
public abstract void accept(Visitor v)
v
- Visitor objectpublic static InstructionComparator getComparator()
public static void setComparator(InstructionComparator c)