org.apache.bcel.generic
public class InstructionList extends Object implements Serializable
See Also: Instruction InstructionHandle BranchHandle
Constructor Summary | |
---|---|
InstructionList()
Create (empty) instruction list. | |
InstructionList(Instruction i)
Create instruction list containing one instruction. | |
InstructionList(BranchInstruction i)
Create instruction list containing one instruction. | |
InstructionList(CompoundInstruction c)
Initialize list with (nonnull) compound instruction. | |
InstructionList(byte[] code)
Initialize instruction list from byte array.
|
Method Summary | |
---|---|
void | addObserver(InstructionListObserver o) Add observer for this object. |
InstructionHandle | append(InstructionHandle ih, InstructionList il)
Append another list after instruction (handle) ih contained in this list.
|
InstructionHandle | append(Instruction i, InstructionList il)
Append another list after instruction i contained in this list.
|
InstructionHandle | append(InstructionList il)
Append another list to this one.
|
InstructionHandle | append(Instruction i)
Append an instruction to the end of this list.
|
BranchHandle | append(BranchInstruction i)
Append a branch instruction to the end of this list.
|
InstructionHandle | append(Instruction i, Instruction j)
Append a single instruction j after another instruction i, which
must be in this list of course!
|
InstructionHandle | append(Instruction i, CompoundInstruction c)
Append a compound instruction, after instruction i.
|
InstructionHandle | append(CompoundInstruction c)
Append a compound instruction.
|
InstructionHandle | append(InstructionHandle ih, CompoundInstruction c)
Append a compound instruction.
|
InstructionHandle | append(InstructionHandle ih, Instruction i)
Append an instruction after instruction (handle) ih contained in this list.
|
BranchHandle | append(InstructionHandle ih, BranchInstruction i)
Append an instruction after instruction (handle) ih contained in this list.
|
boolean | contains(InstructionHandle i) |
boolean | contains(Instruction i) |
InstructionList | copy() |
void | delete(InstructionHandle ih)
Remove instruction from this list. |
void | delete(Instruction i)
Remove instruction from this list. |
void | delete(InstructionHandle from, InstructionHandle to)
Remove instructions from instruction `from' to instruction `to' contained
in this list. |
void | delete(Instruction from, Instruction to)
Remove instructions from instruction `from' to instruction `to' contained
in this list. |
void | dispose()
Delete contents of list. |
static InstructionHandle | findHandle(InstructionHandle[] ihs, int[] pos, int count, int target)
Find the target instruction (handle) that corresponds to the given target
position (byte code offset).
|
InstructionHandle | findHandle(int pos)
Get instruction handle for instruction at byte code position pos.
|
byte[] | getByteCode()
When everything is finished, use this method to convert the instruction
list into an array of bytes.
|
InstructionHandle | getEnd() |
InstructionHandle[] | getInstructionHandles() |
int[] | getInstructionPositions()
Get positions (offsets) of all instructions in the list. |
Instruction[] | getInstructions() |
int | getLength() |
InstructionHandle | getStart() |
InstructionHandle | insert(InstructionHandle ih, InstructionList il)
Insert another list before Instruction handle ih contained in this list.
|
InstructionHandle | insert(InstructionList il)
Insert another list.
|
InstructionHandle | insert(Instruction i, InstructionList il)
Insert another list before Instruction i contained in this list.
|
InstructionHandle | insert(Instruction i)
Insert an instruction at start of this list.
|
BranchHandle | insert(BranchInstruction i)
Insert a branch instruction at start of this list.
|
InstructionHandle | insert(Instruction i, Instruction j)
Insert a single instruction j before another instruction i, which
must be in this list of course!
|
InstructionHandle | insert(Instruction i, CompoundInstruction c)
Insert a compound instruction before instruction i.
|
InstructionHandle | insert(CompoundInstruction c)
Insert a compound instruction.
|
InstructionHandle | insert(InstructionHandle ih, Instruction i)
Insert an instruction before instruction (handle) ih contained in this list.
|
InstructionHandle | insert(InstructionHandle ih, CompoundInstruction c)
Insert a compound instruction.
|
BranchHandle | insert(InstructionHandle ih, BranchInstruction i)
Insert an instruction before instruction (handle) ih contained in this list.
|
boolean | isEmpty()
Test for empty list. |
Iterator | iterator() |
void | move(InstructionHandle start, InstructionHandle end, InstructionHandle target)
Take all instructions (handles) from "start" to "end" and append them after the
new location "target". |
void | move(InstructionHandle ih, InstructionHandle target)
Move a single instruction (handle) to a new location.
|
void | redirectBranches(InstructionHandle old_target, InstructionHandle new_target)
Redirect all references from old_target to new_target, i.e., update targets
of branch instructions.
|
void | redirectExceptionHandlers(CodeExceptionGen[] exceptions, InstructionHandle old_target, InstructionHandle new_target)
Redirect all references of exception handlers from old_target to new_target.
|
void | redirectLocalVariables(LocalVariableGen[] lg, InstructionHandle old_target, InstructionHandle new_target)
Redirect all references of local variables from old_target to new_target.
|
void | removeObserver(InstructionListObserver o) Remove observer for this object. |
void | replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp) Replace all references to the old constant pool with references to the new
constant pool |
void | setPositions() |
void | setPositions(boolean check)
Give all instructions their position number (offset in byte stream), i.e.,
make the list ready to be dumped.
|
int | size() |
String | toString() |
String | toString(boolean verbose) |
void | update() Call notify() method on all observers. |
Parameters: i initial instruction
Parameters: i initial instruction
Parameters: c compound instruction (list)
Parameters: code byte array containing the instructions
Parameters: ih where to append the instruction list il Instruction list to append to this one
Returns: instruction handle pointing to the first appended instruction
Parameters: i where to append the instruction list il Instruction list to append to this one
Returns: instruction handle pointing to the first appended instruction
Parameters: il list to append to end of this list
Returns: instruction handle of the first appended instruction
Parameters: i instruction to append
Returns: instruction handle of the appended instruction
Parameters: i branch instruction to append
Returns: branch instruction handle of the appended instruction
Parameters: i Instruction in list j Instruction to append after i in list
Returns: instruction handle of the first appended instruction
Parameters: i Instruction in list c The composite instruction (containing an InstructionList)
Returns: instruction handle of the first appended instruction
Parameters: c The composite instruction (containing an InstructionList)
Returns: instruction handle of the first appended instruction
Parameters: ih where to append the instruction list c The composite instruction (containing an InstructionList)
Returns: instruction handle of the first appended instruction
Parameters: ih where to append the instruction list i Instruction to append
Returns: instruction handle pointing to the first appended instruction
Parameters: ih where to append the instruction list i Instruction to append
Returns: instruction handle pointing to the first appended instruction
Returns: complete, i.e., deep copy of this list
Parameters: ih instruction (handle) to remove
Parameters: i instruction to remove
Parameters: from where to start deleting (inclusive) to where to end deleting (inclusive)
Parameters: from where to start deleting (inclusive) to where to end deleting (inclusive)
Parameters: ihs array of instruction handles, i.e. il.getInstructionHandles() pos array of positions corresponding to ihs, i.e. il.getInstructionPositions() count length of arrays target target position to search for
Returns: target position's instruction handle if available
Parameters: pos byte code position to search for
Returns: target position's instruction handle if available
Returns: the byte code ready to be dumped
Returns: end of list
Returns: array containing all instructions (handles)
Returns: array containing all instruction's offset in byte code
Returns: an array of instructions without target information for branch instructions.
Returns: length of list (Number of instructions, not bytes)
Returns: start of list
Parameters: ih where to append the instruction list il Instruction list to insert
Returns: instruction handle of the first inserted instruction
Parameters: il list to insert before start of this list
Returns: instruction handle of the first inserted instruction
Parameters: i where to append the instruction list il Instruction list to insert
Returns: instruction handle pointing to the first inserted instruction, i.e., il.getStart()
Parameters: i instruction to insert
Returns: instruction handle of the inserted instruction
Parameters: i branch instruction to insert
Returns: branch instruction handle of the appended instruction
Parameters: i Instruction in list j Instruction to insert before i in list
Returns: instruction handle of the first inserted instruction
Parameters: i Instruction in list c The composite instruction (containing an InstructionList)
Returns: instruction handle of the first inserted instruction
Parameters: c The composite instruction (containing an InstructionList)
Returns: instruction handle of the first inserted instruction
Parameters: ih where to insert to the instruction list i Instruction to insert
Returns: instruction handle of the first inserted instruction
Parameters: ih where to insert the instruction list c The composite instruction (containing an InstructionList)
Returns: instruction handle of the first inserted instruction
Parameters: ih where to insert to the instruction list i Instruction to insert
Returns: instruction handle of the first inserted instruction
Returns: Enumeration that lists all instructions (handles)
Parameters: start of moved block end of moved block target of moved block
Parameters: ih moved instruction target new location of moved instruction
Parameters: old_target the old target instruction handle new_target the new target instruction handle
Parameters: exceptions array of exception handlers old_target the old target instruction handle new_target the new target instruction handle
See Also: MethodGen
Parameters: lg array of local variables old_target the old target instruction handle new_target the new target instruction handle
See Also: MethodGen
Parameters: check Perform sanity checks, e.g. if all targeted instructions really belong to this list
Returns: length of list (Number of instructions, not bytes)
Parameters: verbose toggle output format
Returns: String containing all instructions in this list.