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)
|
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||||
System.out.print("");
|
System.out.print("");
|
||||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
|
Set<UnifyPair> a = null;
|
||||||
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
||||||
Set<UnifyPair> a = null;
|
Set<UnifyPair> a_last = a;
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
a = oup.max(nextSetasList.iterator());
|
a = oup.max(nextSetasList.iterator());
|
||||||
nextSetasList.remove(a);
|
nextSetasList.remove(a);
|
||||||
@ -491,7 +492,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//for(Set<UnifyPair> a : newSet) {
|
//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);
|
||||||
Set<UnifyPair> a_last = a;
|
|
||||||
elems.add(a);
|
elems.add(a);
|
||||||
//if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt
|
//if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt
|
||||||
//writeLog("Vor unify2 Aufruf: " + eq.toString());
|
//writeLog("Vor unify2 Aufruf: " + eq.toString());
|
||||||
@ -504,11 +504,57 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result))
|
if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result))
|
||||||
|| (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result))
|
|| (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result))
|
||||||
|| result.isEmpty()) {
|
|| 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
|
//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())));
|
else {
|
||||||
result.addAll(res);
|
result.addAll(res);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//else {
|
//else {
|
||||||
//wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren
|
//wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren
|
||||||
// if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
// if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user