forked from JavaTX/JavaCompilerCore
modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
Rekursionstife dokumentieten eingefuegt.
This commit is contained in:
parent
0a9e325f54
commit
3ce60eec8d
@ -168,7 +168,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
ArrayList<Set<Set<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
ArrayList<Set<Set<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
||||||
.filter(x -> x.size()>1)
|
.filter(x -> x.size()>1)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel);
|
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, 0);
|
||||||
if (isUndefinedPairSetSet(res)) { return new HashSet<>(); }
|
if (isUndefinedPairSetSet(res)) { return new HashSet<>(); }
|
||||||
else return res;
|
else return res;
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public Set<Set<UnifyPair>> computeCartesianRecursiveOderConstraints(Set<Set<UnifyPair>> fstElems, List<Set<Set<UnifyPair>>> topLevelSets, IFiniteClosure fc, boolean parallel) {
|
public Set<Set<UnifyPair>> computeCartesianRecursiveOderConstraints(Set<Set<UnifyPair>> fstElems, List<Set<Set<UnifyPair>>> topLevelSets, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
||||||
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
||||||
fstElems.addAll(topLevelSets.stream()
|
fstElems.addAll(topLevelSets.stream()
|
||||||
.filter(x -> x.size()==1)
|
.filter(x -> x.size()==1)
|
||||||
@ -196,7 +196,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig
|
if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig
|
||||||
Set<UnifyPair> eq = new HashSet<>();
|
Set<UnifyPair> eq = new HashSet<>();
|
||||||
fstElems.stream().forEach(x -> eq.addAll(x));
|
fstElems.stream().forEach(x -> eq.addAll(x));
|
||||||
Set<Set<UnifyPair>> result = unify(eq, new ArrayList<>(), fc, parallel);
|
Set<Set<UnifyPair>> result = unify(eq, new ArrayList<>(), fc, parallel, rekTiefe);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
||||||
@ -299,10 +299,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
System.out.println(noou);
|
System.out.println(noou);
|
||||||
Set<UnifyPair> eq = new HashSet<>();
|
Set<UnifyPair> eq = new HashSet<>();
|
||||||
elems.stream().forEach(x -> eq.addAll(x));
|
elems.stream().forEach(x -> eq.addAll(x));
|
||||||
res = unify(eq, new ArrayList<>(), fc, parallel);
|
res = unify(eq, new ArrayList<>(), fc, parallel, rekTiefe);
|
||||||
}
|
}
|
||||||
else {//duerfte gar nicht mehr vorkommen PL 2018-04-03
|
else {//duerfte gar nicht mehr vorkommen PL 2018-04-03
|
||||||
res = computeCartesianRecursiveOderConstraints(elems, remainingSets, fc, parallel);
|
res = computeCartesianRecursiveOderConstraints(elems, remainingSets, fc, parallel, rekTiefe);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {
|
if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {
|
||||||
@ -438,7 +438,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* @param fc The finite closure
|
* @param fc The finite closure
|
||||||
* @return The set of all principal type unifiers
|
* @return The set of all principal type unifiers
|
||||||
*/
|
*/
|
||||||
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel) {
|
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
||||||
//Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
//Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
// ).collect(Collectors.toCollection(HashSet::new));
|
// ).collect(Collectors.toCollection(HashSet::new));
|
||||||
//writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
//writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
||||||
@ -450,6 +450,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/*
|
/*
|
||||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||||
*/
|
*/
|
||||||
|
rekTiefe++;
|
||||||
nOfUnify++;
|
nOfUnify++;
|
||||||
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
||||||
writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString());
|
writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString());
|
||||||
@ -575,12 +576,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
|
|
||||||
//Aufruf von computeCartesianRecursive ANFANG
|
//Aufruf von computeCartesianRecursive ANFANG
|
||||||
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel);
|
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel) {
|
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
||||||
//Aufruf von computeCartesianRecursive ENDE
|
//Aufruf von computeCartesianRecursive ENDE
|
||||||
|
|
||||||
//keine Ahnung woher das kommt
|
//keine Ahnung woher das kommt
|
||||||
@ -648,12 +649,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
eqPrimePrimeSet.add(eqPrime);
|
eqPrimePrimeSet.add(eqPrime);
|
||||||
}
|
}
|
||||||
else if(eqPrimePrime.isPresent()) {
|
else if(eqPrimePrime.isPresent()) {
|
||||||
Set<Set<UnifyPair>> unifyres = unify(eqPrimePrime.get(), oderConstraints, fc, false);
|
Set<Set<UnifyPair>> unifyres = unify(eqPrimePrime.get(), oderConstraints, fc, false, rekTiefe);
|
||||||
|
|
||||||
eqPrimePrimeSet.addAll(unifyres);
|
eqPrimePrimeSet.addAll(unifyres);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<Set<UnifyPair>> unifyres = unify(eqPrime, oderConstraints, fc, false);
|
Set<Set<UnifyPair>> unifyres = unify(eqPrime, oderConstraints, fc, false, rekTiefe);
|
||||||
|
|
||||||
|
|
||||||
eqPrimePrimeSet.addAll(unifyres);
|
eqPrimePrimeSet.addAll(unifyres);
|
||||||
@ -682,7 +683,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel) {
|
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
||||||
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
||||||
fstElems.addAll(topLevelSets.stream()
|
fstElems.addAll(topLevelSets.stream()
|
||||||
.filter(x -> x.size()==1)
|
.filter(x -> x.size()==1)
|
||||||
@ -692,7 +693,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
.filter(x -> x.size()>1)
|
.filter(x -> x.size()>1)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
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);
|
Set<Set<UnifyPair>> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
||||||
@ -786,10 +787,11 @@ 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);
|
||||||
|
writeLog("a1: " + rekTiefe + " "+ a.toString()+ "\n");
|
||||||
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());
|
||||||
Set<Set<UnifyPair>> res = unify2(elems, eq, oderConstraints, fc, parallel);
|
Set<Set<UnifyPair>> res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe);
|
||||||
if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {
|
if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {
|
||||||
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
||||||
result = res;
|
result = res;
|
||||||
@ -899,7 +901,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// .collect(Collectors.toCollection(ArrayList::new));
|
// .collect(Collectors.toCollection(ArrayList::new));
|
||||||
writeLog("res (undef): " + res.toString());
|
writeLog("res (undef): " + res.toString());
|
||||||
writeLog("abhSubst: " + abhSubst.toString());
|
writeLog("abhSubst: " + abhSubst.toString());
|
||||||
writeLog("a: " + a.toString());
|
writeLog("a2: " + rekTiefe + " " + a.toString());
|
||||||
writeLog("Durchschnitt: " + durchschnitt.toString());
|
writeLog("Durchschnitt: " + durchschnitt.toString());
|
||||||
writeLog("nextSet: " + nextSet.toString());
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
@ -919,7 +921,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// result.removeIf(y -> isUndefinedPairSet(y));
|
// result.removeIf(y -> isUndefinedPairSet(y));
|
||||||
//}
|
//}
|
||||||
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
||||||
|
writeLog("res: " + res.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeLog("Return computeCR: " + result.toString());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user