org.apache.bcel.generic

Class Select

Implemented Interfaces:
Cloneable, InstructionTargeter, Serializable, StackProducer, VariableLengthInstruction
Known Direct Subclasses:
LOOKUPSWITCH, TABLESWITCH

public abstract class Select
extends BranchInstruction
implements VariableLengthInstruction, StackProducer

Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.
Version:
$Id: Select.java,v 1.2 2002/04/26 09:30:11 mdahm Exp $
Author:
M. Dahm
See Also:
LOOKUPSWITCH, TABLESWITCH, InstructionList

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 org.apache.bcel.generic.BranchInstruction

index, position, target

Fields inherited from class org.apache.bcel.generic.Instruction

length, opcode

Method Summary

boolean
containsTarget(InstructionHandle ih)
void
dump(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
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 org.apache.bcel.generic.BranchInstruction

containsTarget, dump, getIndex, getTarget, getTargetOffset, getTargetOffset, initFromFile, setTarget, toString, updatePosition, updateTarget

Methods inherited from class org.apache.bcel.generic.Instruction

accept, consumeStack, copy, dump, equals, getComparator, getLength, getName, getOpcode, initFromFile, produceStack, readInstruction, setComparator, toString, toString, toString

Field Details

fixed_length

protected int fixed_length

indices

protected int[] indices

match

protected int[] match

match_length

protected int match_length

padding

protected int padding

targets

protected InstructionHandle[] targets

Method Details

containsTarget

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

dump

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

getIndices

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

getMatchs

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

getTargets

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

initFromFile

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

setTarget

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

toString

public String toString(boolean verbose)
Overrides:
toString in interface BranchInstruction
Returns:
mnemonic for instruction

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.
Overrides:
updatePosition in interface BranchInstruction
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

updateTarget

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