Class Switch


  • public class Switch
    extends java.lang.Object
    Switch is used to hold the lookup values and branch targets of a tableswitch or lookup switch instruction.

    The tableswitch low-to-high range of values is represented by storing each lookup value in the range. This allows the tableswitch to be replaced with a lookupswitch if branches are deleted.

    • Constructor Summary

      Constructors 
      Constructor Description
      Switch​(Label defaultTarget, Label[] targets, int[] values)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Label defaultTarget()
      Get the default target of the switch.
      boolean hasContiguousValues()
      Check if the all the values in the range of lookup values are contiguous.
      int highValue()
      Get the high value in the range the lookup values.
      int lowValue()
      Get the low value in the range the lookup values.
      void setDefaultTarget​(Label target)
      Set the default target of the switch.
      Label[] targets()
      Get the non-default branch targets of the switch.
      java.lang.String toString()
      Convert the operand to a string.
      int[] values()
      Get the lookup values of the switch, sorted low to high.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Switch

        public Switch​(Label defaultTarget,
                      Label[] targets,
                      int[] values)
        Constructor.
        Parameters:
        defaultTarget - The default target of the switch.
        targets - The non-default branch targets of the switch.
        values - The lookup values of the switch. This array must be the same size as the targets array.
    • Method Detail

      • setDefaultTarget

        public void setDefaultTarget​(Label target)
        Set the default target of the switch.
        Parameters:
        target - The default target of the switch.
      • defaultTarget

        public Label defaultTarget()
        Get the default target of the switch.
        Returns:
        The default target of the switch.
      • targets

        public Label[] targets()
        Get the non-default branch targets of the switch. The targets are sorted by the corresponding lookup value.
        Returns:
        The non-default branch targets of the switch.
      • values

        public int[] values()
        Get the lookup values of the switch, sorted low to high.
        Returns:
        The lookup values of the switch.
      • hasContiguousValues

        public boolean hasContiguousValues()
        Check if the all the values in the range of lookup values are contiguous. If they are, a table switch can be used. If not a lookupswitch can be used.
        Returns:
        true if contiguous, false if not.
      • lowValue

        public int lowValue()
        Get the low value in the range the lookup values.
        Returns:
        The low value.
      • highValue

        public int highValue()
        Get the high value in the range the lookup values.
        Returns:
        The high value.
      • toString

        public java.lang.String toString()
        Convert the operand to a string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of the operand.