From 615983bf37a97cc78d0bb98b31fe8398848a56ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Fri, 13 Apr 2018 18:13:31 +0200 Subject: [PATCH] modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java resuat add in cartesion angepasst modified: src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java modified: src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java equals in UnfyPair auf UndefinedPairs angepasst --- .../typeinference/unify/TypeUnifyTask.java | 26 +++++++++++++++---- .../typeinference/unify/model/Unifier.java | 3 ++- .../typeinference/unify/model/UnifyPair.java | 7 +++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index a66c4626..386f3e72 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -318,7 +318,7 @@ public class TypeUnifyTask extends RecursiveTask>> { */ eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new)); if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet)) - writeLog("Result " + eqPrimePrimeSet.toString()); + writeLog("Result1 " + eqPrimePrimeSet.toString()); return eqPrimePrimeSet; } @@ -419,10 +419,25 @@ public class TypeUnifyTask extends RecursiveTask>> { elems.add(a); if (remainingSets.isEmpty()) { Set> res = unify2(elems, eq, fc, parallel); - if (!isUndefinedPairSetSet(res)) {// && isUndefinedPairSetSet(result)) {//wenn korektes Ergebnis gefunden alle Fehlerfaelle loeschen - result = new HashSet<>(); + if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) { + //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen + result = res; } - result.addAll(res); + else { + if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) + || (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) + || result.isEmpty()) { + //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + result.addAll(res); + } + //else { + //wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren + // if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) { + // result = result; + // } + //} + } + } else {//duerfte gar nicht mehr vorkommen PL 2018-04-03 result.addAll(computeCartesianRecursive(elems, remainingSets, eq, fc, parallel)); @@ -475,9 +490,10 @@ public class TypeUnifyTask extends RecursiveTask>> { return (!x.containsAll(durchschnitt)); }).collect(Collectors.toCollection(ArrayList::new)); writeLog("abhSubst: " + abhSubst.toString()); + writeLog("a: " + a.toString()); + writeLog("Durchschnitt: " + durchschnitt.toString()); writeLog("nextSet: " + nextSet.toString()); writeLog("nextSetasList: " + nextSetasList.toString()); - writeLog("Durchschnitt: " + durchschnitt.toString()); System.out.println(""); } //if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) { diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java b/src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java index 8aa03a77..dfb88bc7 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java @@ -81,7 +81,8 @@ public class Unifier implements Function, Iterable suniUnifyPair = new HashSet<>(); suniUnifyPair.addAll(thisAsPair.getAllSubstitutions()); suniUnifyPair.add(thisAsPair); - if (p.getLhsType() instanceof PlaceholderType && newLhs instanceof PlaceholderType && p.getPairOp() == PairOperator.EQUALSDOT) { + if (p.getLhsType() instanceof PlaceholderType //&& newLhs instanceof PlaceholderType entfernt PL 2018-04-13 + && p.getPairOp() == PairOperator.EQUALSDOT) { suniUnifyPair.add(p); //p koennte auch subsitution sein } return new UnifyPair(newLhs, newRhs, p.getPairOp(), suniUnifyPair, p); diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java b/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java index dd24c28d..cabfbcc1 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java @@ -148,6 +148,13 @@ public class UnifyPair { UnifyPair other = (UnifyPair) obj; + if (isUndefinedPair()) { + if (!other.getBasePair().equals(basePair) || + !other.getAllSubstitutions().equals(getAllSubstitutions())) { + return false; + } + } + return other.getPairOp() == pairOp && other.getLhsType().equals(lhs) && other.getRhsType().equals(rhs);