diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index aabd2792..bb36c5b4 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -168,7 +168,7 @@ public class TypeUnifyTask extends RecursiveTask>> { ArrayList>> remainingOderconstraints = oderConstraintsField.stream() .filter(x -> x.size()>1) .collect(Collectors.toCollection(ArrayList::new)); - Set> res = unify(neweq, remainingOderconstraints, fc, parallel); + Set> res = unify(neweq, remainingOderconstraints, fc, parallel, 0); if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } else return res; } @@ -184,7 +184,7 @@ public class TypeUnifyTask extends RecursiveTask>> { */ - public Set> computeCartesianRecursiveOderConstraints(Set> fstElems, List>> topLevelSets, IFiniteClosure fc, boolean parallel) { + public Set> computeCartesianRecursiveOderConstraints(Set> fstElems, List>> topLevelSets, IFiniteClosure fc, boolean parallel, int rekTiefe) { //ArrayList>> remainingSets = new ArrayList<>(topLevelSets); fstElems.addAll(topLevelSets.stream() .filter(x -> x.size()==1) @@ -196,7 +196,7 @@ public class TypeUnifyTask extends RecursiveTask>> { if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig Set eq = new HashSet<>(); fstElems.stream().forEach(x -> eq.addAll(x)); - Set> result = unify(eq, new ArrayList<>(), fc, parallel); + Set> result = unify(eq, new ArrayList<>(), fc, parallel, rekTiefe); return result; } Set> nextSet = remainingSets.remove(0); @@ -299,10 +299,10 @@ public class TypeUnifyTask extends RecursiveTask>> { System.out.println(noou); Set eq = new HashSet<>(); 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 - res = computeCartesianRecursiveOderConstraints(elems, remainingSets, fc, parallel); + res = computeCartesianRecursiveOderConstraints(elems, remainingSets, fc, parallel, rekTiefe); } if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) { @@ -438,7 +438,7 @@ public class TypeUnifyTask extends RecursiveTask>> { * @param fc The finite closure * @return The set of all principal type unifiers */ - protected Set> unify(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel) { + protected Set> unify(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //Set aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT) // ).collect(Collectors.toCollection(HashSet::new)); //writeLog(nOfUnify.toString() + " AA: " + aas.toString()); @@ -450,6 +450,7 @@ public class TypeUnifyTask extends RecursiveTask>> { /* * Step 1: Repeated application of reduce, adapt, erase, swap */ + rekTiefe++; nOfUnify++; writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString()); writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString()); @@ -575,12 +576,12 @@ public class TypeUnifyTask extends RecursiveTask>> { //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> unify2(Set> setToFlatten, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel) { + Set> unify2(Set> setToFlatten, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //Aufruf von computeCartesianRecursive ENDE //keine Ahnung woher das kommt @@ -648,12 +649,12 @@ public class TypeUnifyTask extends RecursiveTask>> { eqPrimePrimeSet.add(eqPrime); } else if(eqPrimePrime.isPresent()) { - Set> unifyres = unify(eqPrimePrime.get(), oderConstraints, fc, false); + Set> unifyres = unify(eqPrimePrime.get(), oderConstraints, fc, false, rekTiefe); eqPrimePrimeSet.addAll(unifyres); } else { - Set> unifyres = unify(eqPrime, oderConstraints, fc, false); + Set> unifyres = unify(eqPrime, oderConstraints, fc, false, rekTiefe); eqPrimePrimeSet.addAll(unifyres); @@ -682,7 +683,7 @@ public class TypeUnifyTask extends RecursiveTask>> { - Set> computeCartesianRecursive(Set> fstElems, ArrayList>> topLevelSets, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel) { + Set> computeCartesianRecursive(Set> fstElems, ArrayList>> topLevelSets, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //ArrayList>> remainingSets = new ArrayList<>(topLevelSets); fstElems.addAll(topLevelSets.stream() .filter(x -> x.size()==1) @@ -692,7 +693,7 @@ public class TypeUnifyTask extends RecursiveTask>> { .filter(x -> x.size()>1) .collect(Collectors.toCollection(ArrayList::new)); if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig - Set> result = unify2(fstElems, eq, oderConstraints, fc, parallel); + Set> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe); return result; } Set> nextSet = remainingSets.remove(0); @@ -786,10 +787,11 @@ public class TypeUnifyTask extends RecursiveTask>> { //for(Set a : newSet) { i++; Set> elems = new HashSet>(fstElems); + writeLog("a1: " + rekTiefe + " "+ a.toString()+ "\n"); 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()); - Set> res = unify2(elems, eq, oderConstraints, fc, parallel); + Set> res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe); if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) { //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen result = res; @@ -899,7 +901,7 @@ public class TypeUnifyTask extends RecursiveTask>> { // .collect(Collectors.toCollection(ArrayList::new)); writeLog("res (undef): " + res.toString()); writeLog("abhSubst: " + abhSubst.toString()); - writeLog("a: " + a.toString()); + writeLog("a2: " + rekTiefe + " " + a.toString()); writeLog("Durchschnitt: " + durchschnitt.toString()); writeLog("nextSet: " + nextSet.toString()); writeLog("nextSetasList: " + nextSetasList.toString()); @@ -919,7 +921,10 @@ public class TypeUnifyTask extends RecursiveTask>> { // result.removeIf(y -> isUndefinedPairSet(y)); //} //else result.stream().filter(y -> !isUndefinedPairSet(y)); + writeLog("res: " + res.toString()); } + + writeLog("Return computeCR: " + result.toString()); return result; }