Instruction, InstructionHandle, BranchHandle
| Modifier and Type | Field and Description |
|---|---|
| private int[] | |
| private InstructionHandle | |
| private int | |
| private List | |
| private InstructionHandle |
| Access | Constructor and Description |
|---|---|
| public | |
| public | InstructionList(final BranchInstruction
initial instruction i)Create instruction list containing one instruction. |
| public | InstructionList(final byte[]
byte array containing the instructions code)Initialize instruction list from byte array. |
| public | InstructionList(final CompoundInstruction
compound instruction (list) c)Initialize list with (nonnull) compound instruction. |
| public | InstructionList(final Instruction
initial instruction i)Create instruction list containing one instruction. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public BranchHandle | Returns: branch instruction handle of the appended instructionbranch instruction to append i)Append a branch instruction to the end of this list. |
| public InstructionHandle | Returns: instruction handle of the first appended instructionThe composite instruction (containing an InstructionList) c)Append a compound instruction. |
| public InstructionHandle | Returns: instruction handle of the appended instructioninstruction to append i)Append an instruction to the end of this list. |
| public InstructionHandle | Returns: instruction handle of the first appended instructionInstruction in list i, final CompoundInstruction The composite instruction (containing an InstructionList) c)Append a compound instruction, after instruction i. |
| public InstructionHandle | Returns: instruction handle of the first appended instructionInstruction in list i, final Instruction Instruction to append after i in list j)Append a single instruction j after another instruction i, which must be in this list of course! |
| public InstructionHandle | Returns: instruction handle pointing to the first appended instructionwhere to append the instruction list i, final InstructionList Instruction list to append to this one il)Append another list after instruction i contained in this list. |
| private void | append(final InstructionHandle
instruction to append ih)Append an instruction to the end of this list. |
| public BranchHandle | Returns: instruction handle pointing to the first appended instructionwhere to append the instruction list ih, final BranchInstruction Instruction to append i)Append an instruction after instruction (handle) ih contained in this list. |
| public InstructionHandle | Returns: instruction handle of the first appended instructionwhere to append the instruction list ih, final CompoundInstruction The composite instruction (containing an InstructionList) c)Append a compound instruction. |
| public InstructionHandle | Returns: instruction handle pointing to the first appended instructionwhere to append the instruction list ih, final Instruction Instruction to append i)Append an instruction after instruction (handle) ih contained in this list. |
| public InstructionHandle | Returns: instruction handle pointing to the first appended instructionwhere to append the instruction list ih, final InstructionList Instruction list to append to this one il)Append another list after instruction (handle) ih contained in this list. |
| public InstructionHandle | Returns: instruction handle of the first appended instructionlist to append to end of this list il)Append another list to this one. |
| private void | |
| public boolean | |
| public boolean | |
| public InstructionList | |
| public void | |
| public void | delete(final Instruction
where to start deleting (inclusive) from, final Instruction where to end deleting (inclusive) to)Remove instructions from instruction 'from' to instruction 'to' contained in this list. |
| public void | |
| public void | delete(final InstructionHandle
where to start deleting (inclusive) from, final InstructionHandle where to end deleting (inclusive) to)Remove instructions from instruction 'from' to instruction 'to' contained in this list. |
| public void | |
| public static InstructionHandle | Returns: target position's instruction handle if availablearray of instruction handles, i.e. il.getInstructionHandles() ihs, final int[] array of positions corresponding to ihs, i.e. il.getInstructionPositions() pos, final int length of arrays count, final int target position to search for target)Find the target instruction (handle) that corresponds to the given target position (byte code offset). |
| public InstructionHandle | Returns: target position's instruction handle if availablebyte code position to search for pos)Gets instruction handle for instruction at byte code position pos. |
| private InstructionHandle | Returns: instruction found on success, null otherwiseinstruction to search for i)Search for given Instruction reference, start at beginning of list. |
| private InstructionHandle | Returns: instruction found on success, null otherwiseinstruction to search for i)Search for given Instruction reference, start at end of list |
| public byte[] | Returns: the byte code ready to be dumpedWhen everything is finished, use this method to convert the instruction list into an array of bytes. |
| public InstructionHandle | |
| public InstructionHandle[] | |
| public int[] | Returns: array containing all instruction's offset in byte codeGets positions (offsets) of all instructions in the list. |
| public Instruction[] | getInstructions()
Returns: an array of instructions without target information for branch instructions. |
| public int | |
| public InstructionHandle | |
| public BranchHandle | Returns: branch instruction handle of the appended instructionbranch instruction to insert i)Insert a branch instruction at start of this list. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionThe composite instruction (containing an InstructionList) c)Insert a compound instruction. |
| public InstructionHandle | Returns: instruction handle of the inserted instructioninstruction to insert i)Insert an instruction at start of this list. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionInstruction in list i, final CompoundInstruction The composite instruction (containing an InstructionList) c)Insert a compound instruction before instruction i. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionInstruction in list i, final Instruction Instruction to insert before i in list j)Insert a single instruction j before another instruction i, which must be in this list of course! |
| public InstructionHandle | Returns: instruction handle pointing to the first inserted instruction, i.e., il.getStart()where to append the instruction list i, final InstructionList Instruction list to insert il)Insert another list before Instruction i contained in this list. |
| private void | |
| public BranchHandle | Returns: instruction handle of the first inserted instructionwhere to insert to the instruction list ih, final BranchInstruction Instruction to insert i)Insert an instruction before instruction (handle) ih contained in this list. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionwhere to insert the instruction list ih, final CompoundInstruction The composite instruction (containing an InstructionList) c)Insert a compound instruction. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionwhere to insert to the instruction list ih, final Instruction Instruction to insert i)Insert an instruction before instruction (handle) ih contained in this list. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionwhere to append the instruction list ih, final InstructionList Instruction list to insert il)Insert another list before Instruction handle ih contained in this list. |
| public InstructionHandle | Returns: instruction handle of the first inserted instructionlist to insert before start of this list il)Insert another list. |
| public boolean | |
| public Iterator | Returns: iterator that lists all instructions (handles)Implements java. Returns an iterator over elements of type |
| public void | move(final InstructionHandle
moved instruction ih, final InstructionHandle new location of moved instruction target)Move a single instruction (handle) to a new location. |
| public void | move(final InstructionHandle
of moved block start, final InstructionHandle of moved block end, final InstructionHandle of moved block target)Take all instructions (handles) from "start" to "end" and append them after the new location "target". |
| public void | redirectBranches(final InstructionHandle
the old target instruction handle oldTarget, final InstructionHandle the new target instruction handle newTarget)Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions. |
| public void | redirectExceptionHandlers(final CodeExceptionGen[]
array of exception handlers exceptions, final InstructionHandle the old target instruction handle oldTarget, final InstructionHandle the new target instruction handle newTarget)Redirect all references of exception handlers from oldTarget to newTarget. |
| public void | redirectLocalVariables(final LocalVariableGen[]
array of local variables lg, final InstructionHandle the old target instruction handle oldTarget, final InstructionHandle the new target instruction handle newTarget)Redirect all references of local variables from oldTarget to newTarget. |
| private void | remove(final InstructionHandle
where to start deleting (predecessor, exclusive) prev, InstructionHandle where to end deleting (successor, exclusive) next)Remove from instruction 'prev' to instruction 'next' both contained in this list. |
| public void | |
| public void | replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp)
Replace all references to the old constant pool with references to the new constant pool |
| public void | |
| public void | setPositions(final boolean
Perform sanity checks, e.g. if all targeted instructions really belong to this list check)Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped. |
| public int | |
| public String | |
| public String | toString(final boolean
toggle output format verbose)Returns: String containing all instructions in this list. |
| public void |
| bytePositions | back to summary |
|---|---|
| private int[] bytePositions | |
| end | back to summary |
|---|---|
| private InstructionHandle end | |
| length | back to summary |
|---|---|
| private int length | |
| observers | back to summary |
|---|---|
| private List<InstructionListObserver> observers | |
| start | back to summary |
|---|---|
| private InstructionHandle start | |
| InstructionList | back to summary |
|---|---|
| public InstructionList() Create (empty) instruction list. | |
| InstructionList | back to summary |
|---|---|
| public InstructionList(final BranchInstruction i) Create instruction list containing one instruction.
| |
| InstructionList | back to summary |
|---|---|
| public InstructionList(final byte[] code) Initialize instruction list from byte array.
| |
| InstructionList | back to summary |
|---|---|
| public InstructionList(final CompoundInstruction c) Initialize list with (nonnull) compound instruction. Consumes argument list, i.e., it becomes empty.
| |
| InstructionList | back to summary |
|---|---|
| public InstructionList(final Instruction i) Create instruction list containing one instruction.
| |
| addObserver | back to summary |
|---|---|
| public void addObserver(final InstructionListObserver o) Add observer for this object. | |
| append | back to summary |
|---|---|
| public BranchHandle append(final BranchInstruction i) Append a branch instruction to the end of this list.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final CompoundInstruction c) Append a compound instruction.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final Instruction i) Append an instruction to the end of this list.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final Instruction i, final CompoundInstruction c) Append a compound instruction, after instruction i.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final Instruction i, final Instruction j) Append a single instruction j after another instruction i, which must be in this list of course!
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final Instruction i, final InstructionList il) Append another list after instruction i contained in this list. Consumes argument list, i.e., it becomes empty.
| |
| append | back to summary |
|---|---|
| private void append(final InstructionHandle ih) Append an instruction to the end of this list.
| |
| append | back to summary |
|---|---|
| public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) Append an instruction after instruction (handle) ih contained in this list.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final InstructionHandle ih, final CompoundInstruction c) Append a compound instruction.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final InstructionHandle ih, final Instruction i) Append an instruction after instruction (handle) ih contained in this list.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final InstructionHandle ih, final InstructionList il) Append another list after instruction (handle) ih contained in this list. Consumes argument list, i.e., it becomes empty.
| |
| append | back to summary |
|---|---|
| public InstructionHandle append(final InstructionList il) Append another list to this one. Consumes argument list, i.e., it becomes empty.
| |
| clear | back to summary |
|---|---|
| private void clear() | |
| contains | back to summary |
|---|---|
| public boolean contains(final Instruction i) | |
| contains | back to summary |
|---|---|
| public boolean contains(final InstructionHandle i) | |
| copy | back to summary |
|---|---|
public InstructionList copy()
| |
| delete | back to summary |
|---|---|
| public void delete(final Instruction i) throws TargetLostException Remove instruction from this list. The corresponding Instruction handles must not be reused!
| |
| delete | back to summary |
|---|---|
| public void delete(final Instruction from, final Instruction to) throws TargetLostException Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused!
| |
| delete | back to summary |
|---|---|
| public void delete(final InstructionHandle ih) throws TargetLostException Remove instruction from this list. The corresponding Instruction handles must not be reused!
| |
| delete | back to summary |
|---|---|
| public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException Remove instructions from instruction 'from' to instruction 'to' contained in this list. The user must ensure that 'from' is an instruction before 'to', or risk havoc. The corresponding Instruction handles must not be reused!
| |
| dispose | back to summary |
|---|---|
| public void dispose() Delete contents of list. Provides better memory utilization, because the system then may reuse the instruction
handles. This method is typically called right after | |
| findHandle | back to summary |
|---|---|
| public static InstructionHandle findHandle(final InstructionHandle[] ihs, final int[] pos, final int count, final int target) Find the target instruction (handle) that corresponds to the given target position (byte code offset).
| |
| findHandle | back to summary |
|---|---|
| public InstructionHandle findHandle(final int pos) Gets instruction handle for instruction at byte code position pos. This only works properly, if the list is freshly initialized from a byte array or setPositions() has been called before this method.
| |
| findInstruction1 | back to summary |
|---|---|
| private InstructionHandle findInstruction1(final Instruction i) Search for given Instruction reference, start at beginning of list.
| |
| findInstruction2 | back to summary |
|---|---|
| private InstructionHandle findInstruction2(final Instruction i) Search for given Instruction reference, start at end of list
| |
| getByteCode | back to summary |
|---|---|
| public byte[] getByteCode() When everything is finished, use this method to convert the instruction list into an array of bytes.
| |
| getEnd | back to summary |
|---|---|
public InstructionHandle getEnd()
| |
| getInstructionHandles | back to summary |
|---|---|
public InstructionHandle[] getInstructionHandles()
| |
| getInstructionPositions | back to summary |
|---|---|
| public int[] getInstructionPositions() Gets positions (offsets) of all instructions in the list. This relies on that the list has been freshly created from an byte code array, or that setPositions() has been called. Otherwise this may be inaccurate.
| |
| getInstructions | back to summary |
|---|---|
public Instruction[] getInstructions()
| |
| getLength | back to summary |
|---|---|
public int getLength()
| |
| getStart | back to summary |
|---|---|
public InstructionHandle getStart()
| |
| insert | back to summary |
|---|---|
| public BranchHandle insert(final BranchInstruction i) Insert a branch instruction at start of this list.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final CompoundInstruction c) Insert a compound instruction.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final Instruction i) Insert an instruction at start of this list.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final Instruction i, final CompoundInstruction c) Insert a compound instruction before instruction i.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final Instruction i, final Instruction j) Insert a single instruction j before another instruction i, which must be in this list of course!
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final Instruction i, final InstructionList il) Insert another list before Instruction i contained in this list. Consumes argument list, i.e., it becomes empty.
| |
| insert | back to summary |
|---|---|
| private void insert(final InstructionHandle ih) Insert an instruction at start of this list.
| |
| insert | back to summary |
|---|---|
| public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i) Insert an instruction before instruction (handle) ih contained in this list.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c) Insert a compound instruction.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final InstructionHandle ih, final Instruction i) Insert an instruction before instruction (handle) ih contained in this list.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) Insert another list before Instruction handle ih contained in this list. Consumes argument list, i.e., it becomes empty.
| |
| insert | back to summary |
|---|---|
| public InstructionHandle insert(final InstructionList il) Insert another list.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Test for empty list. | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type
| |
| move | back to summary |
|---|---|
| public void move(final InstructionHandle ih, final InstructionHandle target) Move a single instruction (handle) to a new location.
| |
| move | back to summary |
|---|---|
| public void move(final InstructionHandle start, final InstructionHandle end, final InstructionHandle target) Take all instructions (handles) from "start" to "end" and append them after the new location "target". Of course, "end" must be after "start" and target must not be located withing this range. If you want to move something to the start of the list use null as value for target. Any instruction targeters pointing to handles within the block, keep their targets.
| |
| redirectBranches | back to summary |
|---|---|
| public void redirectBranches(final InstructionHandle oldTarget, final InstructionHandle newTarget) Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions.
| |
| redirectExceptionHandlers | back to summary |
|---|---|
| public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle oldTarget, final InstructionHandle newTarget) Redirect all references of exception handlers from oldTarget to newTarget.
| |
| redirectLocalVariables | back to summary |
|---|---|
| public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle oldTarget, final InstructionHandle newTarget) Redirect all references of local variables from oldTarget to newTarget.
| |
| remove | back to summary |
|---|---|
| private void remove(final InstructionHandle prev, InstructionHandle next) throws TargetLostException Remove from instruction 'prev' to instruction 'next' both contained in this list. Throws TargetLostException when one of the removed instruction handles is still being targeted.
| |
| removeObserver | back to summary |
|---|---|
| public void removeObserver(final InstructionListObserver o) Remove observer for this object. | |
| replaceConstantPool | back to summary |
|---|---|
| public void replaceConstantPool(final ConstantPoolGen oldCp, final ConstantPoolGen newCp) Replace all references to the old constant pool with references to the new constant pool | |
| setPositions | back to summary |
|---|---|
| public void setPositions() | |
| setPositions | back to summary |
|---|---|
| public void setPositions(final boolean check) Give all instructions their position number (offset in byte stream), i.e., make the list ready to be dumped.
| |
| size | back to summary |
|---|---|
public int size()
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| toString | back to summary |
|---|---|
public String toString(final boolean verbose)
| |
| update | back to summary |
|---|---|
| public void update() Call notify() method on all observers. This method is not called automatically whenever the state has changed, but has to be called by the user after he has finished editing the object. | |