Merge branch 'unify-test' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into unify-test
This commit is contained in:
Martin Plümicke 2018-02-21 17:55:47 +01:00
commit 419e4a6d0e
2 changed files with 47 additions and 30 deletions

View File

@ -101,8 +101,8 @@ public class JavaTXCompiler {
}
System.out.println(xConsSet);
//Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure);
Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure);
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
System.out.println("RESULT: " + result);
results.addAll(result);
}

View File

@ -161,44 +161,36 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
//System.out.println(topLevelSets);
System.out.println();
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, fc, parallel);
//Aufruf von computeCartesianRecursive ANFANG
//return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, fc, parallel);
}
//}
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> sets, Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
ArrayList<Set<Set<UnifyPair>>> newSets = new ArrayList<>(sets);
Set<Set<UnifyPair>> set = newSets.remove(0);
ArrayList<Set<UnifyPair>> newSet = new ArrayList<>(set);
Set<Set<UnifyPair>> result = null;
int i = 0;
for(Set<UnifyPair> a : newSet) {
i++;
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
elems.add(a);
if (newSets.isEmpty()) {
result = unify2(elems, eq, fc, parallel);
}
else {
result = computeCartesianRecursive(elems,newSets, eq, fc, parallel);
}
if (!result.isEmpty()) break;
}
return result;
}
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
//Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
//Aufruf von computeCartesianRecursive ENDE
//Set<Set<UnifyPair>> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new));
//Muss auskommentiert werden, wenn computeCartesianRecursive ANFANG
// Cartesian product over all (up to 10) top level sets
//Set<Set<Set<UnifyPair>>> eqPrimeSet = setOps.cartesianProduct(topLevelSets)
//.stream().map(x -> new HashSet<>(x))
//.collect(Collectors.toCollection(HashSet::new));
Set<Set<Set<UnifyPair>>> eqPrimeSet = setOps.cartesianProduct(topLevelSets)
.stream().map(x -> new HashSet<>(x))
.collect(Collectors.toCollection(HashSet::new));
//Muss auskommentiert werden, wenn computeCartesianRecursive ENDE
Set<Set<UnifyPair>> eqPrimePrimeSet = new HashSet<>();
Set<TypeUnifyTask> forks = new HashSet<>();
//for(Set<Set<UnifyPair>> setToFlatten : eqPrimeSet) {
//Muss auskommentiert werden, wenn computeCartesianRecursive ANFANG
for(Set<Set<UnifyPair>> setToFlatten : eqPrimeSet) {
// Flatten the cartesian product
//Muss auskommentiert werden, wenn computeCartesianRecursive ENDE
Set<UnifyPair> eqPrime = new HashSet<>();
setToFlatten.stream().forEach(x -> eqPrime.addAll(x));
@ -242,7 +234,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
else
eqPrimePrimeSet.addAll(unify(eqPrime, fc, false));
}
//}
//Muss auskommentiert werden, wenn computeCartesianRecursive ANFANG
}
//Muss auskommentiert werden, wenn computeCartesianRecursive ENDE
/*
* Step 6 b) Build the union over everything.
@ -259,6 +253,29 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> sets, Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
ArrayList<Set<Set<UnifyPair>>> newSets = new ArrayList<>(sets);
Set<Set<UnifyPair>> set = newSets.remove(0);
ArrayList<Set<UnifyPair>> newSet = new ArrayList<>(set);
Set<Set<UnifyPair>> result = null;
int i = 0;
for(Set<UnifyPair> a : newSet) {
i++;
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
elems.add(a);
if (newSets.isEmpty()) {
//BEI BENUTZUNG EIKOMMENTIEREN result = unify2(elems, eq, fc, parallel);
}
else {
result = computeCartesianRecursive(elems,newSets, eq, fc, parallel);
}
if (!result.isEmpty()) break;
}
return result;
}
/**
* Checks whether a set of pairs is in solved form.
* @param eqPrimePrime The set of pair