Class If

All Implemented Interfaces:
Serializable, Stmt, Indexable

public class If extends JumpStmt
Representation of if statement, e.g., if a == b goto S;
See Also:
  • Field Details

    • index

      protected int index
    • lineNumber

      protected int lineNumber
  • Constructor Details

  • Method Details

    • getCondition

      public ConditionExp getCondition()
      Returns:
      the condition expression of the if-statement.
    • getTarget

      public Stmt getTarget()
      Returns:
      the jump target (when the condition expression is evaluated to true) of the if-statement.
    • setTarget

      public void setTarget(Stmt target)
    • getUses

      public Set<RValue> getUses()
      Specified by:
      getUses in interface Stmt
      Returns:
      a list of right-value expressions used in this Stmt.
    • getTargets

      public List<Stmt> getTargets()
      Specified by:
      getTargets in class JumpStmt
      Returns:
      possible jump targets of this statement.
    • accept

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

      public String toString()
      Overrides:
      toString in class Object
    • 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.
    • canFallThrough

      public boolean canFallThrough()
      Specified by:
      canFallThrough in interface Stmt
      Returns:
      true if execution after this statement could continue at the following statement, otherwise false.