Class BranchInstruction

    • Field Detail

      • index

        @Deprecated
        protected int index
        Deprecated.
        (since 6.0) will be made private; do not access directly, use getter/setter
      • target

        @Deprecated
        protected InstructionHandle target
        Deprecated.
        (since 6.0) will be made private; do not access directly, use getter/setter
      • position

        @Deprecated
        protected int position
        Deprecated.
        (since 6.0) will be made private; do not access directly, use getter/setter
    • Constructor Detail

      • BranchInstruction

        BranchInstruction()
        Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      • BranchInstruction

        protected BranchInstruction​(short opcode,
                                    InstructionHandle target)
        Common super constructor
        Parameters:
        opcode - Instruction opcode
        target - instruction to branch to
    • Method Detail

      • dispose

        void dispose()
        Inform target that it's not targeted anymore.
        Overrides:
        dispose in class Instruction
      • dump

        public void dump​(java.io.DataOutputStream out)
                  throws java.io.IOException
        Dump instruction as byte code to stream out.
        Overrides:
        dump in class Instruction
        Parameters:
        out - Output stream
        Throws:
        java.io.IOException - Thrown when an I/O exception of some sort has occurred.
      • getIndex

        public final int getIndex()
        Returns:
        target offset in byte code
      • getPosition

        protected int getPosition()
        Returns:
        the position
        Since:
        6.0
      • getTarget

        public InstructionHandle getTarget()
        Returns:
        target of branch instruction
      • getTargetOffset

        protected int getTargetOffset()
        Returns:
        the offset to this instruction's target
      • getTargetOffset

        protected int getTargetOffset​(InstructionHandle target)
        Parameters:
        target - branch target
        Returns:
        the offset to 'target' relative to this instruction
      • initFromFile

        protected void initFromFile​(ByteSequence bytes,
                                    boolean wide)
                             throws java.io.IOException
        Read needed data (e.g. index) from file. Conversion to a InstructionHandle is done in InstructionList(byte[]).
        Overrides:
        initFromFile in class Instruction
        Parameters:
        bytes - input stream
        wide - wide prefix?
        Throws:
        java.io.IOException - may be thrown if the implementation needs to read data from the file
        See Also:
        InstructionList
      • setIndex

        protected void setIndex​(int index)
        Parameters:
        index - the index to set
        Since:
        6.0
      • setPosition

        protected void setPosition​(int position)
        Parameters:
        position - the position to set
        Since:
        6.0
      • setTarget

        public void setTarget​(InstructionHandle target)
        Set branch target
        Parameters:
        target - branch target
      • toString

        public java.lang.String toString​(boolean verbose)
        Long output format: <position in byte code> <name of opcode> "["<opcode number>"]" "("<length of instruction>")" "<"<target instruction>">" "@"<branch target offset>
        Overrides:
        toString in class Instruction
        Parameters:
        verbose - long/short format switch
        Returns:
        mnemonic for instruction
      • updatePosition

        protected int updatePosition​(int offset,
                                     int maxOffset)
        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.
        Parameters:
        offset - additional offset caused by preceding (variable length) instructions
        maxOffset - the maximum offset that may be caused by these instructions
        Returns:
        additional offset caused by possible change of this instruction's length