modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
Anfang Paare zusammenfassen
This commit is contained in:
parent
fc14cf9893
commit
27c6351aed
@ -583,7 +583,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (printtag) System.out.println("eq2s " + eq2s);
|
||||
//writeLog("BufferSet: " + bufferSet.toString()+"\n");
|
||||
List<Set<Set<UnifyPair>>> oderConstraintsOutput = new ArrayList<>();//new ArrayList<>(oderConstraints);
|
||||
Set<Set<Set<Set<UnifyPair>>>> secondLevelSets = calculatePairSets(eq2s, oderConstraints, fc, undefinedPairs, oderConstraintsOutput);
|
||||
Set<Set<UnifyPair>> collectErr = new HashSet<>();
|
||||
Set<Set<Set<Set<UnifyPair>>>> secondLevelSets = calculatePairSets(eq2s, oderConstraints, fc, undefinedPairs, oderConstraintsOutput, collectErr);
|
||||
//PL 2017-09-20: Im calculatePairSets wird möglicherweise O .< java.lang.Integer
|
||||
//nicht ausgewertet Faculty Beispiel im 1. Schritt
|
||||
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
|
||||
@ -1727,7 +1728,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
* from the pairs that matched the case. Each generated set contains singleton sets or sets with few elements
|
||||
* (as in case 1 where sigma is added to the innermost set).
|
||||
*/
|
||||
protected Set<Set<Set<Set<UnifyPair>>>> calculatePairSets(Set<UnifyPair> eq2s, List<Set<Set<UnifyPair>>> oderConstraintsInput, IFiniteClosure fc, Set<UnifyPair> undefined, List<Set<Set<UnifyPair>>> oderConstraintsOutput) {
|
||||
protected Set<Set<Set<Set<UnifyPair>>>> calculatePairSets(Set<UnifyPair> eq2s, List<Set<Set<UnifyPair>>> oderConstraintsInput, IFiniteClosure fc, Set<UnifyPair> undefined, List<Set<Set<UnifyPair>>> oderConstraintsOutput, Set<Set<UnifyPair>> collectErr) {
|
||||
oderConstraintsOutput.addAll(oderConstraintsInput);
|
||||
List<Set<Set<Set<UnifyPair>>>> result = new ArrayList<>(9);
|
||||
|
||||
@ -1811,6 +1812,42 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
x1.remove(remElem);
|
||||
}
|
||||
//System.out.println(x1);
|
||||
Set<UnifyPair> sameEqSet = eq2sAsList.stream()
|
||||
.filter(x -> ((x.getLhsType().equals(lhsType) || x.getRhsType().equals(lhsType)) && !x.equals(pair)))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
Set<Set<UnifyPair>> x2 = x1;
|
||||
for (UnifyPair sameEq : sameEqSet) {
|
||||
writeLog("x1 Original:\n" + x1.toString());
|
||||
if (sameEq.getLhsType() instanceof PlaceholderType) {
|
||||
x1 = x1.stream().filter(y -> {
|
||||
UnifyPair type = y.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get();
|
||||
Set<UnifyPair> localEq = new HashSet<>();
|
||||
localEq.add(new UnifyPair(type.getRhsType(), sameEq.getRhsType(), sameEq.getPairOp()));
|
||||
Set<Set<UnifyPair>> localRes = unify(localEq, new ArrayList<>(), fc, parallel, 0);
|
||||
Boolean localCorr = !isUndefinedPairSetSet(localRes);
|
||||
if (!localCorr) {
|
||||
collectErr.addAll(localRes);
|
||||
}
|
||||
return localCorr;
|
||||
}
|
||||
).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
else {
|
||||
x1 = x1.stream().filter(y -> {
|
||||
UnifyPair type = y.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get();
|
||||
Set<UnifyPair> localEq = new HashSet<>();
|
||||
localEq.add(new UnifyPair(sameEq.getLhsType(), type.getRhsType(), sameEq.getPairOp()));
|
||||
Set<Set<UnifyPair>> localRes = unify(localEq, new ArrayList<>(), fc, parallel, 0);
|
||||
Boolean localCorr = !isUndefinedPairSetSet(localRes);
|
||||
if (!localCorr) {
|
||||
collectErr.addAll(localRes);
|
||||
}
|
||||
return localCorr;
|
||||
}
|
||||
).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
writeLog("x1 nach Lösung von " + sameEq.toString()+" :\n" + x1.toString());
|
||||
}
|
||||
result.get(0).add(x1);
|
||||
if (x1.isEmpty()) {
|
||||
undefined.add(pair); //Theta ist nicht im FC => Abbruch
|
||||
@ -1919,6 +1956,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
|
||||
// Filter empty sets or sets that only contain an empty set.
|
||||
writeLog("collectErr: " + collectErr);
|
||||
return result.stream().map(x -> x.stream().filter(y -> y.size() > 0).collect(Collectors.toCollection(HashSet::new)))
|
||||
.filter(x -> x.size() > 0).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user