All Superinterfaces:
ICCompound, ICConditionalStatement, ICElement, ICStatement

@Ser public interface ICIfStm extends ICConditionalStatement
C AST interface to represent a conditional "if" statement.

An if-statement consists of one or more branches (if, else-if) followed by an optional default branch (else) block.

Example:

 if(p)
   b
 else if(p1)
   b1
 else
   b2
 
  • Method Details

    • getBranchPredicates

      List<? extends ICPredicate> getBranchPredicates()
      Get the predicates. Warning, this is the actual list of predicates, not a copy. Caution should be exercised when modifying it
      Returns:
      the original list of predicates
    • getBranchPredicate

      ICPredicate getBranchPredicate(int index)
    • setBranchPredicate

      void setBranchPredicate(int index, ICPredicate p)
    • getBranchBody

      ICBlock getBranchBody(int index)
    • setBranchBody

      void setBranchBody(int index, ICBlock b)
    • addBranch

      void addBranch(ICPredicate p, ICBlock b)
      Add an alternative block (if or else-if) to this element.
      Parameters:
      p - mandatory predicate
      b - mandatory statement
    • insertBranch

      void insertBranch(int index, ICPredicate p, ICBlock b)
    • removeBranch

      void removeBranch(int index)
    • setDefaultBlock

      void setDefaultBlock(ICBlock b)
      Description copied from interface: ICConditionalStatement
      Set the default block of code.
      Specified by:
      setDefaultBlock in interface ICConditionalStatement
      Parameters:
      b - optional block, set to null to remove the default block
    • removeDefaultBlock

      default ICBlock removeDefaultBlock()
      Remove the default block, if there one, and return it.
      Returns:
      the default block (null if there was none)
    • duplicate

      ICIfStm duplicate()
      Description copied from interface: ICElement
      Deep duplication of the element. Sub-elements are duplicated.

      Note: ICClass, ICMethod, ICField, ICIdentifier, ICConstant, ICType and ICLabel are not duplicated.

      Specified by:
      duplicate in interface ICCompound
      Specified by:
      duplicate in interface ICConditionalStatement
      Specified by:
      duplicate in interface ICElement
      Specified by:
      duplicate in interface ICStatement