Search in sources :

Example 1 with With

use of ast.Expression.With in project L42 by ElvisResearchGroup.

the class DesugarW method oldWith_noUseKw.

private void oldWith_noUseKw(SquareWithCall s, X xX, List<VarDec> decs) {
    List<With.On> ons = s.getWith().getOns();
    List<With.On> onsPrime = new ArrayList<>();
    for (With.On on : ons) {
        onsPrime.add(on.withInner(withSquareAdd(s.getP(), xX, on.getInner())));
    }
    Optional<Expression> def = s.getWith().getDefaultE();
    Optional<Expression> defPrime = Map.of(e -> withSquareAdd(s.getP(), xX, e), def);
    With w = s.getWith().withOns(onsPrime).withDefaultE(defPrime);
    decs.add(new VarDecE(w));
}
Also used : Expression(ast.Expression) ArrayList(java.util.ArrayList) On(ast.Expression.With.On) VarDecE(ast.Ast.VarDecE) On(ast.Expression.With.On) With(ast.Expression.With)

Example 2 with With

use of ast.Expression.With in project L42 by ElvisResearchGroup.

the class DesugarW method innerWithXs.

private static Expression innerWithXs(With e) {
    //right side of case b and part of right side of case d
    Expression inner = e.getDefaultE().get();
    List<String> xs = new ArrayList<String>(e.getXs());
    for (VarDecXE d : e.getDecs()) {
        xs.add(d.getX());
    }
    for (VarDecXE d : e.getIs()) {
        xs.add(d.getX());
    }
    inner = new With(e.getP(), xs, Collections.emptyList(), Collections.emptyList(), e.getOns(), e.getDefaultE());
    return inner;
}
Also used : Expression(ast.Expression) ArrayList(java.util.ArrayList) VarDecXE(ast.Ast.VarDecXE) With(ast.Expression.With)

Aggregations

Expression (ast.Expression)2 With (ast.Expression.With)2 ArrayList (java.util.ArrayList)2 VarDecE (ast.Ast.VarDecE)1 VarDecXE (ast.Ast.VarDecXE)1 On (ast.Expression.With.On)1