All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class espresso.classfile.classgen.InstructionList

java.lang.Object
   |
   +----espresso.classfile.classgen.InstructionList

public final class InstructionList
extends Object
implements Constants
This class is a container for a list of `Instruction's, instructions can be appended, inserted, deleted, etc.. Instructions are being wrapped into InstructionHandle objects that are returned upon append/insert operations. They give the user (read only) access to the list structure, it can be traversed and manipulated in a controlled way. A list is finally dumped to a byte code array with `getByteCode'.

See Also:
Instruction, InstructionHandle

Variable Index

 o end
 o length
 o start

Constructor Index

 o InstructionList()
Create (empty) instruction list.
 o InstructionList(byte[])
Initialize instruction list from byte array.
 o InstructionList(CompoundInstruction)
Initialize list with (nonnull) compound instruction.
 o InstructionList(Instruction)
Initialize list with (nonnull) instruction.

Method Index

 o append(BranchInstruction)
Append a branch instruction to the end of this list.
 o append(CompoundInstruction)
Append a compound instruction.
 o append(Instruction)
Append an instruction to the end of this list.
 o append(Instruction, CompoundInstruction)
Append a compound instruction, after instruction i.
 o append(Instruction, Instruction)
Append a single instruction j after another instruction i, which must be in this list of course!
 o append(Instruction, InstructionList)
Append another list after instruction i contained in this list.
 o append(InstructionHandle)
Append an instruction to the end of this list.
 o append(InstructionHandle, InstructionList)
Append another list after instruction (handle) ih contained in this list.
 o append(InstructionList)
Append another list to this one.
 o copy()
 o delete(Instruction)
Remove instruction from this list.
 o delete(Instruction, Instruction)
Remove instructions from instruction `from' to instruction `to' contained in this list.
 o delete(InstructionHandle)
Remove instruction from this list.
 o delete(InstructionHandle, InstructionHandle)
Remove instructions from instruction `from' to instruction `to' contained in this list.
 o dispose()
Delete contents of list.
 o elements()
 o findInstruction1(Instruction)
Search for given Instruction reference, start at beginning of list.
 o findInstruction2(Instruction)
Search for given Instruction reference, start at end of list
 o findTarget(InstructionHandle[], int[], int, int)
Find the target instruction (handle) that corresponds to the given target position.
 o getByteCode()
 o getEnd()
 o getLength()
 o getStackSize()
Inaccurate, do not use!!
 o getStart()
 o insert(BranchInstruction)
Insert a branch instruction at start of this list.
 o insert(CompoundInstruction)
Insert a compound instruction.
 o insert(Instruction)
Insert an instruction at start of this list.
 o insert(Instruction, CompoundInstruction)
Insert a compound instruction before instruction i.
 o insert(Instruction, Instruction)
Insert a single instruction j before another instruction i, which must be in this list of course!
 o insert(Instruction, InstructionList)
Insert another list before Instruction i contained in this list.
 o insert(InstructionHandle)
Insert an instruction at start of this list.
 o insert(InstructionHandle, InstructionList)
Insert another list before Instruction handle ih contained in this list.
 o insert(InstructionList)
Insert another list.
 o isEmpty()
Test for empty list.
 o remove(InstructionHandle, InstructionHandle)
Remove from instruction `prev' to instruction `next' both contained in this list.
 o setPositions()
Give all instructions their position number (offset in byte stream), i.e.
 o toString()

Variables

 o start
 private InstructionHandle start
 o end
 private InstructionHandle end
 o length
 private int length

Constructors

 o InstructionList
 public InstructionList()
Create (empty) instruction list.

 o InstructionList
 public InstructionList(byte code[])
Initialize instruction list from byte array.

Parameters:
code - byte array containing the instructions
 o InstructionList
 public InstructionList(Instruction i)
Initialize list with (nonnull) instruction.

Parameters:
i - first instruction
 o InstructionList
 public InstructionList(CompoundInstruction c)
Initialize list with (nonnull) compound instruction. Consumes argument list, i.e. it becomes empty.

Parameters:
c - compound instruction (list)

Methods

 o isEmpty
 public final boolean isEmpty()
Test for empty list.

 o findTarget
 private static final InstructionHandle findTarget(InstructionHandle ihs[],
                                                   int pos[],
                                                   int count,
                                                   int target)
Find the target instruction (handle) that corresponds to the given target position.

Parameters:
ihs - array of instruction handles
pos - array of positions corresponding to ihs
count - length of arrays
target - target position to search for
Returns:
target position's instruction handle if available
 o append
 public final InstructionHandle append(Instruction i,
                                       InstructionList il)
Append another list after instruction i contained in this list. Consumes argument list, i.e. it becomes empty.

Parameters:
i - where to append the instruction list
il - Instruction list to append to this one
Returns:
instruction handle pointing to the last appended instruction, i.e. il.getEnd()
 o append
 public final InstructionHandle append(InstructionHandle ih,
                                       InstructionList il)
Append another list after instruction (handle) ih contained in this list. Consumes argument list, i.e. it becomes empty.

Parameters:
ih - where to append the instruction list
il - Instruction list to append to this one
Returns:
instruction handle pointing to the last appended instruction, i.e. il.getEnd()
 o insert
 public final InstructionHandle insert(Instruction i,
                                       InstructionList il)
Insert another list before Instruction i contained in this list. Consumes argument list, i.e. it becomes empty.

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()
 o insert
 public final InstructionHandle insert(InstructionHandle ih,
                                       InstructionList il)
Insert another list before Instruction handle ih contained in this list. Consumes argument list, i.e. it becomes empty.

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()
 o append
 private final void append(InstructionHandle ih)
Append an instruction to the end of this list.

Parameters:
ih - instruction to append
 o append
 public final InstructionHandle append(Instruction i)
Append an instruction to the end of this list.

Parameters:
i - instruction to append
Returns:
instruction handle of the appended instruction
 o append
 public final BranchHandle append(BranchInstruction i)
Append a branch instruction to the end of this list.

Parameters:
i - branch instruction to append
Returns:
branch instruction handle of the appended instruction
 o insert
 private final void insert(InstructionHandle ih)
Insert an instruction at start of this list.

Parameters:
ih - instruction to insert
 o insert
 public final InstructionHandle insert(Instruction i)
Insert an instruction at start of this list.

Parameters:
i - instruction to insert
Returns:
instruction handle of the inserted instruction
 o insert
 public final BranchHandle insert(BranchInstruction i)
Insert a branch instruction at start of this list.

Parameters:
i - branch instruction to insert
Returns:
branch instruction handle of the appended instruction
 o append
 public final InstructionHandle append(InstructionList il)
Append another list to this one.

Parameters:
il - list to append to end of this list
Returns:
instruction handle of the last appended instruction
 o insert
 public final InstructionHandle insert(InstructionList il)
Insert another list.

Parameters:
il - list to insert before start of this list
Returns:
instruction handle of the first inserted instruction
 o append
 public final InstructionHandle append(Instruction i,
                                       Instruction j)
Append a single instruction j after another instruction i, which must be in this list of course!

Parameters:
i - Instruction in list
j - Instruction to append after i in list
Returns:
instruction handle of the last appended instruction
 o insert
 public InstructionHandle insert(Instruction i,
                                 Instruction j)
Insert a single instruction j before another instruction i, which must be in this list of course!

Parameters:
i - Instruction in list
j - Instruction to insert before i in list
Returns:
instruction handle of the first inserted instruction
 o append
 public final InstructionHandle append(Instruction i,
                                       CompoundInstruction c)
Append a compound instruction, after instruction i.

Parameters:
i - Instruction in list
c - The composite instruction (containing an InstructionList)
Returns:
instruction handle of the last appended instruction
 o insert
 public final InstructionHandle insert(Instruction i,
                                       CompoundInstruction c)
Insert a compound instruction before instruction i.

Parameters:
i - Instruction in list
c - The composite instruction (containing an InstructionList)
Returns:
instruction handle of the first inserted instruction
 o append
 public final InstructionHandle append(CompoundInstruction c)
Append a compound instruction.

Parameters:
c - The composite instruction (containing an InstructionList)
Returns:
instruction handle of the last appended instruction
 o insert
 public final InstructionHandle insert(CompoundInstruction c)
Insert a compound instruction.

Parameters:
c - The composite instruction (containing an InstructionList)
Returns:
instruction handle of the first inserted instruction
 o remove
 private final void remove(InstructionHandle prev,
                           InstructionHandle next)
Remove from instruction `prev' to instruction `next' both contained in this list.

Parameters:
prev - where to start deleting (predecessor, exclusive)
next - where to end deleting (successor, exclusive)
 o delete
 public final void delete(InstructionHandle ih)
Remove instruction from this list.

Parameters:
ih - instruction (handle) to remove
 o delete
 public final void delete(Instruction i)
Remove instruction from this list.

Parameters:
i - instruction to remove
 o delete
 public final void delete(InstructionHandle from,
                          InstructionHandle to)
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.

Parameters:
from - where to start deleting (inclusive)
to - where to end deleting (inclusive)
 o delete
 public final void delete(Instruction from,
                          Instruction to)
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.

Parameters:
from - where to start deleting (inclusive)
to - where to end deleting (inclusive)
 o findInstruction1
 private final InstructionHandle findInstruction1(Instruction i)
Search for given Instruction reference, start at beginning of list.

Parameters:
i - instruction to search for
Returns:
instruction found on success, null otherwise
 o findInstruction2
 private final InstructionHandle findInstruction2(Instruction i)
Search for given Instruction reference, start at end of list

Parameters:
i - instruction to search for
Returns:
instruction found on success, null otherwise
 o setPositions
 public final void setPositions()
Give all instructions their position number (offset in byte stream), i.e. make the list ready to be dumped.

 o getByteCode
 public byte[] getByteCode()
Returns:
The byte code!
 o toString
 public String toString()
Returns:
String containing all instructions in this list.
Overrides:
toString in class Object
 o elements
 public Enumeration elements()
Returns:
Enumeration that lists all instructions
 o copy
 public InstructionList copy()
Returns:
complete, i.e. deep copy of this list
 o getStackSize
 private int getStackSize()
Inaccurate, do not use!!

Returns:
maximum stack size
 o dispose
 public final void dispose()
Delete contents of list.

 o getStart
 public InstructionHandle getStart()
Returns:
start of list
 o getEnd
 public InstructionHandle getEnd()
Returns:
end of list
 o getLength
 public int getLength()
Returns:
length of list (Number of instructions, not bytes)

All Packages  Class Hierarchy  This Package  Previous  Next  Index