forked from JavaTX/JavaCompilerCore
modified: ../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
remaingSet entfernt fstElems in oneElems umbenannt
This commit is contained in:
parent
d8ac25234f
commit
1cf22d2602
@ -626,22 +626,21 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
//fstElems: Alle 1-elementigen Mengen, die nur ein Paar
|
//fstElems: Alle 1-elementigen Mengen, die nur ein Paar
|
||||||
//a <. theta, theta <. a oder a =. theta enthalten
|
//a <. theta, theta <. a oder a =. theta enthalten
|
||||||
Set<Set<UnifyPair>> fstElems = new HashSet<>();
|
Set<Set<UnifyPair>> oneElems = new HashSet<>();
|
||||||
fstElems.addAll(topLevelSets.stream()
|
oneElems.addAll(topLevelSets.stream()
|
||||||
.filter(x -> x.size()==1)
|
.filter(x -> x.size()==1)
|
||||||
.map(y -> y.stream().findFirst().get())
|
.map(y -> y.stream().findFirst().get())
|
||||||
.collect(Collectors.toCollection(HashSet::new)));
|
.collect(Collectors.toCollection(HashSet::new)));
|
||||||
|
|
||||||
//remainingSets: Alle mehrelementigen Mengen
|
//optNextSet: Eine mehrelementige Menge, wenn vorhanden
|
||||||
ArrayList<Set<? extends Set<UnifyPair>>> remainingSets = topLevelSets.stream()
|
Optional<Set<? extends Set<UnifyPair>>> optNextSet = topLevelSets.stream().filter(x -> x.size()>1).findAny();
|
||||||
.filter(x -> x.size()>1)
|
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
if (!optNextSet.isPresent()) {//Alle Elemente sind 1-elementig
|
||||||
writeLog("Anzahl der Elemente von Remaining: " + remainingSets.size());
|
Set<Set<UnifyPair>> result = unify2(oneElems, eq, oderConstraints, fc, parallel, rekTiefe);
|
||||||
if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig
|
|
||||||
Set<Set<UnifyPair>> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Set<? extends Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
|
||||||
|
Set<? extends Set<UnifyPair>> nextSet = optNextSet.get();
|
||||||
//writeLog("nextSet: " + nextSet.toString());
|
//writeLog("nextSet: " + nextSet.toString());
|
||||||
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
||||||
/*
|
/*
|
||||||
@ -716,7 +715,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair());
|
//writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair());
|
||||||
|
|
||||||
/* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet
|
/* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet
|
||||||
* alle Paare a < ty1 oder ty2 < a aus fstElems */
|
* alle Paare a < ty1 oder ty2 < a aus oneElems */
|
||||||
Set<UnifyPair> sameEqSet = new HashSet<>();
|
Set<UnifyPair> sameEqSet = new HashSet<>();
|
||||||
|
|
||||||
//optOrigPair enthaelt ggf. das Paar a = ty \in nextSet
|
//optOrigPair enthaelt ggf. das Paar a = ty \in nextSet
|
||||||
@ -744,7 +743,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
tyVar = origPair.getRhsType();
|
tyVar = origPair.getRhsType();
|
||||||
}
|
}
|
||||||
UnifyType tyVarEF = tyVar;
|
UnifyType tyVarEF = tyVar;
|
||||||
sameEqSet = fstElems.stream().map(xx -> xx.iterator().next())
|
sameEqSet = oneElems.stream().map(xx -> xx.iterator().next())
|
||||||
.filter(x -> (((x.getLhsType().equals(tyVarEF) && !(x.getRhsType() instanceof PlaceholderType))
|
.filter(x -> (((x.getLhsType().equals(tyVarEF) && !(x.getRhsType() instanceof PlaceholderType))
|
||||||
|| (x.getRhsType().equals(tyVarEF) && !(x.getLhsType() instanceof PlaceholderType)))))
|
|| (x.getRhsType().equals(tyVarEF) && !(x.getLhsType() instanceof PlaceholderType)))))
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
@ -845,7 +844,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
|
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(oneElems);
|
||||||
writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n");
|
writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n");
|
||||||
Set<Set<UnifyPair>> res = new HashSet<>();
|
Set<Set<UnifyPair>> res = new HashSet<>();
|
||||||
Set<Set<Set<UnifyPair>>> add_res = new HashSet<>();
|
Set<Set<Set<UnifyPair>>> add_res = new HashSet<>();
|
||||||
@ -853,6 +852,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
/* PL 2019-03-11 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
/* PL 2019-03-11 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
||||||
if (!oderConstraint && !sameEqSet.isEmpty()) {
|
if (!oderConstraint && !sameEqSet.isEmpty()) {
|
||||||
|
//optAPair enthaelt ggf. das Paar a = ty' \in a
|
||||||
|
//unterscheidet sich von optOrigPair, da dort a = ty
|
||||||
Optional<UnifyPair> optAPair = a.stream().filter(x -> (
|
Optional<UnifyPair> optAPair = a.stream().filter(x -> (
|
||||||
//x.getBasePair() != null && ist gegeben wenn variance != 2
|
//x.getBasePair() != null && ist gegeben wenn variance != 2
|
||||||
//x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT) &&
|
//x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT) &&
|
||||||
@ -871,7 +872,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a
|
if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a
|
||||||
UnifyPair aPair = optAPair.get();
|
UnifyPair aPair = optAPair.get();
|
||||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||||
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
writeLog("variance: " + variance + "sameEqSet:" + sameEqSet);
|
||||||
if (!checkA(aPair, sameEqSet, elems, result)) {
|
if (!checkA(aPair, sameEqSet, elems, result)) {
|
||||||
a = null;
|
a = null;
|
||||||
noShortendElements++;
|
noShortendElements++;
|
||||||
@ -1291,7 +1292,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
||||||
writeLog("RES Fst: reuslt: " + result.toString() + " res: " + res.toString());
|
writeLog("RES Fst: result: " + result.toString() + " res: " + res.toString());
|
||||||
result.addAll(res);
|
result.addAll(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1303,10 +1304,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
|
||||||
//else {//duerfte gar nicht mehr vorkommen PL 2018-04-03
|
|
||||||
//result.addAll(computeCartesianRecursive(elems, remainingSets, eq, fc, parallel));
|
|
||||||
//}
|
|
||||||
if (parallel) {
|
if (parallel) {
|
||||||
for (Set<Set<UnifyPair>> par_res : add_res) {
|
for (Set<Set<UnifyPair>> par_res : add_res) {
|
||||||
if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) {
|
if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user