Class SwitchInstruction

java.lang.Object
com.ibm.wala.shrike.shrikeBT.Instruction
com.ibm.wala.shrike.shrikeBT.SwitchInstruction
All Implemented Interfaces:
Constants, IInstruction, Cloneable

public final class SwitchInstruction extends Instruction
This instruction represents all forms of switch instructions.
  • Method Details

    • getDefaultLabel

      public int getDefaultLabel()
      Returns:
      the label which is branched to if none of the cases match
    • getCasesAndLabels

      public int[] getCasesAndLabels()
      Returns:
      an array of flattened (case, label) pairs, sorted in increasing order by case
    • make

      public static SwitchInstruction make(int[] casesAndLabels, int defaultLabel)
      Make a switch instruction.
      Parameters:
      casesAndLabels - an array of flattened (case, label) pairs, sorted in increasing order by case
      defaultLabel - the default label to branch to if no cases match
      Throws:
      IllegalArgumentException - if casesAndLabels is null
    • isFallThrough

      public boolean isFallThrough()
      Specified by:
      isFallThrough in interface IInstruction
      Overrides:
      isFallThrough in class Instruction
      Returns:
      true if the instruction can "fall through" to the following instruction
    • getBranchTargets

      public int[] getBranchTargets()
      Specified by:
      getBranchTargets in interface IInstruction
      Overrides:
      getBranchTargets in class Instruction
      Returns:
      an array containing the labels this instruction can branch to (not including the following instruction if this instruction 'falls through')
    • redirectTargets

      public IInstruction redirectTargets(int[] targetMap) throws IllegalArgumentException
      Specified by:
      redirectTargets in interface IInstruction
      Overrides:
      redirectTargets in class Instruction
      Returns:
      an Instruction equivalent to this one but with any branch labels updated by looking them up in the targetMap array
      Throws:
      IllegalArgumentException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getPoppedCount

      public int getPoppedCount()
      Specified by:
      getPoppedCount in interface IInstruction
      Overrides:
      getPoppedCount in class Instruction
      Returns:
      the number of values this instruction pops off the working stack
    • toString

      public String toString()
      Description copied from class: Instruction
      Subclasses must implement toString.
      Specified by:
      toString in interface IInstruction
      Specified by:
      toString in class Instruction
    • visit

      public void visit(IInstruction.Visitor v) throws IllegalArgumentException
      Description copied from class: Instruction
      Apply a Visitor to this instruction. We invoke the appropriate Visitor method according to the type of this instruction.
      Specified by:
      visit in interface IInstruction
      Specified by:
      visit in class Instruction
      Throws:
      IllegalArgumentException
    • isPEI

      public boolean isPEI()
      Description copied from interface: IInstruction
      PEI == "Potentially excepting instruction"
      Returns:
      true iff this instruction might throw an exception