Search in sources :

Example 11 with NestedClass

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);
    }
}
Also used : Ast(ast.Ast) NestedClass(ast.ExpCore.ClassB.NestedClass)

Example 12 with NestedClass

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());
        }
    }
}
Also used : NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 13 with NestedClass

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)
}
Also used : ArrayList(java.util.ArrayList) NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member)

Example 14 with NestedClass

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());
}
Also used : Type(ast.Ast.Type) MethodWithType(ast.ExpCore.ClassB.MethodWithType) ArrayList(java.util.ArrayList) NestedClass(ast.ExpCore.ClassB.NestedClass) MethodWithType(ast.ExpCore.ClassB.MethodWithType)

Example 15 with NestedClass

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);
    }
}
Also used : Ast(ast.Ast) Path(ast.Ast.Path) ArrayList(java.util.ArrayList) NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Aggregations

NestedClass (ast.ExpCore.ClassB.NestedClass)24 Member (ast.ExpCore.ClassB.Member)18 ArrayList (java.util.ArrayList)16 ClassB (ast.ExpCore.ClassB)12 Ast (ast.Ast)10 MethodWithType (ast.ExpCore.ClassB.MethodWithType)7 Path (ast.Ast.Path)5 ExpCore (ast.ExpCore)4 MethodImplemented (ast.ExpCore.ClassB.MethodImplemented)3 PathPath (ast.Util.PathPath)3 EncodingHelper.ensureExtractClassB (auxiliaryGrammar.EncodingHelper.ensureExtractClassB)3 List (java.util.List)3 C (ast.Ast.C)2 Position (ast.Ast.Position)2 Type (ast.Ast.Type)2 Phase (ast.ExpCore.ClassB.Phase)2 CloneVisitor (coreVisitors.CloneVisitor)2 HashSet (java.util.HashSet)2 Doc (ast.Ast.Doc)1 MethodSelector (ast.Ast.MethodSelector)1