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
This commit is contained in:
Martin Plümicke 2019-01-25 22:19:32 +01:00
parent 25487469c7
commit 3c0beabc1b
2 changed files with 46 additions and 4 deletions

View File

@ -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)) {

View File

@ -810,6 +810,23 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
nextSetasListRest.remove(a_next);
}
}
//Alle maximale Elemente in nextSetasListRest bestimmen
List<Set<UnifyPair>> nextSetasListRestTest;
do {
nextSetasListRestTest = new ArrayList<Set<UnifyPair>>(nextSetasListRest);
if (!nextSetasListRest.isEmpty()) {
Set<UnifyPair> max = oup.max(nextSetasListRest.iterator());
Iterator<Set<UnifyPair>> nextSetasListItRest2 = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
while (nextSetasListItRest2.hasNext()) {
Set<UnifyPair> 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<Set<Set<UnifyPair>>> {
nextSetasListRest.remove(a_next);
}
}
//Alle minimalen Elemente in nextSetasListRest bestimmen
List<Set<UnifyPair>> nextSetasListRestTest;
do {
nextSetasListRestTest = new ArrayList<Set<UnifyPair>>(nextSetasListRest);
if (!nextSetasListRest.isEmpty()) {
Set<UnifyPair> min = oup.min(nextSetasListRest.iterator());
Iterator<Set<UnifyPair>> nextSetasListItRest2 = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
while (nextSetasListItRest2.hasNext()) {
Set<UnifyPair> 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<Set<Set<UnifyPair>>> {
for(UnifyType c : csPHRenamed) {
//PL 18-02-05 getChildren durch smaller ersetzt in getChildren werden die Varianlen nicht ersetzt.
Set<UnifyType> thetaQs = fc.smaller(c, new HashSet<>()).stream().collect(Collectors.toCollection(HashSet::new));
Set<UnifyType> thetaQs = new HashSet<>();
//TODO smaller wieder reinnehmen?
//thetaQs.add(c);//
thetaQs = fc.smaller(c, new HashSet<>()).stream().collect(Collectors.toCollection(HashSet::new));
//Set<UnifyType> 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<...>> <. 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<Set<Set<UnifyPair>>> {
if(allGen) {
UnifyPair up = new UnifyPair(a, theta, PairOperator.EQUALSDOT, pair.getSubstitution(), pair);
Iterator<UnifyType> 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<UnifyType> 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);