Exemplo n.º 1
0
  @Override
  public void visit(Tree.WhileStatement that) {
    Tree.WhileClause whileClause = that.getWhileClause();
    Tree.ConditionList conditionList = whileClause.getConditionList();
    Tree.ConditionList cl = conditionList;
    if (cl != null) {
      cl.visit(this);
    }

    boolean d = beginDeclarationScope();
    SpecificationState as = beginSpecificationScope();
    Tree.Block block = whileClause.getBlock();
    if (block != null) {
      if (isVariable() || isLate()) {
        block.visit(this);
      } else {
        boolean c = inLoop;
        inLoop = true;
        block.visit(this);
        inLoop = c;
      }
    }
    boolean possiblyAssignedByWhileClause = specified.possibly;
    boolean definitelyAssignedByWhileClause = specified.definitely;

    endDeclarationScope(d);
    endSpecificationScope(as);

    specified.definitely =
        specified.definitely
            || (definitelyAssignedByWhileClause && isAlwaysSatisfied(conditionList));
    specified.possibly =
        specified.possibly || (possiblyAssignedByWhileClause && !isNeverSatisfied(conditionList));

    checkDeclarationSection(that);
  }
Exemplo n.º 2
0
  @Override
  public void visit(Tree.IfStatement that) {
    if (that == lastContinueStatement) {
      lastContinueStatement = null;
    }

    Tree.IfClause ifClause = that.getIfClause();
    Tree.ConditionList conditionList = ifClause.getConditionList();
    if (ifClause != null) {
      Tree.ConditionList cl = conditionList;
      if (cl != null) {
        cl.visit(this);
      }
    }

    boolean d = beginDeclarationScope();
    SpecificationState as = beginSpecificationScope();
    if (ifClause != null) {
      Tree.Block block = ifClause.getBlock();
      if (block != null) {
        block.visit(this);
      }
    }
    boolean definitelyAssignedByIfClause = specified.definitely || specified.exited;
    boolean possiblyAssignedByIfClause = specified.possibly;
    boolean possiblyExitedFromIfClause = specified.exited;
    boolean specifiedByExitsFromIfClause = specified.byExits;
    endDeclarationScope(d);
    endSpecificationScope(as);

    boolean definitelyAssignedByElseClause;
    boolean possiblyAssignedByElseClause;
    boolean possiblyExitedFromElseClause;
    boolean specifiedByExitsFromElseClause;
    Tree.ElseClause elseClause = that.getElseClause();
    if (elseClause != null) {
      d = beginDeclarationScope();
      as = beginSpecificationScope();
      elseClause.visit(this);
      definitelyAssignedByElseClause = specified.definitely || specified.exited;
      possiblyAssignedByElseClause = specified.possibly;
      possiblyExitedFromElseClause = specified.exited;
      specifiedByExitsFromElseClause = specified.byExits;
      endDeclarationScope(d);
      endSpecificationScope(as);
    } else {
      definitelyAssignedByElseClause = false;
      possiblyAssignedByElseClause = false;
      possiblyExitedFromElseClause = false;
      specifiedByExitsFromElseClause = true;
    }

    if (isAlwaysSatisfied(conditionList)) {
      specified.definitely = specified.definitely || definitelyAssignedByIfClause;
      specified.possibly = specified.possibly || possiblyAssignedByIfClause;
      specified.exited = specified.exited || possiblyExitedFromIfClause;
      specified.byExits = specified.byExits && specifiedByExitsFromIfClause;
    } else if (isNeverSatisfied(conditionList)) {
      specified.definitely = specified.definitely || definitelyAssignedByElseClause;
      specified.possibly = specified.possibly || possiblyAssignedByElseClause;
      specified.exited = specified.exited || possiblyExitedFromElseClause;
      specified.byExits = specified.byExits && specifiedByExitsFromElseClause;
    } else {
      specified.definitely =
          specified.definitely || definitelyAssignedByIfClause && definitelyAssignedByElseClause;
      specified.possibly =
          specified.possibly || possiblyAssignedByIfClause || possiblyAssignedByElseClause;
      specified.exited =
          specified.exited || possiblyExitedFromIfClause || possiblyExitedFromElseClause;
      specified.byExits =
          specified.byExits && specifiedByExitsFromIfClause && specifiedByExitsFromElseClause;
    }

    checkDeclarationSection(that);
  }