Search in sources :

Example 26 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Methods method collect.

static List<Ast.Path> collect(Program p, List<Ast.Path> p0ps, List<Ast.Path> visited) {
    if (p0ps.isEmpty()) {
        return p0ps;
    }
    Ast.Path p0 = p0ps.get(0);
    List<Ast.Path> ps = p0ps.subList(1, p0ps.size());
    if (visited.contains(p0)) {
        throw new ast.ErrorMessage.CircularImplements(push(visited, p0));
    }
    if (p0.isPrimitive()) {
        return collect(p, ps, visited);
    }
    ClassB l = p.extractClassB(p0);
    List<Path> superPaths = l.getSuperPaths();
    List<Ast.Path> recP0 = collect(p.navigate(p0), superPaths, push(visited, p0));
    recP0 = Map.of(pi -> From.fromP(pi, p0), recP0);
    List<Ast.Path> recPs = collect(p, ps, visited);
    return mergeUnique(p0, recP0, recPs);
}
Also used : Path(ast.Ast.Path) From(coreVisitors.From) Ast(ast.Ast) Path(ast.Ast.Path) Map(tools.Map) Set(java.util.Set) HashMap(java.util.HashMap) Member(ast.ExpCore.ClassB.Member) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Collectors(java.util.stream.Collectors) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) ClassB(ast.ExpCore.ClassB) Entry(java.util.Map.Entry) Collections(java.util.Collections) Ast(ast.Ast) Path(ast.Ast.Path) ClassB(ast.ExpCore.ClassB)

Example 27 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class MultiTypeSystem method typeLibrary.

private static ClassB typeLibrary(List<List<Ast.C>> current0, List<List<Ast.C>> current1, Program p) {
    ClassB result = p.top();
    for (List<Ast.C> csi : current0) {
        Program pi = p.navigate(csi);
        assert pi.top().getPhase() != Phase.None : "";
        ClassB li = typeSingle(Phase.Typed, pi);
        result = result.onClassNavigateToPathAndDo(csi, oldLi -> li);
    }
    for (List<Ast.C> csi : current1) {
        Program pi = p.navigate(csi);
        assert pi.top().getPhase() != Phase.None : "";
        ClassB li = typeSingle(Phase.Coherent, pi);
        result = result.onClassNavigateToPathAndDo(csi, oldLi -> li);
    }
    return result;
}
Also used : CloneVisitor(coreVisitors.CloneVisitor) Stage(ast.Ast.Stage) List(java.util.List) ClassB(ast.ExpCore.ClassB) Ast(ast.Ast) Type(ast.Ast.Type) Phase(ast.ExpCore.ClassB.Phase) ExpCore(ast.ExpCore) MethodWithType(ast.ExpCore.ClassB.MethodWithType) ArrayList(java.util.ArrayList) ClassB(ast.ExpCore.ClassB)

Example 28 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class MultiTypeSystem method typeProgram.

public static Program typeProgram(Paths paths0, Paths paths1, Program p) {
    if (paths0.isEmpty() && paths1.isEmpty()) {
        return p;
    }
    if (p instanceof FlatProgram) {
        assert paths0.pop().isEmpty() && paths1.pop().isEmpty();
        return p.updateTop(typeLibrary(paths0.top(), paths1.top(), p));
    }
    Program p0 = typeProgram(paths0.pop(), paths1.pop(), p.pop());
    Program p1 = p.growFellow(p0);
    ClassB l = typeLibrary(paths0.top(), paths1.top(), p1);
    return p1.updateTop(l);
}
Also used : ClassB(ast.ExpCore.ClassB)

Example 29 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Norm method normMwt.

protected MethodWithType normMwt(Program p, MethodWithType mwt) {
    MethodType mt = mwt.getMt();
    Optional<ExpCore> e = mwt.get_inner().map(e1 -> e1.accept(new CloneVisitor() {

        @Override
        public ExpCore visit(ClassB cb) {
            return norm(p.evilPush(cb));
        }
    }));
    return mwt.withMt(mt).with_inner(e);
}
Also used : MethodType(ast.Ast.MethodType) ExpCore(ast.ExpCore) CloneVisitor(coreVisitors.CloneVisitor) ClassB(ast.ExpCore.ClassB)

Example 30 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class EncodingHelper method _extractStringU.

public static String _extractStringU(Object e) {
    if (e instanceof String) {
        return (String) e;
    }
    if (!(e instanceof ClassB)) {
        return null;
    }
    ClassB cb = (ClassB) e;
    String code = extractCode(cb, "@stringU\n");
    if (code == null) {
        return null;
    }
    return EncodingHelper.parseStringUnicode(code);
}
Also used : ClassB(ast.ExpCore.ClassB)

Aggregations

ClassB (ast.ExpCore.ClassB)107 ArrayList (java.util.ArrayList)33 Path (ast.Ast.Path)30 ExpCore (ast.ExpCore)25 Member (ast.ExpCore.ClassB.Member)25 EncodingHelper.ensureExtractClassB (auxiliaryGrammar.EncodingHelper.ensureExtractClassB)20 Program (programReduction.Program)20 Ast (ast.Ast)19 MethodWithType (ast.ExpCore.ClassB.MethodWithType)19 MethodSelector (ast.Ast.MethodSelector)18 NestedClass (ast.ExpCore.ClassB.NestedClass)18 List (java.util.List)17 ActionType (platformSpecific.fakeInternet.ActionType)16 Doc (ast.Ast.Doc)12 Type (ast.Ast.Type)12 ErrorMessage (ast.ErrorMessage)12 Optional (java.util.Optional)10 C (ast.Ast.C)9 MethodType (ast.Ast.MethodType)8 Phase (ast.ExpCore.ClassB.Phase)8