use of ast.Ast.Parameters in project L42 by ElvisResearchGroup.
the class Desugar method visit1Step.
public MCall visit1Step(SquareCall s) {
//we can assumethe receivers are normalized after DesugarContext
//assert s.getReceiver() instanceof Ast.Atom: s.getReceiver();
//but nor really, since vars accesses are replaced by meth calls. In that case is fine to not have an atom.
//(b=r.builder() b.a() b.b() b.c() .... b)
List<VarDec> vd = new ArrayList<>();
Expression k = getMCall(s.getP(), s.getReceiver(), "#seqBuilder", getPs());
String x = Functions.freshName("b", usedVars);
X b = new X(s.getP(), x);
vd.add(new VarDecXE(false, Optional.empty(), x, k));
for (Parameters ps : s.getPss()) {
vd.add(new VarDecE(getMCall(s.getP(), b, "#add", ps)));
}
Expression inner = getBlock(s.getP(), vd, b);
Parameters ps = new Parameters(Optional.empty(), Collections.singletonList("seqBuilder"), Collections.singletonList(inner));
return getMCall(s.getP(), s.getReceiver(), "#from", ps);
}
use of ast.Ast.Parameters in project L42 by ElvisResearchGroup.
the class Desugar method liftPs.
protected Parameters liftPs(Parameters ps) {
if (!ps.getE().isPresent()) {
return liftPsPropagate(ps);
}
List<String> xs = new ArrayList<String>(ps.getXs());
List<Expression> es = new ArrayList<Expression>(ps.getEs());
xs.add(0, "that");
es.add(0, ps.getE().get());
return liftPsPropagate(new Parameters(Optional.empty(), xs, es));
}
use of ast.Ast.Parameters 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);
}
use of ast.Ast.Parameters in project L42 by ElvisResearchGroup.
the class DesugarContext method visit.
public Expression visit(SquareCall s) {
List<Parameters> pss = new ArrayList<>();
for (Parameters ps : s.getPss()) {
pss.add(ContextReplace.of(s.getP(), s.getReceiver(), "#square", ps));
}
s = s.withPss(pss);
return super.visit(s);
}
use of ast.Ast.Parameters in project L42 by ElvisResearchGroup.
the class ToAst method visitUsing.
@Override
public Expression visitUsing(UsingContext ctx) {
Path path = Ast.Path.sugarParse(nameU(ctx.Path()));
Expression inner = ctx.eTop().accept(this);
String name = nameL(ctx.mCall().m());
Parameters parameters = this.parseMParameters(ctx.mCall().round().ps());
Doc docs = parseDoc(ctx.mCall().round().docsOpt());
return new Expression.Using(path, name, docs, parameters, inner);
}
Aggregations