Package serp.bytecode
Class LookupSwitchInstruction
java.lang.Object
serp.bytecode.CodeEntry
serp.bytecode.Instruction
serp.bytecode.JumpInstruction
serp.bytecode.LookupSwitchInstruction
- All Implemented Interfaces:
BCEntity,InstructionPtr,VisitAcceptor
The
lookupswitch instruction.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptVisit(BCVisitor visit) Accept a visit from aBCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.addCase(int match, Instruction target) Add a case to this switch.private InstructionfindJumpPoint(int jumpByteIndex, List inss) intSynonymous withJumpInstruction.getOffset().Synonymous withJumpInstruction.getTarget().(package private) intReturn the length in bytes of this opcode, including all arguments.int[]Return the values of the case statements for this switch.int[]intReturn the number of stack positions this instruction pushes or pops during its execution.Return the targets of the case statements for this switch.(package private) voidRead the arguments for this opcode from the given stream.(package private) voidread(Instruction orig) Copy the given instruction data.voidreplaceTarget(Instruction oldTarget, Instruction newTarget) Replace the given old, likely invalid, target with a new target.setCases(int[] matches, Instruction[] targets) Set the match-jumppt pairs for this switch.setDefaultOffset(int offset) Synonymous withJumpInstruction.setOffset(int).Synonymous withJumpInstruction.setTarget(serp.bytecode.Instruction).voidUse the byte indexes read from the class file to calculate and set references to the target instruction(s) for this ptr.(package private) voidwrite(DataOutput out) Write the arguments for this opcode to the given stream.Methods inherited from class serp.bytecode.JumpInstruction
equalsInstruction, getOffset, getTarget, setOffset, setTargetMethods inherited from class serp.bytecode.Instruction
getByteIndex, getClassLoader, getCode, getLineNumber, getLogicalStackChange, getName, getOpcode, getPool, getProject, invalidate, invalidateByteIndexes, isValid, setOpcodeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface serp.bytecode.InstructionPtr
getCode
-
Field Details
-
_matches
-
_cases
-
-
Constructor Details
-
LookupSwitchInstruction
LookupSwitchInstruction(Code owner)
-
-
Method Details
-
getLength
int getLength()Description copied from class:InstructionReturn the length in bytes of this opcode, including all arguments. For many opcodes this method relies on an up-to-date byte index.- Overrides:
getLengthin classInstruction
-
getStackChange
public int getStackChange()Description copied from class:InstructionReturn the number of stack positions this instruction pushes or pops during its execution.- Overrides:
getStackChangein classInstruction- Returns:
- 0 if the stack is not affected by this instruction, a positive number if it pushes onto the stack, and a negative number if it pops from the stack
-
getDefaultTarget
Synonymous withJumpInstruction.getTarget(). -
setDefaultTarget
Synonymous withJumpInstruction.setTarget(serp.bytecode.Instruction). -
getDefaultOffset
public int getDefaultOffset()Synonymous withJumpInstruction.getOffset(). -
setDefaultOffset
Synonymous withJumpInstruction.setOffset(int). -
setCases
Set the match-jumppt pairs for this switch.- Returns:
- this instruction, for method chaining
-
getOffsets
public int[] getOffsets() -
getMatches
public int[] getMatches()Return the values of the case statements for this switch. -
getTargets
Return the targets of the case statements for this switch. -
addCase
Add a case to this switch.- Returns:
- this instruction, for method chaining
-
findJumpPoint
-
updateTargets
public void updateTargets()Description copied from interface:InstructionPtrUse the byte indexes read from the class file to calculate and set references to the target instruction(s) for this ptr. This method will be called after the byte code has been read in for the first time and before it is written after modification.- Specified by:
updateTargetsin interfaceInstructionPtr- Overrides:
updateTargetsin classJumpInstruction
-
replaceTarget
Description copied from interface:InstructionPtrReplace the given old, likely invalid, target with a new target. The new target Instruction is guaranteed to be in the same code block as this InstructionPtr.- Specified by:
replaceTargetin interfaceInstructionPtr- Overrides:
replaceTargetin classJumpInstruction
-
acceptVisit
Description copied from interface:VisitAcceptorAccept a visit from aBCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.- Specified by:
acceptVisitin interfaceVisitAcceptor- Overrides:
acceptVisitin classJumpInstruction
-
read
Description copied from class:InstructionCopy the given instruction data.- Overrides:
readin classJumpInstruction
-
read
Description copied from class:InstructionRead the arguments for this opcode from the given stream. This method should be overridden by opcodes that take arguments.- Overrides:
readin classJumpInstruction- Throws:
IOException
-
write
Description copied from class:InstructionWrite the arguments for this opcode to the given stream. This method should be overridden by opcodes that take arguments.- Overrides:
writein classJumpInstruction- Throws:
IOException
-