use of ast.Util.PathMwt in project L42 by ElvisResearchGroup.
the class Translator method useFrom.
//this should take a class, strip out nested and 'from' it so that it is as at top level
static ClassB useFrom(ClassB ct, Path p) {
ArrayList<Member> ms = new ArrayList<Member>();
for (Member m : ct.getMs()) {
m.match(nc -> null, mi -> {
throw Assertions.codeNotReachable();
}, mt -> ms.add(From.from(mt, p)));
}
//for(PathMwt pmwt:ct.getStage().getInherited()){
for (PathMwt pmwt : Collections.<PathMwt>emptyList()) {
if (Functions.getIfInDom(ms, pmwt.getMwt().getMs()).isPresent()) {
continue;
}
ms.add(From.from(pmwt.getMwt(), p));
}
List<Path> sup = tools.Map.of(ti -> (Path) From.fromP(ti.getPath(), p), ct.getSupertypes());
//tools.Map.of(pi->(Path)From.fromP(pi,p),ct.getStage().getInheritedPaths());
List<Path> supAll = sup;
ClassB res = ct.withMs(ms).withSupertypes(tools.Map.of(pi -> pi.toImmNT(), sup));
return res;
}
Aggregations