|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jode.bytecode.Instruction
This class represents an instruction in the byte code.
Instructions can be created with the static forOpcode(int)
methods.
We only allow a subset of opcodes. Other opcodes are mapped to their simpler version. Don't worry about this, when writing the bytecode the shortest possible bytecode is produced.
The opcodes we map are:[iflda]load_x -> [iflda]load [iflda]store_x -> [iflda]store [ifa]const_xx, ldc_w -> ldc [dl]const_xx -> ldc2_w wide opcode -> opcode tableswitch -> lookupswitch [a]newarray -> multianewarray
Field Summary |
Method Summary | |
boolean |
doesAlwaysJump()
Checks whether this instruction always changes program flow. |
static Instruction |
forOpcode(int opcode)
Creates a new simple Instruction with no parameters. |
static Instruction |
forOpcode(int opcode,
int[] values)
Creates a new switch Instruction. |
static Instruction |
forOpcode(int opcode,
LocalVariableInfo lvi)
Creates a new Instruction with a local variable as parameter. |
static Instruction |
forOpcode(int opcode,
LocalVariableInfo lvi,
int increment)
Creates a new increment Instruction. |
static Instruction |
forOpcode(int opcode,
java.lang.Object constant)
Creates a new ldc Instruction. |
static Instruction |
forOpcode(int opcode,
Reference reference)
Creates a new Instruction with reference as parameter. |
static Instruction |
forOpcode(int opcode,
java.lang.String typeSig)
Creates a new Instruction with type signature as parameter. |
static Instruction |
forOpcode(int opcode,
java.lang.String typeSig,
int dimension)
Creates a new Instruction with type signature and a dimension as parameter. |
java.lang.String |
getClazzType()
Gets the class type this instruction uses, e.g if its a class cast. |
java.lang.Object |
getConstant()
Gets the constant for a opc_ldc or opc_ldc2_w opcode. |
java.lang.String |
getDescription()
Gets a printable representation of the opcode with its parameters. |
int |
getDimensions()
Gets the dimensions for an opc_multianewarray opcode. |
int |
getIncrement()
Gets the increment for an opc_iinc instruction. |
int |
getLineNr()
Gets the line number of this instruction. |
LocalVariableInfo |
getLocalInfo()
Gets the information of the local this instruction accesses. |
int |
getLocalSlot()
Gets the slot number of the local this instruction accesses. |
int |
getOpcode()
Gets the opcode of the instruction. |
Reference |
getReference()
Gets the reference of the field or method this instruction accesses. |
void |
getStackPopPush(int[] poppush)
This returns the number of stack entries this instruction pushes and pops from the stack. |
int[] |
getValues()
Gets the values of a opc_lookupswitch opcode. |
boolean |
hasLineNr()
Tells whether there is a line number information for this instruction. |
boolean |
hasLocal()
Checks whether this instruction accesses a local slot. |
boolean |
isStore()
Checks whether this instruction is a local store instruction, i.e. |
void |
setClazzType(java.lang.String type)
Sets the class type this instruction uses, e.g if its a class cast. |
void |
setConstant(java.lang.Object constant)
Sets the constant for a opc_ldc or opc_ldc2_w opcode. |
void |
setDimensions(int dims)
Sets the dimensions for an opc_multianewarray opcode. |
void |
setIncrement(int incr)
Sets the increment for an opc_iinc instruction. |
void |
setLineNr(int nr)
Sets the line number of this instruction. |
void |
setLocalInfo(LocalVariableInfo info)
Sets the information of the local this instruction accesses. |
void |
setLocalSlot(int slot)
Sets the slot of the local this instruction accesses. |
void |
setReference(Reference ref)
Sets the reference of the field or method this instruction accesses. |
void |
setValues(int[] values)
Sets the values of a opc_lookupswitch opcode. |
java.lang.String |
toString()
Gets a printable representation of the opcode with its parameters. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public static Instruction forOpcode(int opcode)
opcode
- the opcode of this instruction.
java.lang.IllegalArgumentException
- if opcode is not in our subset
or if opcode needs a parameter.public static Instruction forOpcode(int opcode, java.lang.Object constant)
opcode
- the opcode of this instruction.constant
- the constant parameter.
java.lang.IllegalArgumentException
- if opcode is not opc_ldc or
opc_ldc2_w.public static Instruction forOpcode(int opcode, LocalVariableInfo lvi)
opcode
- the opcode of this instruction.lvi
- the local variable parameter.
java.lang.IllegalArgumentException
- if opcode is not in our subset
or if opcode doesn't need a single local variable as parameter.public static Instruction forOpcode(int opcode, Reference reference)
opcode
- the opcode of this instruction.reference
- the reference parameter.
java.lang.IllegalArgumentException
- if opcode is not in our subset
or if opcode doesn't need a reference as parameter.public static Instruction forOpcode(int opcode, java.lang.String typeSig)
opcode
- the opcode of this instruction.typeSig
- the type signature parameter.
java.lang.IllegalArgumentException
- if opcode is not in our subset
or if opcode doesn't need a type signature as parameter.public static Instruction forOpcode(int opcode, int[] values)
opcode
- the opcode of this instruction must be opc_lookupswitch.values
- an array containing the different cases.
java.lang.IllegalArgumentException
- if opcode is not opc_lookupswitch.public static Instruction forOpcode(int opcode, LocalVariableInfo lvi, int increment)
opcode
- the opcode of this instruction.lvi
- the local variable parameter.increment
- the increment parameter.
java.lang.IllegalArgumentException
- if opcode is not opc_iinc.public static Instruction forOpcode(int opcode, java.lang.String typeSig, int dimension)
opcode
- the opcode of this instruction.typeSig
- the type signature parameter.dimension
- the array dimension parameter.
java.lang.IllegalArgumentException
- if opcode is not
opc_multianewarray.public final int getOpcode()
public final boolean hasLineNr()
public final int getLineNr()
public final void setLineNr(int nr)
nr
- the line number; use -1 to clear it.public boolean isStore()
astore
, istore
, lstore
,
fstore
or dstore
.
public boolean hasLocal()
public int getLocalSlot()
java.lang.IllegalArgumentException
- if this instruction doesn't
access a local slot.public LocalVariableInfo getLocalInfo()
java.lang.IllegalArgumentException
- if this instruction doesn't
access a local.public void setLocalInfo(LocalVariableInfo info)
info
- the local variable info.
java.lang.IllegalArgumentException
- if this instruction doesn't
access a local.public void setLocalSlot(int slot)
slot
- the local slot
java.lang.IllegalArgumentException
- if this instruction doesn't
access a local.public int getIncrement()
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public void setIncrement(int incr)
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public int getDimensions()
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public void setDimensions(int dims)
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public java.lang.Object getConstant()
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public void setConstant(java.lang.Object constant)
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public Reference getReference()
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public void setReference(Reference ref)
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public java.lang.String getClazzType()
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public void setClazzType(java.lang.String type)
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public int[] getValues()
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public void setValues(int[] values)
java.lang.IllegalArgumentException
- if this instruction doesn't
support this.public final boolean doesAlwaysJump()
public void getStackPopPush(int[] poppush)
poppush
- an array of two ints. The first element will
get the number of pops, the second the number of pushes.public final java.lang.String getDescription()
public java.lang.String toString()
|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |