Search in sources :

Example 46 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class PluginWithPart method execute.

public Object execute(Program p, Using u) {
    assert false : "is this not called with compilation?";
    //rest of implementation is wrong
    Method method = ProtectedPluginType.getMethod(pointed, p, u.getS().nameToS(), u.getS().getNames().size(), u);
    List<ExpCore> es = u.getEs();
    ExpCore rec = null;
    if ((method.getModifiers() & Modifier.STATIC) == 0) {
        rec = es.get(0);
        es = es.subList(1, es.size());
    }
    return ProtectedPluginType.executeMethod(method, p, rec, es.toArray());
}
Also used : ExpCore(ast.ExpCore) Method(java.lang.reflect.Method)

Example 47 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class Resources method isValid.

public static boolean isValid(Program p, Object res, Object[] xs) {
    if (L42.trustPluginsAndFinalProgram) {
        return true;
    }
    ExpCore ec0 = Revertable.doRevert(res);
    List<ExpCore> es = new ArrayList<>();
    for (Object o : xs) {
        es.add(Revertable.doRevert(o));
    }
    boolean strict = true;
    for (ExpCore ec : es) {
        List<ClassB> cbs = CollectClassBs0.of(ec);
        List<Path> ps = CollectPaths0.of(ec);
        for (ClassB cb : cbs) {
            if (!cb.getPhase().subtypeEq(Phase.Typed)) {
                strict = false;
            }
        }
        for (Path path : ps) {
            if (path.isPrimitive()) {
                continue;
            }
            ClassB extracted = p.extractClassB(path);
            if (!extracted.getPhase().subtypeEq(Phase.Typed)) {
                strict = false;
            }
        }
    }
    List<ClassB> cbs = CollectClassBs0.of(ec0);
    for (ClassB cb : cbs) {
        try {
            newTypeSystem.TypeSystem.instance().topTypeLib(Phase.Typed, p.evilPush(cb));
        } catch (ErrorMessage msg) {
            System.err.println("__________PLUGIN error identified_________");
            //to breakpoint here
            throw msg;
        }
    }
    return true;
}
Also used : Path(ast.Ast.Path) ExpCore(ast.ExpCore) ArrayList(java.util.ArrayList) ErrorMessage(ast.ErrorMessage) ClassB(ast.ExpCore.ClassB)

Example 48 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class OnLineCodeHelper method pluginType.

//Unuseful variant, since program not availabe at desugaring time
public static List<Type> pluginType(Program p, Expression.Using u) {
    MethodSelector ms = MethodSelector.of(u.getName(), u.getPs().getXs());
    ExpCore.Using uCore = new ExpCore.Using(u.getPath(), ms, Doc.empty(), Collections.emptyList(), new ExpCore._void());
    return plugin(p, uCore).typeOf(p, uCore);
}
Also used : ExpCore(ast.ExpCore) MethodSelector(ast.Ast.MethodSelector) Using(ast.ExpCore.Using) Using(ast.ExpCore.Using)

Example 49 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class ProgramReduction method top.

private static Program top(Program p, NestedClass nc) {
    ExpCore ec = nc.getInner();
    assert IsCompiled.of(ec);
    assert !(ec instanceof ClassB);
    System.out.println("Top running on nc:" + nc.getName());
    PathsPaths pair = UsedPaths.usedPathsECatchErrors(p, ec);
    Paths paths = pair.left;
    Paths paths1 = pair.right;
    Program p0 = Norm.multiNorm(p, paths.union(paths1));
    Program p1 = MultiTypeSystem.typeProgram(paths, paths1, p0);
    ExpCore annEc1 = MultiTypeSystem.typeMetaExp(p1, MultiTypeSystem.toAny(paths, ec));
    ClassB res = reduceE(p1, annEc1, C.of("NameDebug_" + nc.getName()));
    res = privateMangling.RefreshUniqueNames.refresh(res);
    ClassB top = p1.top();
    //would actually fail if not there
    assert top.getNested(Collections.singletonList(nc.getName())) != null;
    top = top.withMember(nc.withE(res));
    return p1.updateTop(top);
}
Also used : ExpCore(ast.ExpCore) ClassB(ast.ExpCore.ClassB)

Example 50 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class UsedPaths method deepImplements.

private static Paths deepImplements(ClassB l) {
    Paths res = Paths.reorganize(l.getSuperPaths());
    Paths acc = Paths.empty();
    for (Member mi : l.getMs()) {
        if (mi instanceof MethodWithType && !((MethodWithType) mi).get_inner().isPresent()) {
            continue;
        }
        ExpCore e = mi.getInner();
        for (ClassB cbij : CollectClassBs0.of(e)) {
            acc = acc.union(deepImplements(cbij));
        }
    }
    return res.union(acc.pop());
}
Also used : ExpCore(ast.ExpCore) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Aggregations

ExpCore (ast.ExpCore)62 ArrayList (java.util.ArrayList)25 ClassB (ast.ExpCore.ClassB)18 Member (ast.ExpCore.ClassB.Member)11 MethodWithType (ast.ExpCore.ClassB.MethodWithType)10 Expression (ast.Expression)10 Block (ast.ExpCore.Block)9 MethodType (ast.Ast.MethodType)8 Doc (ast.Ast.Doc)7 Path (ast.Ast.Path)7 Assertions (tools.Assertions)7 MethodSelector (ast.Ast.MethodSelector)6 Position (ast.Ast.Position)6 Program (programReduction.Program)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 Type (ast.Ast.Type)5 ErrorMessage (ast.ErrorMessage)5 CloneVisitor (coreVisitors.CloneVisitor)5 List (java.util.List)5