All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class de.fub.bytecode.generic.BranchInstruction

java.lang.Object
   |
   +----de.fub.bytecode.generic.Instruction
           |
           +----de.fub.bytecode.generic.BranchInstruction

public abstract class BranchInstruction
extends Instruction
implements InstructionTargeter
Abstract super class for branching instructions like GOTO, IFEQ, etc.. Branch instructions may have a variable length, namely GOTO, JSR, LOOKUPSWITCH and TABLESWITCH.

Version:
$Id: BranchInstruction.java,v 1.10 1999/09/09 07:42:46 dahm Exp $
Author:
M. Dahm
See Also:
InstructionList

Variable Index

 o index
 o position
 o target

Constructor Index

 o BranchInstruction(short, InstructionHandle)

Method Index

 o containsTarget(InstructionHandle)
 o dump(DataOutputStream)
Dump instruction as byte code to stream out.
 o getTarget()
 o getTargetOffset()
 o getTargetOffset(InstructionHandle)
 o initFromFile(ByteSequence, boolean)
Read needed data (e.g.
 o setTarget(InstructionHandle)
Set branch target
 o toString(boolean)
Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "
 o updatePosition(int, int)
Called by InstructionList.setPositions when setting the position for every instruction.
 o updateTarget(InstructionHandle, InstructionHandle)

Variables

 o index
 protected int index
 o target
 protected InstructionHandle target
 o position
 protected int position

Constructors

 o BranchInstruction
 protected BranchInstruction(short tag,
                             InstructionHandle target)
Parameters:
instruction - Target instruction to branch to

Methods

 o dump
 public void dump(DataOutputStream out) throws IOException
Dump instruction as byte code to stream out.

Parameters:
out - Output stream
Overrides:
dump in class Instruction
 o getTargetOffset
 protected int getTargetOffset(InstructionHandle target)
Parameters:
target - branch target
Returns:
the offset to `target' relative to this instruction
 o getTargetOffset
 protected int getTargetOffset()
Returns:
the offset to this instruction's target
 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 toString
 public String toString(boolean verbose)
Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>

Parameters:
verbose - long/short format switch
Returns:
mnemonic for instruction
Overrides:
toString in class Instruction
 o initFromFile
 protected void initFromFile(ByteSequence bytes,
                             boolean wide) throws IOException
Read needed data (e.g. index) from file. Conversion to a InstructionHandle is done in InstructionList(byte[]).

Overrides:
initFromFile in class Instruction
See Also:
InstructionList
 o getTarget
 public InstructionHandle getTarget()
Returns:
target of branch instruction
 o setTarget
 public void setTarget(InstructionHandle target)
Set branch target

 o updateTarget
 public void updateTarget(InstructionHandle old_ih,
                          InstructionHandle new_ih)
Parameters:
old_ih - old target
new_ih - new target
 o containsTarget
 public boolean containsTarget(InstructionHandle ih)
Returns:
true, if ih is target of this instruction

All Packages  Class Hierarchy  This Package  Previous  Next  Index