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 InjectionOnSugar method visit.
@Override
public Expression visit(Using s) {
List<String> xs = s.getS().getNames();
List<ast.ExpCore> es1 = s.getEs();
List<ast.Expression> es = new ArrayList<ast.Expression>();
for (ast.ExpCore e : es1) {
es.add(lift(e));
}
ast.Ast.Parameters ps = new ast.Ast.Parameters(Optional.<ast.Expression>empty(), xs, es);
return new Expression.Using(s.getPath(), s.getS().nameToS(), s.getDoc(), ps, lift(s.getInner()));
}
use of ast.Expression in project L42 by ElvisResearchGroup.
the class InjectionOnSugar method visit.
@Override
public Expression visit(ClassB s) {
Doc doc1 = s.getDoc1();
Header h = (s.isInterface()) ? new Ast.InterfaceHeader() : new Ast.TraitHeader();
List<Type> supertypes = s.getSupertypes();
List<Member> members = new ArrayList<>();
for (ast.ExpCore.ClassB.Member mi : s.getMs()) {
members.add(mi.match(nc -> new Expression.ClassB.NestedClass(nc.getDoc(), nc.getName(), lift(nc.getInner()), nc.getP()), mimpl -> new Expression.ClassB.MethodImplemented(mimpl.getDoc(), mimpl.getS(), lift(mimpl.getInner()), mimpl.getP()), mwt -> {
Doc idoc = mwt.getDoc();
MethodSelector is = mwt.getMs();
MethodType mt = mwt.getMt();
return new Expression.ClassB.MethodWithType(idoc, is, mt, lift(mwt.get_inner()), mwt.getP());
}));
}
return new Expression.ClassB(doc1, h, Collections.emptyList(), supertypes, members, s.getP());
}
Aggregations