Class ConditionalBranchInstruction


  • public class ConditionalBranchInstruction
    extends Instruction
    Represents the conditional branch instructions.
    • Constructor Detail

      • ConditionalBranchInstruction

        public ConditionalBranchInstruction​(int opcode,
                                            int offset,
                                            short branchOffset)
        Constructs a ConditionalBranchInstruction.
        Parameters:
        opcode - The opcode of the instruction.
        offset - The bytecode offset of the instruction.
        branchOffset - The branch target offset relative to current instruction.
        Throws:
        IllegalArgumentException - if the opcode is not a conditional branch opcode
    • Method Detail

      • write

        public void write​(DataOutputStream dos)
                   throws IOException
        Writes the conditional branch opcode and its operands to the DataOutputStream.
        Specified by:
        write in class Instruction
        Parameters:
        dos - The DataOutputStream to write to.
        Throws:
        IOException - If an I/O error occurs.
      • getStackChange

        public int getStackChange()
        Returns the change in stack size caused by this instruction.
        Specified by:
        getStackChange in class Instruction
        Returns:
        The stack size change based on the branch type.
      • getLocalChange

        public int getLocalChange()
        Returns the change in local variables caused by this instruction.
        Specified by:
        getLocalChange in class Instruction
        Returns:
        The local variables size change (none).
      • getBranchOffset

        public int getBranchOffset()
        Returns the branch offset.
        Returns:
        The branch target offset.
      • toString

        public String toString()
        Returns a string representation of the instruction.
        Overrides:
        toString in class Instruction
        Returns:
        The mnemonic and branch target of the instruction.