|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.fub.bytecode.generic.InstructionList
This class is a container for a list of Instruction objects. Instructions can be appended, inserted, moved, deleted, etc.. Instructions are being wrapped into InstructionHandles objects that are returned upon append/insert operations. They give the user (read only) access to the list structure, such that it can be traversed and manipulated in a controlled way. A list is finally dumped to a byte code array with getByteCode.
Instruction
,
InstructionHandle
,
BranchHandle
, Serialized FormConstructor Summary | |
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. |
Method Summary | |
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. |
java.util.Enumeration |
elements()
|
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. |
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 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()
|
java.lang.String |
toString()
|
java.lang.String |
toString(boolean verbose)
|
void |
update()
Call notify() method on all observers. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public InstructionList()
public InstructionList(Instruction i)
i
- initial instructionpublic InstructionList(BranchInstruction i)
i
- initial instructionpublic InstructionList(CompoundInstruction c)
c
- compound instruction (list)public InstructionList(byte[] code)
code
- byte array containing the instructionsMethod Detail |
public boolean isEmpty()
public 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 InstructionHandle findHandle(int pos)
pos
- byte code position to search forpublic InstructionHandle append(InstructionHandle ih, InstructionList il)
ih
- where to append the instruction listil
- Instruction list to append to this onepublic InstructionHandle append(Instruction i, InstructionList il)
i
- 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 InstructionHandle append(Instruction i)
i
- instruction to appendpublic BranchHandle append(BranchInstruction i)
i
- branch instruction to appendpublic InstructionHandle append(Instruction i, Instruction j)
i
- Instruction in listj
- Instruction to append after i in listpublic InstructionHandle append(Instruction i, CompoundInstruction c)
i
- Instruction in listc
- The composite instruction (containing an InstructionList)public InstructionHandle append(CompoundInstruction c)
c
- The composite instruction (containing an InstructionList)public 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 BranchHandle append(InstructionHandle ih, BranchInstruction i)
ih
- where to append the instruction listi
- Instruction to appendpublic InstructionHandle insert(InstructionHandle ih, InstructionList il)
i
- where to append the instruction listil
- Instruction list to insertpublic InstructionHandle insert(InstructionList il)
il
- list to insert before start of this listpublic InstructionHandle insert(Instruction i, InstructionList il)
i
- where to append the instruction listil
- Instruction list to insertpublic InstructionHandle insert(Instruction i)
i
- instruction to insertpublic BranchHandle insert(BranchInstruction i)
i
- branch instruction to insertpublic InstructionHandle insert(Instruction i, Instruction j)
i
- Instruction in listj
- Instruction to insert before i in listpublic InstructionHandle insert(Instruction i, CompoundInstruction c)
i
- Instruction in listc
- The composite instruction (containing an InstructionList)public InstructionHandle insert(CompoundInstruction c)
c
- 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, CompoundInstruction c)
ih
- where to insert the instruction listc
- The composite instruction (containing an InstructionList)public BranchHandle insert(InstructionHandle ih, BranchInstruction i)
ih
- where to insert to the instruction listi
- Instruction to insertpublic void move(InstructionHandle start, InstructionHandle end, InstructionHandle target)
start
- of moved blockend
- of moved blocktarget
- of moved blockpublic void move(InstructionHandle ih, InstructionHandle target)
ih
- moved instructiontarget
- new location of moved instructionpublic void delete(InstructionHandle ih) throws TargetLostException
ih
- instruction (handle) to removepublic void delete(Instruction i) throws TargetLostException
i
- instruction to removepublic void delete(InstructionHandle from, InstructionHandle to) throws TargetLostException
from
- where to start deleting (inclusive)to
- where to end deleting (inclusive)public void delete(Instruction from, Instruction to) throws TargetLostException
from
- where to start deleting (inclusive)to
- where to end deleting (inclusive)public boolean contains(InstructionHandle i)
public boolean contains(Instruction i)
public void setPositions()
public void setPositions(boolean check)
check
- Perform sanity checks, e.g. if all targeted instructions really belong
to this listpublic byte[] getByteCode()
public Instruction[] getInstructions()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(boolean verbose)
verbose
- toggle output formatpublic java.util.Enumeration elements()
public InstructionHandle[] getInstructionHandles()
public int[] getInstructionPositions()
public InstructionList copy()
public void replaceConstantPool(ConstantPoolGen old_cp, ConstantPoolGen new_cp)
public void dispose()
public InstructionHandle getStart()
public InstructionHandle getEnd()
public int getLength()
public int size()
public void redirectBranches(InstructionHandle old_target, InstructionHandle new_target)
old_target
- the old target instruction handlenew_target
- the new target instruction handlepublic void redirectLocalVariables(LocalVariableGen[] lg, InstructionHandle old_target, InstructionHandle new_target)
public void redirectExceptionHandlers(CodeExceptionGen[] exceptions, InstructionHandle old_target, InstructionHandle new_target)
public void addObserver(InstructionListObserver o)
public void removeObserver(InstructionListObserver o)
public void update()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |