Package serp.bytecode
Class InstructionPtrStrategy
java.lang.Object
serp.bytecode.InstructionPtrStrategy
- All Implemented Interfaces:
InstructionPtr
InstructionPtrStrategy handles the different strategies for finding the
Instructions that InstructionPtrs point to. These strategies include,
from least desirable to most desirable, using byte indexes,
and storing a reference to the target Instruction proper.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInstructionPtrStrategy
(InstructionPtr pointer) InstructionPtrStrategy
(InstructionPtr pointer, Instruction target) -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the byteIndex at which the target instruction can be found.getCode()
Returns the Code block that owns the Instruction(s) this InstructionPtr points to.Returns the Instruction this Target is targetting.void
replaceTarget
(Instruction oldTarget, Instruction newTarget) Replace the given old, likely invalid, target with a new target.void
setByteIndex
(int index) Sets the byteIndex where the target Instruction can be found.void
Changes the target Instruction.void
Same as getInstruction, but this method alters the Target strategy to use the returned Instruction.
-
Field Details
-
_pointer
-
_target
-
_byteIndex
private int _byteIndex
-
-
Constructor Details
-
InstructionPtrStrategy
-
InstructionPtrStrategy
-
-
Method Details
-
setByteIndex
public void setByteIndex(int index) Sets the byteIndex where the target Instruction can be found. This target will now be using byte indices as its target finding strategy, which is the least robust option. Changing the Code block or importing it into another Method may result in an invalid target. -
setTargetInstruction
Changes the target Instruction. The target is in the best state possible and should maintain this information even in the face of Code imports and Code changes. -
getTargetInstruction
Returns the Instruction this Target is targetting. This request does not change the targetting strategy for this Target. -
getByteIndex
public int getByteIndex()Returns the byteIndex at which the target instruction can be found. This call does not change the Target strategy. -
updateTargets
public void updateTargets()Same as getInstruction, but this method alters the Target strategy to use the returned Instruction. This method alters the Target strategy (and Instruction) iff it was previously using byte indexes.- Specified by:
updateTargets
in interfaceInstructionPtr
-
replaceTarget
Description copied from interface:InstructionPtr
Replace 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:
replaceTarget
in interfaceInstructionPtr
-
getCode
Description copied from interface:InstructionPtr
Returns the Code block that owns the Instruction(s) this InstructionPtr points to.- Specified by:
getCode
in interfaceInstructionPtr
-