public class InstructionList extends Object implements Iterable<InstructionHandle>
Instruction,
InstructionHandle,
BranchHandle| Constructor and Description |
|---|
InstructionList()
Create (empty) instruction list.
|
InstructionList(BranchInstruction i)
Create instruction list containing one instruction.
|
InstructionList(byte[] code)
Initialize instruction list from byte array.
|
InstructionList(CompoundInstruction c)
Initialize list with (nonnull) compound instruction.
|
InstructionList(Instruction i)
Create instruction list containing one instruction.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addObserver(InstructionListObserver o)
Add observer for this object.
|
BranchHandle |
append(BranchInstruction i)
Append a branch instruction to the end of this list.
|
InstructionHandle |
append(CompoundInstruction c)
Append a compound instruction.
|
InstructionHandle |
append(Instruction i)
Append an instruction to the end of this list.
|
InstructionHandle |
append(Instruction i,
CompoundInstruction c)
Append a compound instruction, after instruction i.
|
BranchHandle |
append(InstructionHandle ih,
BranchInstruction i)
Append an instruction after instruction (handle) ih contained in this list.
|
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.
|
InstructionHandle |
append(InstructionHandle ih,
InstructionList il)
Append another list after instruction (handle) ih contained in 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,
InstructionList il)
Append another list after instruction i contained in this list.
|
InstructionHandle |
append(InstructionList il)
Append another list to this one.
|
boolean |
contains(Instruction i) |
boolean |
contains(InstructionHandle i) |
InstructionList |
copy() |
void |
delete(Instruction i)
Remove instruction from this list.
|
void |
delete(InstructionHandle ih)
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() |
BranchHandle |
insert(BranchInstruction i)
Insert a branch instruction at start of this list.
|
InstructionHandle |
insert(CompoundInstruction c)
Insert a compound instruction.
|
InstructionHandle |
insert(Instruction i)
Insert an instruction at start of this list.
|
InstructionHandle |
insert(Instruction i,
CompoundInstruction c)
Insert a compound instruction before instruction i.
|
BranchHandle |
insert(InstructionHandle ih,
BranchInstruction i)
Insert an instruction before instruction (handle) ih contained in this list.
|
InstructionHandle |
insert(InstructionHandle ih,
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,
InstructionList il)
Insert another list before Instruction handle ih contained in 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,
InstructionList il)
Insert another list before Instruction i contained in this list.
|
InstructionHandle |
insert(InstructionList il)
Insert another list.
|
boolean |
isEmpty()
Test for empty list.
|
Iterator<InstructionHandle> |
iterator() |
void |
move(InstructionHandle ih,
InstructionHandle target)
Move a single instruction (handle) to a new location.
|
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 |
redirectBranches(InstructionHandle oldTarget,
InstructionHandle newTarget)
Redirect all references from oldTarget to newTarget, i.e., update targets of branch instructions.
|
void |
redirectExceptionHandlers(CodeExceptionGen[] exceptions,
InstructionHandle oldTarget,
InstructionHandle newTarget)
Redirect all references of exception handlers from oldTarget to newTarget.
|
void |
redirectLocalVariables(LocalVariableGen[] lg,
InstructionHandle oldTarget,
InstructionHandle newTarget)
Redirect all references of local variables from oldTarget to newTarget.
|
void |
removeObserver(InstructionListObserver o)
Remove observer for this object.
|
void |
replaceConstantPool(ConstantPoolGen oldCp,
ConstantPoolGen newCp)
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic InstructionList()
public InstructionList(BranchInstruction i)
i - initial instructionpublic InstructionList(byte[] code)
code - byte array containing the instructionspublic InstructionList(CompoundInstruction c)
c - compound instruction (list)public InstructionList(Instruction i)
i - initial instructionpublic static InstructionHandle findHandle(InstructionHandle[] ihs, int[] pos, int count, int target)
ihs - array of instruction handles, i.e. il.getInstructionHandles()pos - array of positions corresponding to ihs, i.e. il.getInstructionPositions()count - length of arraystarget - target position to search forpublic void addObserver(InstructionListObserver o)
public BranchHandle append(BranchInstruction i)
i - branch instruction to appendpublic InstructionHandle append(CompoundInstruction c)
c - The composite instruction (containing an InstructionList)public InstructionHandle append(Instruction i)
i - instruction to appendpublic InstructionHandle append(Instruction i, CompoundInstruction c)
i - Instruction in listc - The composite instruction (containing an InstructionList)public InstructionHandle append(Instruction i, Instruction j)
i - Instruction in listj - Instruction to append after i in listpublic InstructionHandle append(Instruction i, InstructionList il)
i - where to append the instruction listil - Instruction list to append to this onepublic BranchHandle append(InstructionHandle ih, BranchInstruction i)
ih - where to append the instruction listi - Instruction to appendpublic InstructionHandle append(InstructionHandle ih, CompoundInstruction c)
ih - where to append the instruction listc - The composite instruction (containing an InstructionList)public InstructionHandle append(InstructionHandle ih, Instruction i)
ih - where to append the instruction listi - Instruction to appendpublic InstructionHandle append(InstructionHandle ih, InstructionList il)
ih - where to append the instruction listil - Instruction list to append to this onepublic InstructionHandle append(InstructionList il)
il - list to append to end of this listpublic boolean contains(Instruction i)
public boolean contains(InstructionHandle i)
public InstructionList copy()
public void delete(Instruction i) throws TargetLostException
i - instruction to removeTargetLostExceptionpublic void delete(Instruction from, Instruction to) throws TargetLostException
from - where to start deleting (inclusive)to - where to end deleting (inclusive)TargetLostExceptionpublic void delete(InstructionHandle ih) throws TargetLostException
ih - instruction (handle) to removeTargetLostExceptionpublic void delete(InstructionHandle from, InstructionHandle to) throws TargetLostException
from - where to start deleting (inclusive)to - where to end deleting (inclusive)TargetLostExceptionpublic void dispose()
MethodGen.getMethod().public InstructionHandle findHandle(int pos)
pos - byte code position to search forpublic byte[] getByteCode()
public InstructionHandle getEnd()
public InstructionHandle[] getInstructionHandles()
public int[] getInstructionPositions()
public Instruction[] getInstructions()
public int getLength()
public InstructionHandle getStart()
public BranchHandle insert(BranchInstruction i)
i - branch instruction to insertpublic InstructionHandle insert(CompoundInstruction c)
c - The composite instruction (containing an InstructionList)public InstructionHandle insert(Instruction i)
i - instruction to insertpublic InstructionHandle insert(Instruction i, CompoundInstruction c)
i - Instruction in listc - The composite instruction (containing an InstructionList)public InstructionHandle insert(Instruction i, Instruction j)
i - Instruction in listj - Instruction to insert before i in listpublic InstructionHandle insert(Instruction i, InstructionList il)
i - where to append the instruction listil - Instruction list to insertpublic BranchHandle insert(InstructionHandle ih, BranchInstruction i)
ih - where to insert to the instruction listi - Instruction to insertpublic InstructionHandle insert(InstructionHandle ih, CompoundInstruction c)
ih - where to insert the instruction listc - The composite instruction (containing an InstructionList)public InstructionHandle insert(InstructionHandle ih, Instruction i)
ih - where to insert to the instruction listi - Instruction to insertpublic InstructionHandle insert(InstructionHandle ih, InstructionList il)
ih - where to append the instruction listil - Instruction list to insertpublic InstructionHandle insert(InstructionList il)
il - list to insert before start of this listpublic boolean isEmpty()
public Iterator<InstructionHandle> iterator()
iterator in interface Iterable<InstructionHandle>public void move(InstructionHandle ih, InstructionHandle target)
ih - moved instructiontarget - new location of moved instructionpublic void move(InstructionHandle start, InstructionHandle end, InstructionHandle target)
Any instruction targeters pointing to handles within the block, keep their targets.
start - of moved blockend - of moved blocktarget - of moved blockpublic void redirectBranches(InstructionHandle oldTarget, InstructionHandle newTarget)
oldTarget - the old target instruction handlenewTarget - the new target instruction handlepublic void redirectExceptionHandlers(CodeExceptionGen[] exceptions, InstructionHandle oldTarget, InstructionHandle newTarget)
exceptions - array of exception handlersoldTarget - the old target instruction handlenewTarget - the new target instruction handleMethodGenpublic void redirectLocalVariables(LocalVariableGen[] lg, InstructionHandle oldTarget, InstructionHandle newTarget)
lg - array of local variablesoldTarget - the old target instruction handlenewTarget - the new target instruction handleMethodGenpublic void removeObserver(InstructionListObserver o)
public void replaceConstantPool(ConstantPoolGen oldCp, ConstantPoolGen newCp)
public void setPositions()
public void setPositions(boolean check)
check - Perform sanity checks, e.g. if all targeted instructions really belong to this listpublic int size()
public String toString(boolean verbose)
verbose - toggle output formatpublic void update()
Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.