From 27c6351aedc34665592321f89f9d46dcc1c2d694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Fri, 1 Mar 2019 16:52:59 +0100 Subject: [PATCH] modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Anfang Paare zusammenfassen --- .../typeinference/unify/TypeUnifyTask.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 3ef3f8d4..fb4e14da 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -583,7 +583,8 @@ public class TypeUnifyTask extends RecursiveTask>> { if (printtag) System.out.println("eq2s " + eq2s); //writeLog("BufferSet: " + bufferSet.toString()+"\n"); List>> oderConstraintsOutput = new ArrayList<>();//new ArrayList<>(oderConstraints); - Set>>> secondLevelSets = calculatePairSets(eq2s, oderConstraints, fc, undefinedPairs, oderConstraintsOutput); + Set> collectErr = new HashSet<>(); + Set>>> secondLevelSets = calculatePairSets(eq2s, oderConstraints, fc, undefinedPairs, oderConstraintsOutput, collectErr); //PL 2017-09-20: Im calculatePairSets wird möglicherweise O .< java.lang.Integer //nicht ausgewertet Faculty Beispiel im 1. Schritt //PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren @@ -1727,7 +1728,7 @@ public class TypeUnifyTask extends RecursiveTask>> { * from the pairs that matched the case. Each generated set contains singleton sets or sets with few elements * (as in case 1 where sigma is added to the innermost set). */ - protected Set>>> calculatePairSets(Set eq2s, List>> oderConstraintsInput, IFiniteClosure fc, Set undefined, List>> oderConstraintsOutput) { + protected Set>>> calculatePairSets(Set eq2s, List>> oderConstraintsInput, IFiniteClosure fc, Set undefined, List>> oderConstraintsOutput, Set> collectErr) { oderConstraintsOutput.addAll(oderConstraintsInput); List>>> result = new ArrayList<>(9); @@ -1811,6 +1812,42 @@ public class TypeUnifyTask extends RecursiveTask>> { x1.remove(remElem); } //System.out.println(x1); + Set sameEqSet = eq2sAsList.stream() + .filter(x -> ((x.getLhsType().equals(lhsType) || x.getRhsType().equals(lhsType)) && !x.equals(pair))) + .collect(Collectors.toCollection(HashSet::new)); + Set> x2 = x1; + for (UnifyPair sameEq : sameEqSet) { + writeLog("x1 Original:\n" + x1.toString()); + if (sameEq.getLhsType() instanceof PlaceholderType) { + x1 = x1.stream().filter(y -> { + UnifyPair type = y.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get(); + Set localEq = new HashSet<>(); + localEq.add(new UnifyPair(type.getRhsType(), sameEq.getRhsType(), sameEq.getPairOp())); + Set> localRes = unify(localEq, new ArrayList<>(), fc, parallel, 0); + Boolean localCorr = !isUndefinedPairSetSet(localRes); + if (!localCorr) { + collectErr.addAll(localRes); + } + return localCorr; + } + ).collect(Collectors.toCollection(HashSet::new)); + } + else { + x1 = x1.stream().filter(y -> { + UnifyPair type = y.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get(); + Set localEq = new HashSet<>(); + localEq.add(new UnifyPair(sameEq.getLhsType(), type.getRhsType(), sameEq.getPairOp())); + Set> localRes = unify(localEq, new ArrayList<>(), fc, parallel, 0); + Boolean localCorr = !isUndefinedPairSetSet(localRes); + if (!localCorr) { + collectErr.addAll(localRes); + } + return localCorr; + } + ).collect(Collectors.toCollection(HashSet::new)); + } + writeLog("x1 nach Lösung von " + sameEq.toString()+" :\n" + x1.toString()); + } result.get(0).add(x1); if (x1.isEmpty()) { undefined.add(pair); //Theta ist nicht im FC => Abbruch @@ -1919,6 +1956,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } // Filter empty sets or sets that only contain an empty set. + writeLog("collectErr: " + collectErr); return result.stream().map(x -> x.stream().filter(y -> y.size() > 0).collect(Collectors.toCollection(HashSet::new))) .filter(x -> x.size() > 0).collect(Collectors.toCollection(HashSet::new)); }