use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Functions method originDecOf.
public static Path originDecOf(Program p, MethodSelector ms, ClassB cb) /*normalized*/
{
assert cb.getPhase().subtypeEq(Phase.Norm);
for (Path pi : cb.getSuperPaths()) {
ClassB cbi = p.extractClassB(pi);
MethodWithType m = (MethodWithType) cbi._getMember(ms);
if (m != null && !m.getMt().isRefine()) {
return pi;
}
}
throw Assertions.codeNotReachable();
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class FindPathUsage method liftT.
public Type liftT(Type s) {
Path inner = s.getPath();
if (s.toString().endsWith("Location")) {
System.out.println(s);
}
Ast.Position pos = ctxPos();
locate(inner, pos);
return s;
//add using
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Norm method norm.
public ExpCore.ClassB norm(Program p) {
//-norm(p)={interface? implements Ps' norm(p,Ms') }
//p.top()={interface? implements Ps Ms} //Ms is free var and is ok
ClassB l = p.top();
//Ps'=collect(p,Ps)
List<Path> ps1 = Methods.collect(p, l.getSuperPaths());
//Ms'=methods(p,This0), {C:e in Ms} //norm now put all the nested classes in the back.
List<ClassB.Member> ms1 = Stream.concat(p.methods(Path.outer(0)).stream(), l.getMs().stream().filter(m -> m instanceof ClassB.NestedClass)).map(m -> norm(p, m)).collect(Collectors.toList());
//return l.withSupertypes(ps1).withMs(ms1).withUniqueId(p.getFreshId()).withPhase(Phase.Norm);
return new ClassB(l.getDoc1(), l.isInterface(), Map.of(pi -> pi.toImmNT(), ps1), ms1, l.getP(), Phase.Norm, p.getFreshId());
}
use of ast.Ast.Path 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.Ast.Path in project L42 by ElvisResearchGroup.
the class _Sum method sumMethod.
static MethodWithType sumMethod(MethodWithType ma, MethodWithType mb) {
Set<Path> pa = new HashSet<Path>(Map.of(t -> t.getPath(), ma.getMt().getExceptions()));
Set<Path> pb = new HashSet<Path>(Map.of(t -> t.getPath(), mb.getMt().getExceptions()));
Set<Path> pc = new HashSet<>(pa);
pc.retainAll(pb);
Doc doc = ma.getDoc().sum(mb.getDoc());
MethodType mt = ma.getMt();
List<Ast.Type> opc = pc.stream().map(pi -> (Ast.Type) pi.toImmNT()).collect(Collectors.toList());
Collections.sort(opc, (p1, p2) -> p1.toString().compareTo(p2.toString()));
mt = mt.withExceptions(opc);
MethodWithType mwt = ma.withMt(mt).withDoc(doc);
//now mwt has min exceptions and summed docs
assert !ma.get_inner().isPresent() || !mb.get_inner().isPresent();
if (mb.get_inner().isPresent()) {
mwt = mwt.withInner(mb.getInner());
}
return mwt;
}
Aggregations