diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index 8d381e37..9a66543a 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -103,7 +103,7 @@ public class JavaTXCompiler { System.out.println(xConsSet); Set> result = unify.unify(xConsSet, finiteClosure); System.out.println("RESULT: " + result.size()); - //results.addAll(result); + results.addAll(result); } return results.stream().map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList()); diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index e51679e2..31f79b1b 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -156,15 +156,17 @@ public class TypeUnifyTask extends RecursiveTask>> { topLevelSets.add(flat); } + + Set> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new)); // Cartesian product over all (up to 10) top level sets - Set>> eqPrimeSet = setOps.cartesianProduct(topLevelSets) - .stream().map(x -> new HashSet<>(x)) - .collect(Collectors.toCollection(HashSet::new)); + //Set>> eqPrimeSet = setOps.cartesianProduct(topLevelSets) + //.stream().map(x -> new HashSet<>(x)) + //.collect(Collectors.toCollection(HashSet::new)); Set> eqPrimePrimeSet = new HashSet<>(); Set forks = new HashSet<>(); - for(Set> setToFlatten : eqPrimeSet) { + //for(Set> setToFlatten : eqPrimeSet) { // Flatten the cartesian product Set eqPrime = new HashSet<>(); setToFlatten.stream().forEach(x -> eqPrime.addAll(x)); @@ -208,7 +210,7 @@ public class TypeUnifyTask extends RecursiveTask>> { else eqPrimePrimeSet.addAll(unify(eqPrime, fc, false)); } - } + //} /* * Step 6 b) Build the union over everything. diff --git a/test/javFiles/FC_Matrix.jav b/test/javFiles/FC_Matrix.jav new file mode 100644 index 00000000..75ead472 --- /dev/null +++ b/test/javFiles/FC_Matrix.jav @@ -0,0 +1,10 @@ +import java.util.Vector; + +class Matrix extends Vector> { + + methode(m) { + m.add(1); + Matrix i; + methode(i); + } + } diff --git a/test/javFiles/Matrix.jav b/test/javFiles/Matrix.jav index aa8966c9..e1183535 100644 --- a/test/javFiles/Matrix.jav +++ b/test/javFiles/Matrix.jav @@ -6,21 +6,21 @@ class Matrix extends Vector> { mul(m) { var ret = new Matrix(); var i = 0; - //while(i < size()) { + while(i < size()) { var v1 = this.elementAt(i); - //var v2 = new Vector(); - //var j = 0; - //while(j < v1.size()) { - //var erg = 0; - //var k = 0; - //while(k < v1.size()) { - //erg = erg + v1.elementAt(k) - // * m.elementAt(k).elementAt(j); - //k++; } - //v2.addElement(new Integer(erg)); - //j++; } - //ret.addElement(v2); - //i++; } + var v2 = new Vector(); + var j = 0; + while(j < v1.size()) { + var erg = 0; + var k = 0; + while(k < v1.size()) { + erg = erg + v1.elementAt(k) + * m.elementAt(k).elementAt(j); + k++; } + v2.addElement(new Integer(erg)); + j++; } + ret.addElement(v2); + i++; } return ret; } } diff --git a/test/typeinference/FiniteClosureTest_Matrix.java b/test/typeinference/FiniteClosureTest_Matrix.java new file mode 100644 index 00000000..59a1b478 --- /dev/null +++ b/test/typeinference/FiniteClosureTest_Matrix.java @@ -0,0 +1,9 @@ +package typeinference; + +import java.io.File; + +public class FiniteClosureTest_Matrix extends JavaTXCompilerTest{ + public FiniteClosureTest_Matrix() { + this.fileToTest = new File(rootDirectory+"FC_Matrix.jav"); + } +} \ No newline at end of file