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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.apache.bcel.generic.Instruction
      extended byorg.apache.bcel.generic.BranchInstruction
All Implemented Interfaces:
java.lang.Cloneable, InstructionTargeter, java.io.Serializable
Direct Known Subclasses:
GotoInstruction, IfInstruction, JsrInstruction, Select

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 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
protected  int index
           
protected  int position
           
protected  InstructionHandle target
           
 
Fields inherited from class org.apache.bcel.generic.Instruction
length, opcode
 
Constructor Summary
(package private) BranchInstruction()
          Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction().
protected BranchInstruction(short opcode, InstructionHandle target)
          Common super constructor
 
Method Summary
 boolean containsTarget(InstructionHandle ih)
           
(package private)  void dispose()
          Inform target that it's not targeted anymore.
 void dump(java.io.DataOutputStream out)
          Dump instruction as byte code to stream out.
 int getIndex()
           
 InstructionHandle getTarget()
           
protected  int getTargetOffset()
           
protected  int getTargetOffset(InstructionHandle _target)
           
protected  void initFromFile(org.apache.bcel.util.ByteSequence bytes, boolean wide)
          Read needed data (e.g.
(package private) static void notifyTarget(InstructionHandle old_ih, InstructionHandle new_ih, InstructionTargeter t)
          Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
 void setTarget(InstructionHandle target)
          Set branch target
 java.lang.String toString(boolean verbose)
          Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>
protected  int updatePosition(int offset, int max_offset)
          Called by InstructionList.setPositions when setting the position for every instruction.
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
           
 
Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, produceStack, readInstruction, setComparator, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected int index

target

protected InstructionHandle target

position

protected int position
Constructor Detail

BranchInstruction

BranchInstruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.


BranchInstruction

protected BranchInstruction(short opcode,
                            InstructionHandle target)
Common super constructor

Method Detail

dump

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

Overrides:
dump in class Instruction

getTargetOffset

protected int getTargetOffset(InstructionHandle _target)

getTargetOffset

protected int getTargetOffset()

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.


toString

public java.lang.String toString(boolean verbose)
Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>

Overrides:
toString in class Instruction

initFromFile

protected void initFromFile(org.apache.bcel.util.ByteSequence bytes,
                            boolean wide)
                     throws java.io.IOException
Read needed data (e.g. index) from file. Conversion to a InstructionHandle is done in InstructionList(byte[]).

Overrides:
initFromFile in class Instruction

getIndex

public final int getIndex()

getTarget

public InstructionHandle getTarget()

setTarget

public void setTarget(InstructionHandle target)
Set branch target


notifyTarget

static final void notifyTarget(InstructionHandle old_ih,
                               InstructionHandle new_ih,
                               InstructionTargeter t)
Used by BranchInstruction, LocalVariableGen, CodeExceptionGen


updateTarget

public void updateTarget(InstructionHandle old_ih,
                         InstructionHandle new_ih)
Specified by:
updateTarget in interface InstructionTargeter

containsTarget

public boolean containsTarget(InstructionHandle ih)
Specified by:
containsTarget in interface InstructionTargeter

dispose

void dispose()
Inform target that it's not targeted anymore.

Overrides:
dispose in class Instruction