forked from JavaTX/JavaCompilerCore
modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
Loesung Fehler rausgemacht
This commit is contained in:
parent
a733f373a7
commit
1931c61392
@ -452,8 +452,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||
System.out.print("");
|
||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||
Set<UnifyPair> a = null;
|
||||
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
||||
Set<UnifyPair> a = null;
|
||||
Set<UnifyPair> a_last = a;
|
||||
if (variance == 1) {
|
||||
a = oup.max(nextSetasList.iterator());
|
||||
nextSetasList.remove(a);
|
||||
@ -491,7 +492,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
//for(Set<UnifyPair> a : newSet) {
|
||||
i++;
|
||||
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
|
||||
Set<UnifyPair> a_last = a;
|
||||
elems.add(a);
|
||||
//if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt
|
||||
//writeLog("Vor unify2 Aufruf: " + eq.toString());
|
||||
@ -504,11 +504,57 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result))
|
||||
|| (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result))
|
||||
|| result.isEmpty()) {
|
||||
|
||||
if (!result.isEmpty() && !res.isEmpty() && !isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
||||
|
||||
//Alle Variablen bestimmen die nicht hinzugefügt wurden in a
|
||||
List<PlaceholderType> vars_a = a.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new));
|
||||
Set<UnifyPair> fstElemRes = res.iterator().next();
|
||||
Set<UnifyPair> compRes = fstElemRes.stream().filter(x -> vars_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
//Alle Variablen bestimmen die nicht hinzugefügt wurden in a_last
|
||||
List<PlaceholderType> varsLast_a = a_last.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new));
|
||||
//erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen
|
||||
Set<UnifyPair> fstElemResult = result.iterator().next();
|
||||
Set<UnifyPair> compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));;
|
||||
|
||||
if (variance == 1) {
|
||||
int resOfCompare = oup.compare(compResult, compRes);
|
||||
if (resOfCompare == -1) {
|
||||
writeLog("Geloescht result: " + result);
|
||||
result = res;
|
||||
} else {
|
||||
if (resOfCompare == 0) {
|
||||
result.addAll(res);
|
||||
} //else {
|
||||
if (resOfCompare == 1) {
|
||||
writeLog("Geloescht res: " + res);
|
||||
//result = result;
|
||||
}}}
|
||||
else { if (variance == -1) {
|
||||
int resOfCompare = oup.compare(compResult, compRes);
|
||||
if (resOfCompare == 1) {
|
||||
writeLog("Geloescht result: " + result);
|
||||
result = res;
|
||||
} else {
|
||||
if (resOfCompare == 0) {
|
||||
result.addAll(res);
|
||||
} else {
|
||||
if (resOfCompare == -1) {
|
||||
writeLog("Geloescht res: " + res);
|
||||
//result = result;
|
||||
}}}}
|
||||
else { if (variance == 0) {
|
||||
result.addAll(res);
|
||||
}}}
|
||||
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
||||
a_last.stream().filter(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())));
|
||||
result.addAll(res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.addAll(res);
|
||||
}
|
||||
}
|
||||
//else {
|
||||
//wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren
|
||||
// if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
||||
|
Loading…
Reference in New Issue
Block a user