All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class de.fub.bytecode.generic.InstructionHandle

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

public class InstructionHandle
extends Object
implements Serializable
Instances of this class give users a handle to the instructions contained in an InstructionList. Instruction objects may be uesd more than once within a list, this is useful because it saves memory and may be much faster. Within an InstructionList an InstructionHandle object is wrapped around all instructions, i.e. it implements a cell in a doubly-linked list. From the outside only the next and the previous instruction (handle) are accessible. One can traverse the list via an Enumeration returned by InstructionList.elements().

Version:
$Id: InstructionHandle.java,v 1.10 1999/11/24 10:35:44 dahm Exp $
Author:
M. Dahm
See Also:
Instruction, BranchHandle, InstructionList

Variable Index

 o i_position

Constructor Index

 o InstructionHandle(Instruction)

Method Index

 o addAttribute(Object, Object)
Add an attribute to an instruction handle.
 o addHandle()
Overridden in BranchHandle
 o addTargeter(InstructionTargeter)
Denote this handle is being referenced by t.
 o getAttribute(Object)
Get attribute of an instruction handle.
 o getInstruction()
 o getNext()
 o getPosition()
 o getPrev()
 o getTargeters()
 o hasTargeters()
 o removeAllTargeters()
Remove all targeters, if any.
 o removeAttribute(Object)
Delete an attribute of an instruction handle.
 o removeTargeter(InstructionTargeter)
Denote this handle isn't referenced anymore by t.
 o setInstruction(Instruction)
Replace current instruction contained in this handle.
 o toString()
 o toString(boolean)
 o updatePosition(int, int)
Called by InstructionList.setPositions when setting the position for every instruction.

Variables

 o i_position
 protected int i_position

Constructors

 o InstructionHandle
 protected InstructionHandle(Instruction i)

Methods

 o getNext
 public final InstructionHandle getNext()
 o getPrev
 public final InstructionHandle getPrev()
 o getInstruction
 public final Instruction getInstruction()
 o setInstruction
 public void setInstruction(Instruction i)
Replace current instruction contained in this handle. Old instruction is disposed using Instruction.dispose().

 o updatePosition
 protected int updatePosition(int offset,
                              int max_offset)
Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable length instructions `setPositions()' performs multiple passes over the instruction list to calculate the correct (byte) positions and offsets by calling this function.

Parameters:
offset - additional offset caused by preceding (variable length) instructions
max_offset - the maximum offset that may be caused by these instructions
Returns:
additional offset caused by possible change of this instruction's length
 o getPosition
 public int getPosition()
Returns:
the position, i.e. the byte code offset of the contained instruction. This is accurate only after InstructionList.setPositions() has been called.
 o addHandle
 protected void addHandle()
Overridden in BranchHandle

 o removeAllTargeters
 public void removeAllTargeters()
Remove all targeters, if any.

 o removeTargeter
 public void removeTargeter(InstructionTargeter t)
Denote this handle isn't referenced anymore by t.

 o addTargeter
 public void addTargeter(InstructionTargeter t)
Denote this handle is being referenced by t.

 o hasTargeters
 public boolean hasTargeters()
 o getTargeters
 public InstructionTargeter[] getTargeters()
Returns:
null, if there are no targeters
 o toString
 public String toString(boolean verbose)
 o toString
 public String toString()
Overrides:
toString in class Object
 o addAttribute
 public void addAttribute(Object key,
                          Object attr)
Add an attribute to an instruction handle.

Parameters:
key - the key object to store/retrieve the attribute
attr - the attribute to associate with this handle
 o removeAttribute
 public void removeAttribute(Object key)
Delete an attribute of an instruction handle.

Parameters:
key - the key object to retrieve the attribute
 o getAttribute
 public Object getAttribute(Object key)
Get attribute of an instruction handle.

Parameters:
key - the key object to store/retrieve the attribute

All Packages  Class Hierarchy  This Package  Previous  Next  Index