Class TableSwitch

All Implemented Interfaces:
Serializable, Stmt, Indexable

public class TableSwitch extends SwitchStmt
See Also:
  • Field Details

    • index

      protected int index
    • lineNumber

      protected int lineNumber
  • Constructor Details

    • TableSwitch

      public TableSwitch(Var var, int lowIndex, int highIndex)
  • Method Details

    • getLowIndex

      public int getLowIndex()
    • getHighIndex

      public int getHighIndex()
    • getCaseValues

      public List<Integer> getCaseValues()
      Specified by:
      getCaseValues in class SwitchStmt
      Returns:
      all case values of the switch statement. For example, for switch statement
       
       switch (x) {
           case 1: a = 1; break;
           case 3: a = 3; break;
           default: a = 0; break;
       }
       
       

      This API would return [1, 3].

    • getCaseTargets

      public List<Pair<Integer,Stmt>> getCaseTargets()
      Specified by:
      getCaseTargets in class SwitchStmt
      Returns:
      pairs of case value and the corresponding jump target. Default case is excluded. For example, for switch statement
       
       switch (x) {
           case 1: a = 1; break;
           case 3: a = 3; break;
           default: a = 0; break;
       }
       
       

      This API would return [(1, a = 1;), (3, a = 3;)].

    • accept

      public <T> T accept(StmtVisitor<T> visitor)
    • getInsnString

      public String getInsnString()
      Specified by:
      getInsnString in class SwitchStmt
    • getIndex

      public int getIndex()
      Specified by:
      getIndex in interface Indexable
      Specified by:
      getIndex in interface Stmt
      Returns:
      the index of this Stmt in the container IR.
    • setIndex

      public void setIndex(int index)
      Specified by:
      setIndex in interface Stmt
    • getLineNumber

      public int getLineNumber()
      Specified by:
      getLineNumber in interface Stmt
      Returns:
      the line number of this Stmt in the original source file. If the line number is unavailable, return -1.
    • setLineNumber

      public void setLineNumber(int lineNumber)
      Specified by:
      setLineNumber in interface Stmt
    • getDef

      public Optional<LValue> getDef()
      Specified by:
      getDef in interface Stmt
      Returns:
      the (optional) left-value expression defined in this Stmt. In Tai-e IR, each Stmt can define at most one expression.