joeq.Compiler.BytecodeAnalysis
Class Bytecodes.BranchInstruction

java.lang.Object
  extended by joeq.Compiler.BytecodeAnalysis.Bytecodes.Instruction
      extended by joeq.Compiler.BytecodeAnalysis.Bytecodes.BranchInstruction
All Implemented Interfaces:
Serializable, Cloneable, Bytecodes.InstructionTargeter
Direct Known Subclasses:
Bytecodes.GotoInstruction, Bytecodes.IfInstruction, Bytecodes.JsrInstruction, Bytecodes.Select
Enclosing interface:
Bytecodes

public abstract static class Bytecodes.BranchInstruction
extends Bytecodes.Instruction
implements Bytecodes.InstructionTargeter

See Also:
Serialized Form

Field Summary
protected  int index
           
protected  int position
           
protected  Bytecodes.InstructionHandle target
           
 
Fields inherited from class joeq.Compiler.BytecodeAnalysis.Bytecodes.Instruction
length, opcode
 
Constructor Summary
protected Bytecodes.BranchInstruction(short opcode, Bytecodes.InstructionHandle target)
          Common super constructor.
 
Method Summary
 boolean containsTarget(Bytecodes.InstructionHandle ih)
           
 void dump(DataOutputStream out)
          Dump instruction as byte code to stream out.
 int getIndex()
           
 Bytecodes.InstructionHandle getTarget()
           
protected  int getTargetOffset()
           
protected  int getTargetOffset(Bytecodes.InstructionHandle target)
           
protected  void initFromFile(jq_ConstantPool cp, jwutil.io.ByteSequence bytes, boolean wide)
          Read needed data (e.g.
 void setTarget(Bytecodes.InstructionHandle target)
          Set branch target
 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(Bytecodes.InstructionHandle old_ih, Bytecodes.InstructionHandle new_ih)
           
 
Methods inherited from class joeq.Compiler.BytecodeAnalysis.Bytecodes.Instruction
accept, consumeStack, copy, getLength, getOpcode, produceStack, readInstruction, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected int index

target

protected Bytecodes.InstructionHandle target

position

protected int position
Constructor Detail

Bytecodes.BranchInstruction

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

Parameters:
opcode - instruction opcode
target - instruction to branch to
Method Detail

dump

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

Overrides:
dump in class Bytecodes.Instruction
Parameters:
out - Output stream
Throws:
IOException

getTargetOffset

protected int getTargetOffset(Bytecodes.InstructionHandle target)
Parameters:
target - branch target
Returns:
the offset to `target' relative to this instruction

getTargetOffset

protected int getTargetOffset()
Returns:
the offset to this instruction's target

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

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>

Overrides:
toString in class Bytecodes.Instruction
Parameters:
verbose - long/short format switch
Returns:
mnemonic for instruction

initFromFile

protected void initFromFile(jq_ConstantPool cp,
                            jwutil.io.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 Bytecodes.Instruction
Parameters:
bytes - input stream
wide - wide prefix?
cp - constant pool of class we are reading
Throws:
IOException
See Also:
Bytecodes.InstructionList

getIndex

public final int getIndex()
Returns:
target offset in byte code

getTarget

public Bytecodes.InstructionHandle getTarget()
Returns:
target of branch instruction

setTarget

public void setTarget(Bytecodes.InstructionHandle target)
Set branch target

Parameters:
target - branch target

updateTarget

public void updateTarget(Bytecodes.InstructionHandle old_ih,
                         Bytecodes.InstructionHandle new_ih)
Specified by:
updateTarget in interface Bytecodes.InstructionTargeter
Parameters:
old_ih - old target
new_ih - new target

containsTarget

public boolean containsTarget(Bytecodes.InstructionHandle ih)
Specified by:
containsTarget in interface Bytecodes.InstructionTargeter
Returns:
true, if ih is target of this instruction


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