Class InstructionHandle
java.lang.Object
org.apache.bcel.generic.InstructionHandle
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BranchHandle
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().
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConvenience method, simply calls accept() on the contained instruction.voidaddAttribute(Object key, Object attr) Add an attribute to an instruction handle.protected voidOverridden in BranchHandlevoidDenote this handle is being referenced by t.getAttribute(Object key) Get attribute of an instruction handle.final Instructionfinal InstructionHandlegetNext()intfinal InstructionHandlegetPrev()booleanvoidRemove all targeters, if any.voidremoveAttribute(Object key) Delete an attribute of an instruction handle.voidDenote this handle isn't referenced anymore by t.voidReplace current instruction contained in this handle.Temporarily swap the current instruction, without disturbing anything.toString()toString(boolean verbose) protected intupdatePosition(int offset, int max_offset) Called by InstructionList.setPositions when setting the position for every instruction.
-
Field Details
-
i_position
protected int i_position
-
-
Constructor Details
-
InstructionHandle
-
-
Method Details
-
getNext
-
getPrev
-
getInstruction
-
setInstruction
Replace current instruction contained in this handle. Old instruction is disposed using Instruction.dispose(). -
swapInstruction
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) instructionsmax_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
Denote this handle isn't referenced anymore by t. -
addTargeter
Denote this handle is being referenced by t. -
hasTargeters
public boolean hasTargeters() -
getTargeters
- Returns:
- null, if there are no targeters
-
toString
- Returns:
- a (verbose) string representation of the contained instruction.
-
toString
-
addAttribute
-
removeAttribute
Delete an attribute of an instruction handle.- Parameters:
key- the key object to retrieve the attribute
-
getAttribute
-
getAttributes
- Returns:
- all attributes associated with this handle
-
accept
Convenience method, simply calls accept() on the contained instruction.- Parameters:
v- Visitor object
-