use of ast.Expression.SquareCall in project L42 by ElvisResearchGroup.
the class DesugarW method visit.
public Expression visit(SquareWithCall s) {
//we can assumethe receivers are normalized after DesugarContext
assert s.getReceiver() instanceof Ast.Atom : s;
//(b=r.builder() b.a() b.b() b.c() .... b)
List<VarDec> vd = new ArrayList<>();
Expression k = Desugar.getMCall(s.getP(), s.getReceiver(), "#seqBuilder", Desugar.getPs());
String x = Functions.freshName("b", usedVars);
X b = new X(s.getP(), x);
vd.add(new VarDecXE(false, Optional.empty(), x, k));
Expression ew = s.getWith().accept(this);
ew = ew.accept(new CloneVisitor() {
@Override
public Expression visit(Expression.UseSquare u) {
SquareCall sq = (SquareCall) u.getInner();
//inner, hide external one to prevent use (was a bug before)
List<VarDec> vd = new ArrayList<>();
for (Parameters ps : sq.getPss()) {
vd.add(new VarDecE(Desugar.getMCall(s.getP(), b, "#add", ps)));
}
return Desugar.getBlock(s.getP(), vd, Expression._void.instance);
}
});
vd.add(new VarDecE(ew));
Expression inner = Desugar.getBlock(s.getP(), vd, b);
Parameters ps = new Parameters(Optional.empty(), Collections.singletonList("seqBuilder"), Collections.singletonList(inner));
return Desugar.getMCall(s.getP(), s.getReceiver(), "#from", ps);
}
Aggregations