use of ast.Ast.Header in project L42 by ElvisResearchGroup.
the class CloneVisitor method visit.
public Expression visit(ClassB s) {
Header h = liftH(s.getH());
List<FieldDec> fs = Map.of(this::liftF, s.getFields());
List<Type> superT = Map.of(this::liftT, s.getSupertypes());
List<Member> ms = Map.of(this::liftM, s.getMs());
return new ClassB(liftDoc(s.getDoc1()), h, fs, superT, ms, s.getP());
}
use of ast.Ast.Header 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());
}
use of ast.Ast.Header in project L42 by ElvisResearchGroup.
the class ToAst method visitClassB.
@Override
public Expression visitClassB(ClassBContext ctx) {
//the number 1 if present is ignored
Doc doc1 = parseDoc(ctx.docsOpt().get(0));
Header h = parseHeader(ctx.header());
List<Type> supertypes = new ArrayList<>();
ImplsContext impl = ctx.impls();
if (impl != null) {
{
int i = -1;
for (TerminalNode p : impl.Path()) {
i += 1;
supertypes.add(Path.sugarParse(nameU(p)).toImmNT().withDoc(parseDoc(impl.docsOpt().get(0))));
}
}
}
List<Member> ms = visitMembers(ctx.member());
List<Ast.FieldDec> fs = new ArrayList<>();
for (FieldDecContext f : ctx.fieldDec()) {
fs.add(parseFieldDec(f));
}
return new Expression.ClassB(doc1, h, fs, supertypes, ms, position(ctx));
}
Aggregations