modified: ../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
vor entfernung von Remaining
This commit is contained in:
parent
e00d76ce3b
commit
d8ac25234f
@ -623,15 +623,20 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* @return The set of all principal type unifiers
|
* @return The set of all principal type unifiers
|
||||||
*/
|
*/
|
||||||
Set<Set<UnifyPair>> computeCartesianRecursive(ArrayList<Set<? extends Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
Set<Set<UnifyPair>> computeCartesianRecursive(ArrayList<Set<? extends Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
||||||
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
|
||||||
|
//fstElems: Alle 1-elementigen Mengen, die nur ein Paar
|
||||||
|
//a <. theta, theta <. a oder a =. theta enthalten
|
||||||
Set<Set<UnifyPair>> fstElems = new HashSet<>();
|
Set<Set<UnifyPair>> fstElems = new HashSet<>();
|
||||||
fstElems.addAll(topLevelSets.stream()
|
fstElems.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
|
||||||
ArrayList<Set<? extends Set<UnifyPair>>> remainingSets = topLevelSets.stream()
|
ArrayList<Set<? extends Set<UnifyPair>>> remainingSets = topLevelSets.stream()
|
||||||
.filter(x -> x.size()>1)
|
.filter(x -> x.size()>1)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
writeLog("Anzahl der Elemente von Remaining: " + remainingSets.size());
|
||||||
if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig
|
if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig
|
||||||
Set<Set<UnifyPair>> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe);
|
Set<Set<UnifyPair>> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe);
|
||||||
return result;
|
return result;
|
||||||
@ -713,8 +718,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/* 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 fstElems */
|
||||||
Set<UnifyPair> sameEqSet = new HashSet<>();
|
Set<UnifyPair> sameEqSet = new HashSet<>();
|
||||||
|
|
||||||
|
//optOrigPair enthaelt ggf. das Paar a = ty \in nextSet
|
||||||
Optional<UnifyPair> optOrigPair = null;
|
Optional<UnifyPair> optOrigPair = null;
|
||||||
//if (variance != 2) {
|
|
||||||
if (!oderConstraint) {
|
if (!oderConstraint) {
|
||||||
optOrigPair = nextSetElem.stream().filter(x -> (
|
optOrigPair = nextSetElem.stream().filter(x -> (
|
||||||
//x.getBasePair() != null && ist gegeben wenn variance != 2
|
//x.getBasePair() != null && ist gegeben wenn variance != 2
|
||||||
@ -750,11 +756,18 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
while (nextSetasList.size() > 0) {
|
while (nextSetasList.size() > 0) {
|
||||||
Set<UnifyPair> a_last = a;
|
Set<UnifyPair> a_last = a;
|
||||||
|
|
||||||
//Liste der Faelle für die parallele Verarbeitung
|
/* Liste der Faelle für die parallele Verarbeitung
|
||||||
|
* Enthaelt Elemente, die nicht in Relation zu aktuellem Fall in der
|
||||||
|
* Variablen a stehen. Diese muesse auf alle Faelle bearbeitet werden,
|
||||||
|
* Deshalb wird ihre Berechnung parallel angestossen.
|
||||||
|
*/
|
||||||
List<Set<UnifyPair>> nextSetasListRest = new ArrayList<>();
|
List<Set<UnifyPair>> nextSetasListRest = new ArrayList<>();
|
||||||
|
|
||||||
//Liste der Faelle, bei dem Receiver jeweils "? extends" enthaelt bzw. nicht enthaelt
|
/* Liste der Faelle, bei dem Receiver jeweils "? extends" enthaelt bzw. nicht enthaelt
|
||||||
//In der Regel is dies ein Element
|
* In der Regel ist dies genau ein Element
|
||||||
|
* Dieses Element wird später aus nextSetasList geloescht, wenn das jeweils andere Element zum Erfolg
|
||||||
|
* gefuehrt hat.
|
||||||
|
*/
|
||||||
List<Set<UnifyPair>> nextSetasListOderConstraints = new ArrayList<>();
|
List<Set<UnifyPair>> nextSetasListOderConstraints = new ArrayList<>();
|
||||||
|
|
||||||
writeLog("nextSet: " + nextSet.toString());
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
@ -777,6 +790,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Alle maximale Elemente in nextSetasListRest bestimmen
|
//Alle maximale Elemente in nextSetasListRest bestimmen
|
||||||
|
//nur für diese wird parallele Berechnung angestossen.
|
||||||
nextSetasListRest = oup.maxElements(nextSetasListRest);
|
nextSetasListRest = oup.maxElements(nextSetasListRest);
|
||||||
}
|
}
|
||||||
else if (variance == -1) {
|
else if (variance == -1) {
|
||||||
@ -797,10 +811,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Alle minimalen Elemente in nextSetasListRest bestimmen
|
//Alle minimalen Elemente in nextSetasListRest bestimmen
|
||||||
|
//nur für diese wird parallele Berechnung angestossen.
|
||||||
nextSetasListRest = oup.minElements(nextSetasListRest);
|
nextSetasListRest = oup.minElements(nextSetasListRest);
|
||||||
}
|
}
|
||||||
else if (variance == 2) {
|
else if (variance == 2) {
|
||||||
a = nextSetasList.remove(0);
|
a = nextSetasList.remove(0);
|
||||||
|
|
||||||
|
//Fuer alle Elemente wird parallele Berechnung angestossen.
|
||||||
nextSetasListRest = new ArrayList<>(nextSetasList);
|
nextSetasListRest = new ArrayList<>(nextSetasList);
|
||||||
}
|
}
|
||||||
else if (variance == 0) {
|
else if (variance == 0) {
|
||||||
@ -826,20 +843,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//writeLog("nextSet: " + nextSetasList.toString()+ "\n");
|
|
||||||
//nextSetasList.remove(a);
|
|
||||||
|
|
||||||
//PL 2018-03-01
|
|
||||||
//TODO: 1. Maximum und Minimum unterscheiden
|
|
||||||
//TODO: 2. compare noch für alle Elmemente die nicht X =. ty sind erweitern
|
|
||||||
//for(Set<UnifyPair> a : newSet) {
|
|
||||||
i++;
|
i++;
|
||||||
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
|
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
|
||||||
writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n");
|
writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n");
|
||||||
//elems.add(a); PL 2019-01-20 Muss weg, weil das in jeweiligen Thread erfolgen muss. Fuer den sequentiellen Fall
|
|
||||||
//im else-Zweig
|
|
||||||
//if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt
|
|
||||||
//writeLog("Vor unify2 Aufruf: " + elems.toString());
|
|
||||||
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<>();
|
||||||
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
||||||
@ -1553,7 +1560,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
result.addAll(localRes);
|
result.addAll(localRes);
|
||||||
}
|
}
|
||||||
//writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1571,12 +1578,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
result.addAll(localRes);
|
result.addAll(localRes);
|
||||||
}
|
}
|
||||||
//writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//writeLog("TRUE: " + aPair + "sameEqSet: " + sameEqSet);
|
writeLog("TRUE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user