joeq.Compiler.BytecodeAnalysis
Class Bytecodes.InstructionHandle

java.lang.Object
  extended by joeq.Compiler.BytecodeAnalysis.Bytecodes.InstructionHandle
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Bytecodes.BranchHandle
Enclosing interface:
Bytecodes

public static class Bytecodes.InstructionHandle
extends Object
implements Serializable

See Also:
Serialized Form

Field Summary
protected  int i_position
           
 
Constructor Summary
protected Bytecodes.InstructionHandle(Bytecodes.Instruction i)
           
 
Method Summary
 void accept(Bytecodes.Visitor v)
          Convenience method, simply calls accept() on the contained instruction.
 void addAttribute(Object key, Object attr)
          Add an attribute to an instruction handle.
protected  void addHandle()
          Overridden in BranchHandle
 void addTargeter(Bytecodes.InstructionTargeter t)
          Denote this handle is being referenced by t.
 Object getAttribute(Object key)
          Get attribute of an instruction handle.
 Bytecodes.Instruction getInstruction()
           
 Bytecodes.InstructionHandle getNext()
           
 int getPosition()
           
 Bytecodes.InstructionHandle getPrev()
           
 Set getTargeters()
           
 boolean hasTargeters()
           
 void removeAllTargeters()
          Remove all targeters, if any.
 void removeAttribute(Object key)
          Delete an attribute of an instruction handle.
 void removeTargeter(Bytecodes.InstructionTargeter t)
          Denote this handle isn't referenced anymore by t.
 void setInstruction(Bytecodes.Instruction i)
          Replace current instruction contained in this handle.
 Bytecodes.Instruction swapInstruction(Bytecodes.Instruction i)
          Temporarily swap the current instruction, without disturbing anything.
 String toString()
           
 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

i_position

protected int i_position
Constructor Detail

Bytecodes.InstructionHandle

protected Bytecodes.InstructionHandle(Bytecodes.Instruction i)
Method Detail

getNext

public final Bytecodes.InstructionHandle getNext()

getPrev

public final Bytecodes.InstructionHandle getPrev()

getInstruction

public final Bytecodes.Instruction getInstruction()

setInstruction

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


swapInstruction

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


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

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.

addHandle

protected void addHandle()
Overridden in BranchHandle


removeAllTargeters

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


removeTargeter

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


addTargeter

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


hasTargeters

public boolean hasTargeters()

getTargeters

public Set getTargeters()
Returns:
null, if there are no targeters

toString

public String toString(boolean verbose)
Returns:
a (verbose) string representation of the contained instruction.

toString

public String toString()
Overrides:
toString in class Object
Returns:
a string representation of the contained instruction.

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

removeAttribute

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

Parameters:
key - the key object to retrieve the attribute

getAttribute

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

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

accept

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

Parameters:
v - Visitor object


Copyright © 2001-2008 John Whaley. All Rights Reserved.