Ejemplo n.º 1
0
  @Override
  public SStmCG caseAForPatternBindStm(AForPatternBindStm node, IRInfo question)
      throws AnalysisException {
    // Example for mk_(a,b) in [mk_(1,2), mk_(3,4)] do skip;
    PPattern pattern = node.getPatternBind().getPattern();
    PExp exp = node.getExp();
    PStm stm = node.getStatement();
    Boolean reverse = node.getReverse();

    SPatternCG patternCg = pattern.apply(question.getPatternVisitor(), question);
    SExpCG seqExpCg = exp.apply(question.getExpVisitor(), question);
    SStmCG stmCg = stm.apply(question.getStmVisitor(), question);

    AForAllStmCG forAll = new AForAllStmCG();
    forAll.setPattern(patternCg);
    forAll.setBody(stmCg);

    if (reverse != null && reverse) {
      AReverseUnaryExpCG reversedExp = new AReverseUnaryExpCG();
      reversedExp.setType(seqExpCg.getType().clone());
      reversedExp.setExp(seqExpCg);
      forAll.setExp(reversedExp);
    } else {
      forAll.setExp(seqExpCg);
    }

    return forAll;
  }
Ejemplo n.º 2
0
  @Override
  public SStmCG caseAForAllStm(AForAllStm node, IRInfo question) throws AnalysisException {
    // Example: for all x in set {1,2,3} do skip;
    PPattern pattern = node.getPattern();
    PExp set = node.getSet();
    PStm body = node.getStatement();

    SPatternCG patternCg = pattern.apply(question.getPatternVisitor(), question);
    SExpCG setExpCg = set.apply(question.getExpVisitor(), question);
    SStmCG bodyCg = body.apply(question.getStmVisitor(), question);

    AForAllStmCG forAll = new AForAllStmCG();
    forAll.setPattern(patternCg);
    forAll.setExp(setExpCg);
    forAll.setBody(bodyCg);

    return forAll;
  }