de.fub.bytecode.generic
Class InstructionList

java.lang.Object
|
+--de.fub.bytecode.generic.InstructionList

All Implemented Interfaces:

java.io.Serializable

public class InstructionList

extends java.lang.Object

implements java.io.Serializable

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.

move

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.

delete

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!

Parameters:

from - where to start deleting (inclusive)

to - where to end deleting (inclusive)

delete

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!

getInstructionHandles

getInstructionPositions

public int[] getInstructionPositions()

Get 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.