Search in sources :

Example 6 with PathSPath

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);
        }
    }
}
Also used : PathPath(ast.Util.PathPath) PathSPath(ast.Util.PathSPath) SPathSPath(ast.Util.SPathSPath) CloneWithPath(coreVisitors.CloneWithPath) Path(ast.Ast.Path) PathSPath(ast.Util.PathSPath) SPathSPath(ast.Util.SPathSPath) PathPath(ast.Util.PathPath) ArrayList(java.util.ArrayList)

Example 7 with PathSPath

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();
}
Also used : PathPath(ast.Util.PathPath) PathSPath(ast.Util.PathSPath) SPathSPath(ast.Util.SPathSPath) CloneWithPath(coreVisitors.CloneWithPath) Path(ast.Ast.Path) SPathSPath(ast.Util.SPathSPath)

Example 8 with PathSPath

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());
}
Also used : PathPath(ast.Util.PathPath) PathSPath(ast.Util.PathSPath) Path(ast.Ast.Path) PathSPath(ast.Util.PathSPath) PathPath(ast.Util.PathPath) Doc(ast.Ast.Doc)

Aggregations

PathPath (ast.Util.PathPath)8 PathSPath (ast.Util.PathSPath)8 Path (ast.Ast.Path)7 SPathSPath (ast.Util.SPathSPath)7 CloneWithPath (coreVisitors.CloneWithPath)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)3 C (ast.Ast.C)2 Doc (ast.Ast.Doc)2 Type (ast.Ast.Type)2 ClassB (ast.ExpCore.ClassB)2 Member (ast.ExpCore.ClassB.Member)2 MethodWithType (ast.ExpCore.ClassB.MethodWithType)2 NestedClass (ast.ExpCore.ClassB.NestedClass)2 ClassKind (is.L42.connected.withSafeOperators.ExtractInfo.ClassKind)2 Ast (ast.Ast)1 Position (ast.Ast.Position)1 Stage (ast.Ast.Stage)1 ErrorMessage (ast.ErrorMessage)1 ExpCore (ast.ExpCore)1