use of ast.Expression in project L42 by ElvisResearchGroup.
the class TestHelper method getExpCore.
public static ExpCore getExpCore(String source, String _e1) {
Expression code1 = Parser.parse("GeneratedByTestHelper_", _e1);
Expression code2 = Desugar.of(code1);
ExpCore e1 = code2.accept(new InjectionOnCore());
return e1;
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class TestHelper method getProgram.
public static Program getProgram(/*List<Path> paths,*/
String[] code) {
Program p0 = Program.emptyLibraryProgram();
Integer outerCount = code.length;
for (String s : code) {
Expression e = Parser.parse("This" + outerCount, s);
--outerCount;
ClassB ec = (ClassB) Desugar.of(e).accept(new InjectionOnCore());
p0 = p0.evilPush(ec);
}
return p0;
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class TestHelper method getClassB.
public static ClassB getClassB(String source, String e1) {
Expression code1 = Parser.parse("GeneratedByTestHelper_" + source, e1);
auxiliaryGrammar.WellFormedness.checkAll(code1);
Expression code2 = Desugar.of(code1);
assert auxiliaryGrammar.WellFormedness.checkAll(code2);
ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
return code3;
}
use of ast.Expression 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.Expression 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));
}
Aggregations