diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index 38c0c7f2a..581ace29c 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -26,6 +26,7 @@ import de.dhbwstuttgart.typeinference.unify.RuleSet; import de.dhbwstuttgart.typeinference.unify.TypeUnify; import de.dhbwstuttgart.typeinference.unify.distributeVariance; import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure; +import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; @@ -34,6 +35,7 @@ import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -192,9 +194,32 @@ public class JavaTXCompiler { logFile.flush(); results.addAll(result); } - } - catch (IOException e) { } - + + /* + Function f = y -> { + if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); + return y; + }; + + Function, Set> g = x -> new rules().x.stream().map(y -> { + if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); + return y; + }).collect(Collectors.toCollection(HashSet::new)); + */ + results = results.stream().map(x -> new RuleSet().subst(x.stream().map(y -> { + if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); + return y; + }).collect(Collectors.toCollection(HashSet::new))).get()).collect(Collectors.toCollection(HashSet::new)); + /*results.stream().map(x -> x.stream().map(y -> { + if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); + return y; + }).collect(Collectors.toCollection(HashSet::new)).collect(Collectors.toCollection(HashSet::new))); + */ + System.out.println("RESULT Final: " + results); + logFile.write("RES_FINAL: " + results.toString()+"\n"); + logFile.flush(); + } + catch (IOException e) { } return results.stream().map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList()); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java index 6c3cfaad8..a48b7db2e 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -38,7 +38,7 @@ public class RuleSet implements IRuleSet{ FileWriter logFile; - RuleSet() { + public RuleSet() { super(); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java b/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java index 848e7fdd9..86e13e1d7 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java @@ -116,6 +116,10 @@ public class UnifyPair { return pairOp; } + public void setPairOp(PairOperator po) { + pairOp = po; + } + public byte getVariance() { return variance; } diff --git a/test/bytecode/VectorAddTest.java b/test/bytecode/VectorAddTest.java deleted file mode 100644 index 68651a400..000000000 --- a/test/bytecode/VectorAddTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package bytecode; - -import static org.junit.Assert.*; - -import java.io.File; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; - -import org.junit.Test; - -import de.dhbwstuttgart.core.JavaTXCompiler; - -public class VectorAddTest { - private static String path; - private static File fileToTest; - private static JavaTXCompiler compiler; - private static ClassLoader loader; - private static Class classToTest; - private static String pathToClassFile; - private static Object instanceOfClass; - - @Test - public void generateBC() throws Exception { - path = System.getProperty("user.dir")+"/test/bytecode/javFiles/VectorAdd.jav"; - fileToTest = new File(path); - compiler = new JavaTXCompiler(fileToTest); - compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/"); - pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/"; - loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); - classToTest = loader.loadClass("VectorAdd"); - instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); - } -} diff --git a/test/bytecode/javFiles/Matrix.jav b/test/bytecode/javFiles/Matrix.jav index 2ba7f3071..6eae34288 100644 --- a/test/bytecode/javFiles/Matrix.jav +++ b/test/bytecode/javFiles/Matrix.jav @@ -3,7 +3,7 @@ import java.lang.Integer; //import java.lang.Byte; import java.lang.Boolean; -public class Matrix extends Vector> { +public class Matrix extends Vector> { Matrix () { } @@ -18,7 +18,7 @@ public class Matrix extends Vector> { } } - mul(m) { + Matrix mul(java.util.Vector> m) { var ret = new Matrix(); var i = 0; while(i < size()) { diff --git a/test/bytecode/javFiles/Sorting.jav b/test/bytecode/javFiles/Sorting.jav index f9f5843ae..0c76fa2e0 100644 --- a/test/bytecode/javFiles/Sorting.jav +++ b/test/bytecode/javFiles/Sorting.jav @@ -7,12 +7,13 @@ class Sorting{ a.addAll(b); return a; } - +/* sort(in){ var firstHalf = in; var secondHalf = in; return merge(sort(firstHalf), sort(secondHalf)); } +*/ /* void sort(ArrayList a){