public abstract class Instruction
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
private static InstructionComparator |
cmp |
protected short |
length
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
protected short |
opcode
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
Constructor and Description |
---|
Instruction()
Empty constructor needed for Instruction.readInstruction.
|
Instruction(short opcode,
short length) |
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(Visitor v)
Call corresponding visitor method(s).
|
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(java.io.DataOutputStream out)
Dump instruction as byte code to stream out.
|
boolean |
equals(java.lang.Object that)
Check for equality, delegated to comparator
|
static InstructionComparator |
getComparator()
Deprecated.
(6.0) use the built in comparator, or wrap this class in another object that implements these methods
|
int |
getLength() |
java.lang.String |
getName() |
short |
getOpcode() |
int |
hashCode()
calculate the hashCode of this object
|
protected void |
initFromFile(ByteSequence bytes,
boolean wide)
Read needed data (e.g.
|
static boolean |
isValidByte(int value)
Check if the value can fit in a byte (signed)
|
static boolean |
isValidShort(int value)
Check if the value can fit in a short (signed)
|
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)
Deprecated.
(6.0) use the built in comparator, or wrap this class in another object that implements these methods
|
(package private) void |
setLength(int length)
Needed in readInstruction and subclasses in this package
|
(package private) void |
setOpcode(short opcode)
Needed in readInstruction and subclasses in this package
|
java.lang.String |
toString() |
java.lang.String |
toString(boolean verbose)
Long output format:
<name of opcode> "["<opcode number>"]"
"("<length of instruction>")"
|
java.lang.String |
toString(ConstantPool cp) |
@Deprecated protected short length
@Deprecated protected short opcode
private static InstructionComparator cmp
Instruction()
public Instruction(short opcode, short length)
public void dump(java.io.DataOutputStream out) throws java.io.IOException
out
- Output streamjava.io.IOException
public java.lang.String getName()
public java.lang.String toString(boolean verbose)
verbose
- long/short format switchpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(ConstantPool cp)
public Instruction copy()
BranchInstruction
protected void initFromFile(ByteSequence bytes, boolean wide) throws java.io.IOException
bytes
- byte sequence to read fromwide
- "wide" instruction flagjava.io.IOException
- may be thrown if the implementation needs to read data from the filepublic static Instruction readInstruction(ByteSequence bytes) throws java.io.IOException
If the Instruction is defined in InstructionConst
, then the
singleton instance is returned.
bytes
- input stream bytesjava.io.IOException
InstructionConst.getInstruction(int)
public int consumeStack(ConstantPoolGen cpg)
public int produceStack(ConstantPoolGen cpg)
public short getOpcode()
public int getLength()
final void setOpcode(short opcode)
final void setLength(int length)
void dispose()
public abstract void accept(Visitor v)
v
- Visitor object@Deprecated public static InstructionComparator getComparator()
@Deprecated public static void setComparator(InstructionComparator c)
public boolean equals(java.lang.Object that)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static boolean isValidByte(int value)
value
- the value to checkpublic static boolean isValidShort(int value)
value
- the value to check