modified: ../../src/de/dhbwstuttgart/core/JavaTXCompiler.java

modified:   ../../src/de/dhbwstuttgart/typeinference/unify/RuleSet.java
	modified:   ../../src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java
Gleichungen a <.? b werden durch a =. b ersetzt und subst angewandt.

	deleted:    ../../test/bytecode/VectorAddTest.java
	modified:   ../../test/bytecode/javFiles/Matrix.jav
	modified:   ../../test/bytecode/javFiles/Sorting.jav
This commit is contained in:
Martin Plümicke 2018-09-27 15:59:57 +02:00
parent 0594fc7381
commit 8a43839c28
6 changed files with 37 additions and 41 deletions

View File

@ -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<UnifyPair, UnifyPair> f = y -> {
if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT);
return y;
};
Function<Set<UnifyPair>, Set<UnifyPair>> 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());
}

View File

@ -38,7 +38,7 @@ public class RuleSet implements IRuleSet{
FileWriter logFile;
RuleSet() {
public RuleSet() {
super();
}

View File

@ -116,6 +116,10 @@ public class UnifyPair {
return pairOp;
}
public void setPairOp(PairOperator po) {
pairOp = po;
}
public byte getVariance() {
return variance;
}

View File

@ -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();
}
}

View File

@ -3,7 +3,7 @@ import java.lang.Integer;
//import java.lang.Byte;
import java.lang.Boolean;
public class Matrix extends Vector<Vector<Integer>> {
public class Matrix extends Vector<Vector<Integer>> {
Matrix () {
}
@ -18,7 +18,7 @@ public class Matrix extends Vector<Vector<Integer>> {
}
}
mul(m) {
Matrix mul(java.util.Vector<java.util.Vector<java.lang.Integer>> m) {
var ret = new Matrix();
var i = 0;
while(i < size()) {

View File

@ -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<String> a){