From 3c0beabc1b1a27855b9279a250be07fccb2399d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Fri, 25 Jan 2019 22:19:32 +0100 Subject: [PATCH 1/3] modified: src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java reduce2 nochmals angepasst modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java - Fehler behoben - In den Thread nur noch Element von nextSet verschieben, die auf alle Faele berechnet werdne muessen --- .../typeinference/unify/RuleSet.java | 3 +- .../typeinference/unify/TypeUnifyTask.java | 47 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index a3430577..a8c0675d 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -326,7 +326,8 @@ public class RuleSet implements IRuleSet{ lhsSType = (ReferenceType) lhsType; rhsSType = (ReferenceType) rhsType; } - else if ((lhsType instanceof WildcardType) && (rhsType instanceof WildcardType)) { + else if (((lhsType instanceof ExtendsType) && (rhsType instanceof ExtendsType)) + || ((lhsType instanceof SuperType) && (rhsType instanceof SuperType))) { UnifyType lhsSTypeRaw = ((WildcardType) lhsType).getWildcardedType(); UnifyType rhsSTypeRaw = ((WildcardType) rhsType).getWildcardedType(); if ((lhsSTypeRaw instanceof ReferenceType) && (rhsSTypeRaw instanceof ReferenceType)) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 8b2c7c3c..da3d508b 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -810,6 +810,23 @@ public class TypeUnifyTask extends RecursiveTask>> { nextSetasListRest.remove(a_next); } } + //Alle maximale Elemente in nextSetasListRest bestimmen + List> nextSetasListRestTest; + do { + nextSetasListRestTest = new ArrayList>(nextSetasListRest); + if (!nextSetasListRest.isEmpty()) { + Set max = oup.max(nextSetasListRest.iterator()); + Iterator> nextSetasListItRest2 = new ArrayList>(nextSetasListRest).iterator(); + while (nextSetasListItRest2.hasNext()) { + Set a_nextRest = nextSetasListItRest2.next(); + if (//a.equals(a_next) || + (oup.compare(max, a_nextRest) == 1)) { + nextSetasListRest.remove(a_nextRest); + } + + }} + } while(!nextSetasListRestTest.equals(nextSetasListRest)); + } else if (variance == -1) { a = oup.min(nextSetasList.iterator()); @@ -823,6 +840,23 @@ public class TypeUnifyTask extends RecursiveTask>> { nextSetasListRest.remove(a_next); } } + //Alle minimalen Elemente in nextSetasListRest bestimmen + + List> nextSetasListRestTest; + do { + nextSetasListRestTest = new ArrayList>(nextSetasListRest); + if (!nextSetasListRest.isEmpty()) { + Set min = oup.min(nextSetasListRest.iterator()); + Iterator> nextSetasListItRest2 = new ArrayList>(nextSetasListRest).iterator(); + while (nextSetasListItRest2.hasNext()) { + Set a_nextRest = nextSetasListItRest2.next(); + if (//a.equals(a_next) || + (oup.compare(min, a_nextRest) == -1)) { + nextSetasListRest.remove(a_nextRest); + } + + }} + } while(!nextSetasListRestTest.equals(nextSetasListRest)); } else if (variance == 2) { a = nextSetasList.remove(0); @@ -1860,13 +1894,17 @@ public class TypeUnifyTask extends RecursiveTask>> { for(UnifyType c : csPHRenamed) { //PL 18-02-05 getChildren durch smaller ersetzt in getChildren werden die Varianlen nicht ersetzt. - Set thetaQs = fc.smaller(c, new HashSet<>()).stream().collect(Collectors.toCollection(HashSet::new)); + Set thetaQs = new HashSet<>(); + //TODO smaller wieder reinnehmen? + //thetaQs.add(c);// + thetaQs = fc.smaller(c, new HashSet<>()).stream().collect(Collectors.toCollection(HashSet::new)); //Set thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new)); //thetaQs.add(thetaPrime); //PL 18-02-05 wieder geloescht //PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert, //da children offensichtlich ein echtes kleiner und kein kleinergleich ist //PL 18-02-06: eingefuegt, thetaQs der Form V> <. V'> werden entfernt + //TODO PL 19-01-14 wieder reinnehmen kurzfristig auskommentiert thetaQs = thetaQs.stream().filter(ut -> ut.getTypeParams().arePlaceholders()).collect(Collectors.toCollection(HashSet::new)); //PL 18-02-06: eingefuegt @@ -1931,13 +1969,16 @@ public class TypeUnifyTask extends RecursiveTask>> { if(allGen) { UnifyPair up = new UnifyPair(a, theta, PairOperator.EQUALSDOT, pair.getSubstitution(), pair); Iterator upit = up.getRhsType().getTypeParams().iterator(); - while (upit.hasNext()) ((PlaceholderType)upit.next()).setVariance(a.getVariance()); + //TODO PL 2019-01-24: upit.next() ist nicht unbedingt ein PlaceholderType -> Visitor + while (upit.hasNext()) upit.next().accept(new distributeVariance(), a.getVariance());//((PlaceholderType)upit.next()).setVariance(a.getVariance()); resultPrime.add(up); } else { UnifyPair up = new UnifyPair(a, theta.setTypeParams(new TypeParams(freshTphs.toArray(new UnifyType[0]))), PairOperator.EQUALSDOT, pair.getSubstitution(), pair); Iterator upit = up.getRhsType().getTypeParams().iterator(); - while (upit.hasNext()) ((PlaceholderType)upit.next()).setVariance(a.getVariance()); + distributeVariance dv = new distributeVariance(); + //TODO PL 2019-01-24: upit.next() ist nicht unbedingt ein PlaceholderType -> Visitor + while (upit.hasNext()) upit.next().accept(new distributeVariance(), a.getVariance()); //((PlaceholderType)upit.next()).setVariance(a.getVariance()); resultPrime.add(up); } resultPrime.addAll(substitutionSet); From 9dcb1f76cab606a7356b4baaa3a5590d8a9fb427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Fri, 25 Jan 2019 22:22:16 +0100 Subject: [PATCH 2/3] modified: src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java --- .../de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java index a5919c18..dc600939 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java @@ -17,7 +17,7 @@ public class UnifyResultModel { listeners.remove(listenerToRemove); } - public void notify(ResultSet newResult) { + public void notify(Set newResult) { UnifyResultEvent evt = new UnifyResultEvent(newResult); for (UnifyResultListener listener : listeners) { From 26634bb03842b55e9884b85c01d65ceb911e310e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Fri, 25 Jan 2019 22:26:38 +0100 Subject: [PATCH 3/3] modified: src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java --- .../de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java index dc600939..fe72bfea 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/UnifyResultModel.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.typeinference.unify; import java.util.ArrayList; import java.util.List; +import java.util.Set; import de.dhbwstuttgart.typeinference.result.ResultSet; @@ -17,7 +18,7 @@ public class UnifyResultModel { listeners.remove(listenerToRemove); } - public void notify(Set newResult) { + public void notify(List newResult) { UnifyResultEvent evt = new UnifyResultEvent(newResult); for (UnifyResultListener listener : listeners) {