Class Switch
java.lang.Object
EDU.purdue.cs.bloat.editor.Switch
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 -
Method Summary
Modifier and TypeMethodDescriptionGet the default target of the switch.booleanCheck if the all the values in the range of lookup values are contiguous.intGet the high value in the range the lookup values.intlowValue()Get the low value in the range the lookup values.voidsetDefaultTarget(Label target) Set the default target of the switch.Label[]targets()Get the non-default branch targets of the switch.toString()Convert the operand to a string.int[]values()Get the lookup values of the switch, sorted low to high.
-
Constructor Details
-
Switch
-
-
Method Details
-
setDefaultTarget
Set the default target of the switch.- Parameters:
target- The default target of the switch.
-
defaultTarget
Get the default target of the switch.- Returns:
- The default target of the switch.
-
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
-