use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Redirect method accumulateVerified.
/*private static void lessEqual(List<PathSPath> ambiguities, List<PathPath> verified) {
Iterator<PathSPath> it = ambiguities.iterator();
while(it.hasNext()){
Path pi=it.next().getPath();
for(PathPath pp:verified){if(pp.getPath1().equals(pi)){it.remove();}}
}
}*/
private static void accumulateVerified(List<PathSPath> ambiguities, List<PathPath> verified) {
assert ambiguitiesOk(ambiguities);
for (PathPath pp : verified) {
PathSPath psp = selectPSP(ambiguities, pp.getPath1());
if (psp == null) {
continue;
}
//ambiguities.add(new PathSPath(pp.getPath1(),Arrays.asList(pp.getPath2())));
if (psp.getPathsSet().contains(pp.getPath2())) {
ambiguities.remove(psp);
} else {
List<Path> ps = new ArrayList<>(psp.getPathsSet());
ps.add(pp.getPath2());
throw Errors42.errorIncoherentRedirectMapping(verified, ambiguities, psp.getPath(), ps);
}
}
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Redirect method plusEqualAndExc.
private static boolean plusEqualAndExc(List<PathSPath> ambiguities, List<SPathSPath> exceptions, Path src, MethodWithType mwtSrc, MethodWithType mwtDest) {
int countExternal = 0;
int countExternalSatisfied = 0;
List<Path> srcExc = Map.of(t -> t.getPath(), mwtSrc.getMt().getExceptions());
List<Path> destExc = Map.of(t -> t.getPath(), mwtDest.getMt().getExceptions());
exceptions.add(new SPathSPath(src, mwtSrc, mwtDest));
for (Path pi : srcExc) {
if (pi.isPrimitive() || pi.outerNumber() > 0) {
countExternal += 1;
if (destExc.contains(pi)) {
countExternalSatisfied += 1;
}
continue;
}
plusEqual(ambiguities, pi, destExc);
}
int countInternal = srcExc.size() - countExternal;
return countInternal + countExternalSatisfied >= destExc.size();
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Redirect method checkExceptionOk.
private static void checkExceptionOk(List<SPathSPath> exceptions, List<PathPath> verified) {
for (SPathSPath exc : exceptions) {
List<Path> src = Map.of(t -> traspose(verified, t.getPath()), exc.getMwt1().getMt().getExceptions());
//was: src=Map.of(pi->traspose(verified,pi),src); and now is merged on top
List<Path> other = Map.of(t -> t.getPath(), exc.getMwt2().getMt().getExceptions());
if (!src.containsAll(other)) {
throw Errors42.errorMethodClash(exc.getSrc().getCBar(), exc.getMwt1(), exc.getMwt2(), true, Collections.emptyList(), false, false, false);
}
}
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class ToAst method parseType.
private Type parseType(TContext t) {
if (t.concreteT() != null) {
ConcreteTContext tt = t.concreteT();
Doc d = parseDoc(tt.docsOpt());
Ast.Type nt = new Ast.Type(Mdf.fromString((tt.Mdf() == null) ? "" : nameK(tt.Mdf())), Ast.Path.sugarParse(nameU(tt.Path())), d);
if (tt.Ph() == null) {
return nt;
}
return Functions.toPh(nt);
}
if (t.historicalT() != null) {
HistoricalTContext tt = t.historicalT();
Doc d = parseDoc(tt.docsOpt());
Path p = ast.Ast.Path.sugarParse(nameU(tt.Path()));
List<MethodSelectorX> mss = new ArrayList<MethodSelectorX>();
for (HistoricalSeqContext ms : tt.historicalSeq()) {
mss.add(parseMethSelectorX(ms));
}
//return new ast.Ast.HistoricType(p,mss,d);
throw Assertions.codeNotReachable();
}
throw Assertions.codeNotReachable();
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Errors42 method errorIncoherentRedirectMapping.
/* static void checkCoherentMapping(List<PathPath> setVisited) {
// setVisited is a set of individual redirected classes,
// created by walking the sub-tree under each cascade redirect.
// getPath1() is the path in the library before redirecting.
// getPath2() is the proposed path in the redirected library.
// We will allow many paths to be redirected into a single new path,
// but not vice-versa.
for(PathPath p1:setVisited){
for(PathPath p2:setVisited){
if(p1.equals(p2)){continue;}
if(p1.getPath1().equals(p2.getPath1())){
throw errorIncoherentRedirectMapping(setVisited, p1.getPath1(),p1.getPath2(),p2.getPath2());
}
}
}
return;
}*/
static Error errorIncoherentRedirectMapping(List<PathPath> verified, List<PathSPath> ambiguities, Path incoSrc, List<Path> _incoDest) {
Doc src = Doc.empty();
Doc dest = Doc.empty();
//Doc ambig=Doc.empty();
for (PathPath v : verified) {
src = src.sum(formatPathIn(v.getPath1().getCBar()));
dest = dest.sum(formatPathOut(v.getPath2()));
}
for (PathSPath a : ambiguities) {
//if(a.getPaths().size()!=1){
// ambig=ambig.sum(formatPathIn(a.getPath().getCBar()));
// ambig=ambig.sum(Doc.factory("@"+a.getPaths().size()));
// }
Doc srci = formatPathIn(a.getPath().getCBar());
for (Path pij : a.getPathsSet()) {
src = src.sum(srci);
dest = dest.sum(formatPathOut(pij));
}
}
Doc incoDest = Doc.empty();
for (Path pi : _incoDest) {
incoDest = incoDest.sum(formatPathOut(pi));
}
return Resources.Error.multiPartStringError("IncoherentRedirectMapping", "Src", src.formatNewLinesAsList(), "Dest", dest.formatNewLinesAsList(), //"Ambiguities",ambig.formatNewLinesAsList(),
"IncoherentSrc", incoSrc == null ? Doc.empty() : formatPathIn(incoSrc.getCBar()), "IncoherentDest", incoDest.formatNewLinesAsList());
}
Aggregations