use of ast.ExpCore.ClassB 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.ClassB in project L42 by ElvisResearchGroup.
the class OnLineCodeHelper method getL42Code.
static Expression.ClassB getL42Code(String url) {
try {
//can be classB or classBReuse
Expression data = load(url);
//TODO: can be removed later, but now allows librares to be real source code
data = Desugar.of(data);
// Configuration.reduction.of((ClassB) data.accept(new InjectionOnCore()));
return (Expression.ClassB) data;
} catch (org.antlr.v4.runtime.misc.ParseCancellationException pce) {
System.err.println("Url is: " + url);
throw pce;
}
}
use of ast.ExpCore.ClassB 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.ClassB 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());
}
use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.
the class _Sum method normalizedSum.
/*
private static void interfaceClash(Program p, ClassB candidate) {
try{
Configuration.typeSystem.computeStage(p,candidate);
}catch(ErrorMessage.IncoherentMwts i){
List<Path>ps=new ArrayList<>();
List<Member>mems=new ArrayList<>();
Path ph=Path.outer(0,i.getExploredPath());
for(PathMwt e:i.getIncoherent()){
ps.add(From.fromP(e.getOriginal(),ph));
}
assert !ps.isEmpty();
Member notInterf=null;
Program p1=p.addAtTop(candidate);
for(Path pi:ps){
ClassB cb=p1.extractCb(pi);
System.out.println(pi);
System.out.println(i);
System.out.println(cb.getStage());
System.out.println(candidate.getStage());
Optional<Member> currentOpt=Program.getIfInDom(cb.getMs(),i.getGuilty());
Member current=currentOpt.get();
if(cb.isInterface()){
mems.add(current);
}
else notInterf=current;
}
if(notInterf==null){
throw Errors42.errorClassClash(i.getExploredPath(), ps);
}
Member mb=mems.get(0);
throw Errors42.errorMethodClash(i.getExploredPath(), notInterf,mb, true,Collections.emptyList(),true,true,true);
}
}
*/
static ClassB normalizedSum(Program p, ClassB topA, ClassB topB, ClassB a, ClassB b, List<Ast.C> current) {
List<Member> ms = doubleSimetricalMatch(p, topA, topB, a, b, current);
List<ast.Ast.Type> superT = new ArrayList<>(a.getSupertypes());
superT.addAll(b.getSupertypes());
superT = Collections.unmodifiableList(superT);
Doc doc1 = a.getDoc1().sum(b.getDoc1());
//Sum.checkClassClash(p, current, topA, topB, a, b);
boolean isInterface = a.isInterface() || b.isInterface();
Phase accPhase = a.getPhase().acc(b.getPhase());
ExpCore.ClassB res = new ClassB(doc1, isInterface, superT, ms, CollapsePositions.accumulatePos(a.getP(), b.getP()), accPhase, accPhase == Phase.None ? 0 : 1);
res = (ClassB) res.accept(new coreVisitors.CloneVisitor() {
public ExpCore visit(ClassB s) {
if (s.getPhase() == Phase.None) {
return super.visit(s);
}
return super.visit(s.withPhase(accPhase));
}
});
//TODO: remove after new reduction introduced
return res;
}
Aggregations