Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.bcel.generic
Class InstructionHandle  view InstructionHandle download InstructionHandle.java

java.lang.Object
  extended byorg.apache.bcel.generic.InstructionHandle
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BranchHandle

public class InstructionHandle
extends java.lang.Object
implements java.io.Serializable

Instances of this class give users a handle to the instructions contained in an InstructionList. Instruction objects may be used 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 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
private  java.util.Map attributes
           
protected  int i_position
           
private static InstructionHandle ih_list
           
(package private)  Instruction instruction
           
(package private)  InstructionHandle next
           
(package private)  InstructionHandle prev
           
private  java.util.Set targeters
           
 
Constructor Summary
protected InstructionHandle(Instruction i)
           
 
Method Summary
 void accept(Visitor v)
          Convenience method, simply calls accept() on the contained instruction.
 void addAttribute(java.lang.Object key, java.lang.Object attr)
          Add an attribute to an instruction handle.
protected  void addHandle()
          Overridden in BranchHandle
 void addTargeter(InstructionTargeter t)
          Denote this handle is being referenced by t.
(package private)  void dispose()
          Delete contents, i.e., remove user access and make handle reusable.
 java.lang.Object getAttribute(java.lang.Object key)
          Get attribute of an instruction handle.
 java.util.Collection getAttributes()
           
 Instruction getInstruction()
           
(package private) static InstructionHandle getInstructionHandle(Instruction i)
          Factory method.
 InstructionHandle getNext()
           
 int getPosition()
           
 InstructionHandle getPrev()
           
 InstructionTargeter[] getTargeters()
           
 boolean hasTargeters()
           
 void removeAllTargeters()
          Remove all targeters, if any.
 void removeAttribute(java.lang.Object key)
          Delete an attribute of an instruction handle.
 void removeTargeter(InstructionTargeter t)
          Denote this handle isn't referenced anymore by t.
 void setInstruction(Instruction i)
          Replace current instruction contained in this handle.
(package private)  void setPosition(int pos)
          Set the position, i.e., the byte code offset of the contained instruction.
 Instruction swapInstruction(Instruction i)
          Temporarily swap the current instruction, without disturbing anything.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 java.lang.String toString(boolean verbose)
           
protected  int updatePosition(int offset, int max_offset)
          Called by InstructionList.setPositions when setting the position for every instruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

InstructionHandle next

prev

InstructionHandle prev

instruction

Instruction instruction

i_position

protected int i_position

targeters

private java.util.Set targeters

attributes

private java.util.Map attributes

ih_list

private static InstructionHandle ih_list
Constructor Detail

InstructionHandle

protected InstructionHandle(Instruction i)
Method Detail

getNext

public final InstructionHandle getNext()

getPrev

public final InstructionHandle getPrev()

getInstruction

public final Instruction getInstruction()

setInstruction

public void setInstruction(Instruction i)
Replace current instruction contained in this handle. Old instruction is disposed using Instruction.dispose().


swapInstruction

public Instruction swapInstruction(Instruction i)
Temporarily swap the current instruction, without disturbing anything. Meant to be used by a debugger, implementing breakpoints. Current instruction is returned.


getInstructionHandle

static final InstructionHandle getInstructionHandle(Instruction i)
Factory method.


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.


getPosition

public int getPosition()

setPosition

void setPosition(int pos)
Set the position, i.e., the byte code offset of the contained instruction.


addHandle

protected void addHandle()
Overridden in BranchHandle


dispose

void dispose()
Delete contents, i.e., remove user access and make handle reusable.


removeAllTargeters

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


removeTargeter

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


addTargeter

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


hasTargeters

public boolean hasTargeters()

getTargeters

public InstructionTargeter[] getTargeters()

toString

public java.lang.String toString(boolean verbose)

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


addAttribute

public void addAttribute(java.lang.Object key,
                         java.lang.Object attr)
Add an attribute to an instruction handle.


removeAttribute

public void removeAttribute(java.lang.Object key)
Delete an attribute of an instruction handle.


getAttribute

public java.lang.Object getAttribute(java.lang.Object key)
Get attribute of an instruction handle.


getAttributes

public java.util.Collection getAttributes()

accept

public void accept(Visitor v)
Convenience method, simply calls accept() on the contained instruction.