use of ast.Util.PathSPath 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.Util.PathSPath 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.Util.PathSPath 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