use of ast.ExpCore.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class _Aux method getNestedList.
static void getNestedList(ExpCore.ClassB cb, List<Ast.C> cs, List<ExpCore.ClassB.NestedClass> result) {
Ast.C nName = cs.get(0);
int index = getIndex(cb.getMs(), nName);
checkIndex(index);
NestedClass nc = (NestedClass) cb.getMs().get(index);
result.add(nc);
if (cs.size() != 1) {
getNestedList(wrapCast(nc.getInner()), cs.subList(1, cs.size()), result);
}
}
use of ast.ExpCore.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class ErrorFormatter method printType.
private static void printType(int i, String prefix, ClassB top) {
System.out.print("This" + i + prefix + " :{\n");
printMembers(top);
System.out.print(" }\n");
for (Member m : top.getMs()) {
if (!(m instanceof NestedClass)) {
continue;
}
NestedClass nc = (NestedClass) m;
if (nc.getInner() instanceof ClassB) {
printType(i, "." + nc.getName(), (ClassB) nc.getInner());
}
}
}
use of ast.ExpCore.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method plgComplete.
public static ClassB plgComplete(List<Ast.C> cs, Program p, ClassB l) throws UnresolvedOverloading, ClassUnfit, MethodUnfit {
//p.top() is topL
List<Member> ms = new ArrayList<>();
for (Member m : l.getMs()) {
if (!(m instanceof NestedClass)) {
ms.add(m);
continue;
}
NestedClass nc = (NestedClass) m;
List<Ast.C> csc = new ArrayList<>(cs);
csc.add(nc.getName());
ms.add(nc.withInner(plgComplete(csc, p, (ClassB) nc.getInner())));
}
return plgComplete1(cs, p, l.withMs(ms));
//forall nested c in l
// l=l[with c=plgComplete(cs:c, p,l.c)
//return plgComplete1(cs,p,l)
}
use of ast.ExpCore.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class Compose method alradyRefreshedCompose.
public static ClassB alradyRefreshedCompose(PData p, ClassB a, ClassB b) {
if (a.isInterface() || b.isInterface()) {
assert false;
}
List<Type> impls = new ArrayList<>(a.getSupertypes());
for (Type ti : b.getSupertypes()) {
impls.remove(ti);
}
impls.addAll(b.getSupertypes());
List<MethodWithType> mwts = new ArrayList<>(a.mwts());
for (MethodWithType mwti : b.mwts()) {
Functions._findAndRemove(mwts, mwti.getMs());
}
for (MethodWithType mwti : b.mwts()) {
mwts.add(sumMwt(_extractMwt(mwti, a.mwts()), mwti));
}
List<NestedClass> ncs = new ArrayList<>(a.ns());
for (NestedClass nci : b.ns()) {
Functions._findAndRemove(ncs, nci.getName());
}
for (NestedClass nci : b.ns()) {
NestedClass ncj = _extractNc(nci, a.ns());
if (ncj == null) {
ncs.add(nci);
} else {
ClassB l = alradyRefreshedCompose(p, (ClassB) nci.getE(), (ClassB) ncj.getE());
ncs.add(nci.withE(l));
}
}
return new ClassB(a.getDoc1().sum(b.getDoc1()), false, impls, mwts, ncs, a.getP().sum(b.getP()), Phase.Norm, p.p.getFreshId());
}
use of ast.ExpCore.ClassB.NestedClass in project L42 by ElvisResearchGroup.
the class Translator method add.
public static void add(int level, List<Ast.C> cs, ClassB cb, Map<String, ClassB> map, Program original) {
Ast.Path p = Ast.Path.outer(level, cs);
if (cb.getPhase() == Phase.Coherent && IsCompiled.of(cb)) {
//otherwise is "meta"
//assert cb.getStage().getInheritedPaths()!=null;
ClassB cbUF = useFrom(cb, p);
if (!cs.isEmpty()) {
//ok to ignore empty ones, since not complete?
map.put(Resources.nameOf(level, cs), cbUF);
}
} else {
//generate only for metaprogramming //Can be ignored now with typemap
/*ExpCore.ClassB cbMP = new ExpCore.ClassB(
Doc.factory("##@DebugInfo: is interface since (cb.getStage()!=Stage.Star :"
+(cb.getStage().getStage()!=Stage.Star)+") or since !IsCompiled.of(cb) :"+!IsCompiled.of(cb)+")"
),Doc.empty(),true,Collections.emptyList(),Collections.emptyList(),new Util.CachedStage());
cbMP.getStage().setInheritedPaths(Collections.emptyList());
cbMP.getStage().setInherited(Collections.emptyList());
assert cbMP.getStage().getInheritedPaths()!=null;
map.put(Resources.nameOf(level,cs),cbMP);
*/
}
for (Member m : cb.getMs()) {
if (!(m instanceof NestedClass)) {
continue;
}
NestedClass nc = (NestedClass) m;
if (!(nc.getInner() instanceof ClassB)) {
continue;
}
if (cs.isEmpty() && level > 0) {
if (nc.getInner() == original.get(level - 1)) {
continue;
}
//avoid generation of multiple versions of the same thing
}
ArrayList<Ast.C> newCs = new ArrayList<>(cs);
newCs.add(nc.getName());
add(level, newCs, (ClassB) nc.getInner(), map, original);
}
}
Aggregations