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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations