Package org.apache.bcel.generic
Class Select
- java.lang.Object
-
- org.apache.bcel.generic.Instruction
-
- org.apache.bcel.generic.BranchInstruction
-
- org.apache.bcel.generic.Select
-
- All Implemented Interfaces:
java.lang.Cloneable,InstructionTargeter,StackConsumer,StackProducer,VariableLengthInstruction
- Direct Known Subclasses:
LOOKUPSWITCH,TABLESWITCH
public abstract class Select extends BranchInstruction implements VariableLengthInstruction, StackConsumer, StackProducer
Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.We use our super's
targetproperty as the default target.- See Also:
LOOKUPSWITCH,TABLESWITCH,InstructionList
-
-
Field Summary
Fields Modifier and Type Field Description protected intfixed_lengthDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected int[]indicesDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected int[]matchDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected intmatch_lengthDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected intpaddingDeprecated.(since 6.0) will be made private; do not access directly, use getter/setterprotected InstructionHandle[]targetsDeprecated.(since 6.0) will be made private; do not access directly, use getter/setter-
Fields inherited from class org.apache.bcel.generic.BranchInstruction
index, position, target
-
Fields inherited from class org.apache.bcel.generic.Instruction
length, opcode
-
-
Constructor Summary
Constructors Constructor Description Select()Empty constructor needed for Instruction.readInstruction.Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget)(Match, target) pairs for switch.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Objectclone()booleancontainsTarget(InstructionHandle ih)Checks whether this targeter targets the specified instruction handle.(package private) voiddispose()Inform targets that they're not targeted anymore.voiddump(java.io.DataOutputStream out)Dump instruction as byte code to stream out.(package private) intgetFixed_length()int[]getIndices()(package private) intgetIndices(int index)(package private) intgetMatch(int index)(package private) intgetMatch_length()int[]getMatchs()(package private) intgetPadding()(package private) InstructionHandlegetTarget(int index)InstructionHandle[]getTargets()protected voidinitFromFile(ByteSequence bytes, boolean wide)Read needed data (e.g.(package private) voidsetFixed_length(int fixed_length)(package private) voidsetIndices(int[] array)(package private) intsetIndices(int i, int value)(package private) voidsetMatch(int index, int value)(package private) intsetMatch_length(int match_length)(package private) voidsetMatches(int[] array)voidsetTarget(int i, InstructionHandle target)Set branch target for `i'th case(package private) voidsetTargets(InstructionHandle[] array)java.lang.StringtoString(boolean verbose)Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>protected intupdatePosition(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.voidupdateTarget(InstructionHandle old_ih, InstructionHandle new_ih)Replaces the target of this targeter from this old handle to the new handle.-
Methods inherited from class org.apache.bcel.generic.BranchInstruction
getIndex, getPosition, getTarget, getTargetOffset, getTargetOffset, notifyTarget, setIndex, setPosition, setTarget
-
Methods inherited from class org.apache.bcel.generic.Instruction
accept, consumeStack, copy, equals, getComparator, getLength, getName, getOpcode, hashCode, isValidByte, isValidShort, produceStack, readInstruction, setComparator, setLength, setOpcode, toString, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.bcel.generic.StackConsumer
consumeStack
-
Methods inherited from interface org.apache.bcel.generic.StackProducer
produceStack
-
-
-
-
Field Detail
-
match
@Deprecated protected int[] match
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
indices
@Deprecated protected int[] indices
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
targets
@Deprecated protected InstructionHandle[] targets
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
fixed_length
@Deprecated protected int fixed_length
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
match_length
@Deprecated protected int match_length
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
padding
@Deprecated protected int padding
Deprecated.(since 6.0) will be made private; do not access directly, use getter/setter
-
-
Constructor Detail
-
Select
Select()
Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
-
Select
Select(short opcode, int[] match, InstructionHandle[] targets, InstructionHandle defaultTarget)(Match, target) pairs for switch. `Match' and `targets' must have the same length of course.- Parameters:
match- array of matching valuestargets- instruction targetsdefaultTarget- default instruction target
-
-
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.- Overrides:
updatePositionin classBranchInstruction- Parameters:
offset- additional offset caused by preceding (variable length) instructionsmax_offset- the maximum offset that may be caused by these instructions- Returns:
- additional offset caused by possible change of this instruction's length
-
dump
public void dump(java.io.DataOutputStream out) throws java.io.IOExceptionDump instruction as byte code to stream out.- Overrides:
dumpin classBranchInstruction- Parameters:
out- Output stream- Throws:
java.io.IOException
-
initFromFile
protected void initFromFile(ByteSequence bytes, boolean wide) throws java.io.IOException
Read needed data (e.g. index) from file.- Overrides:
initFromFilein classBranchInstruction- Parameters:
bytes- input streamwide- wide prefix?- Throws:
java.io.IOException- may be thrown if the implementation needs to read data from the file- See Also:
InstructionList
-
toString
public java.lang.String toString(boolean verbose)
Description copied from class:BranchInstructionLong output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>- Overrides:
toStringin classBranchInstruction- Parameters:
verbose- long/short format switch- Returns:
- mnemonic for instruction
-
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)
Description copied from interface:InstructionTargeterReplaces the target of this targeter from this old handle to the new handle.- Specified by:
updateTargetin interfaceInstructionTargeter- Overrides:
updateTargetin classBranchInstruction- Parameters:
old_ih- old targetnew_ih- new target
-
containsTarget
public boolean containsTarget(InstructionHandle ih)
Description copied from interface:InstructionTargeterChecks whether this targeter targets the specified instruction handle.- Specified by:
containsTargetin interfaceInstructionTargeter- Overrides:
containsTargetin classBranchInstruction- Returns:
- true, if ih is target of this instruction
-
clone
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
dispose
void dispose()
Inform targets that they're not targeted anymore.- Overrides:
disposein classBranchInstruction
-
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
-
getMatch
final int getMatch(int index)
- Returns:
- match entry
- Since:
- 6.0
-
getIndices
final int getIndices(int index)
- Returns:
- index entry from indices
- Since:
- 6.0
-
getTarget
final InstructionHandle getTarget(int index)
- Returns:
- target entry
- Since:
- 6.0
-
getFixed_length
final int getFixed_length()
- Returns:
- the fixed_length
- Since:
- 6.0
-
setFixed_length
final void setFixed_length(int fixed_length)
- Parameters:
fixed_length- the fixed_length to set- Since:
- 6.0
-
getMatch_length
final int getMatch_length()
- Returns:
- the match_length
- Since:
- 6.0
-
setMatch_length
final int setMatch_length(int match_length)
- Parameters:
match_length- the match_length to set- Since:
- 6.0
-
setMatch
final void setMatch(int index, int value)- Parameters:
index-value-- Since:
- 6.0
-
setIndices
final void setIndices(int[] array)
- Parameters:
array-- Since:
- 6.0
-
setMatches
final void setMatches(int[] array)
- Parameters:
array-- Since:
- 6.0
-
setTargets
final void setTargets(InstructionHandle[] array)
- Parameters:
array-- Since:
- 6.0
-
getPadding
final int getPadding()
- Returns:
- the padding
- Since:
- 6.0
-
setIndices
final int setIndices(int i, int value)- Since:
- 6.0
-
-