Package serp.bytecode

Class InstructionPtrStrategy

  • All Implemented Interfaces:
    InstructionPtr

    class InstructionPtrStrategy
    extends java.lang.Object
    implements 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.
    • Method Detail

      • 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

        public void setTargetInstruction​(Instruction ins)
        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

        public Instruction 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 interface InstructionPtr
      • replaceTarget

        public void replaceTarget​(Instruction oldTarget,
                                  Instruction newTarget)
        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 interface InstructionPtr
      • getCode

        public Code getCode()
        Description copied from interface: InstructionPtr
        Returns the Code block that owns the Instruction(s) this InstructionPtr points to.
        Specified by:
        getCode in interface InstructionPtr