de.fub.bytecode.generic
Class Select

java.lang.Object
  |
  +--de.fub.bytecode.generic.Instruction
        |
        +--de.fub.bytecode.generic.BranchInstruction
              |
              +--de.fub.bytecode.generic.Select
Direct Known Subclasses:
LOOKUPSWITCH, TABLESWITCH

public abstract class Select
extends BranchInstruction
implements VariableLengthInstruction

Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.

Version:
$Id: Select.java,v 1.10 1999/08/30 13:54:10 dahm Exp $
Author:
M. Dahm
See Also:
LOOKUPSWITCH, TABLESWITCH, InstructionList, Serialized Form

Field Summary
protected  int fixed_length
           
protected  int[] indices
           
protected  int[] match
           
protected  int match_length
           
protected  int padding
           
protected  InstructionHandle[] targets
           
 
Fields inherited from class de.fub.bytecode.generic.BranchInstruction
index, position, target
 
Fields inherited from class de.fub.bytecode.generic.Instruction
length, tag
 
Method Summary
 boolean containsTarget(InstructionHandle ih)
           
 void dump(java.io.DataOutputStream out)
          Dump instruction as byte code to stream out.
 int[] getIndices()
           
 int[] getMatchs()
           
 InstructionHandle[] getTargets()
           
protected  void initFromFile(ByteSequence bytes, boolean wide)
          Read needed data (e.g.
 void setTarget(int i, InstructionHandle target)
          Set branch target for `i'th case
 java.lang.String toString(boolean verbose)
           
protected  int updatePosition(int offset, int max_offset)
          Since this is a variable length instruction, it may shift the following instructions which then need to update their position.
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
           
 
Methods inherited from class de.fub.bytecode.generic.BranchInstruction
getTarget, getTargetOffset, getTargetOffset, setTarget
 
Methods inherited from class de.fub.bytecode.generic.Instruction
consumeStack, consumeStack, copy, getLength, getTag, produceStack, produceStack, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

match

protected int[] match

indices

protected int[] indices

targets

protected InstructionHandle[] targets

fixed_length

protected int fixed_length

match_length

protected int match_length

padding

protected int padding
Method Detail

updatePosition

protected int updatePosition(int offset,
                             int max_offset)
Since this is a variable length instruction, it may shift the following instructions which then need to update their position. 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
Overrides:
updatePosition in class BranchInstruction

dump

public void dump(java.io.DataOutputStream out)
          throws java.io.IOException
Dump instruction as byte code to stream out.
Parameters:
out - Output stream
Overrides:
dump in class BranchInstruction

initFromFile

protected void initFromFile(ByteSequence bytes,
                            boolean wide)
                     throws java.io.IOException
Read needed data (e.g. index) from file.
Overrides:
initFromFile in class BranchInstruction

toString

public java.lang.String toString(boolean verbose)
Returns:
mnemonic for instruction
Overrides:
toString in class BranchInstruction

setTarget

public void setTarget(int i,
                      InstructionHandle target)
Set branch target for `i'th case

updateTarget

public void updateTarget(InstructionHandle old_ih,
                         InstructionHandle new_ih)
Parameters:
old_ih - old target
new_ih - new target
Overrides:
updateTarget in class BranchInstruction

containsTarget

public boolean containsTarget(InstructionHandle ih)
Returns:
true, if ih is target of this instruction
Overrides:
containsTarget in class BranchInstruction

getMatchs

public int[] getMatchs()
Returns:
array of match indices

getIndices

public int[] getIndices()
Returns:
array of match target offsets

getTargets

public InstructionHandle[] getTargets()
Returns:
array of match targets