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