forked from JavaTX/JavaCompilerCore
Compare commits
10 Commits
performanc
...
b806fa88ff
Author | SHA1 | Date | |
---|---|---|---|
|
b806fa88ff | ||
|
301e9143ec | ||
|
bb4eaaccc5 | ||
|
4dbae46765 | ||
|
c64071f235 | ||
|
94dbf1f7ad | ||
|
890f64c813 | ||
|
5aadb7545e | ||
|
0c0ac61a02 | ||
|
46192e3fd3 |
4
pom.xml
4
pom.xml
@@ -54,8 +54,8 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
<version>3.8.0</version>
|
<version>3.8.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<compilerArgs>--enable-preview</compilerArgs>
|
<compilerArgs>--enable-preview</compilerArgs>
|
||||||
<source>19</source>
|
<source>21</source>
|
||||||
<target>19</target>
|
<target>21</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@@ -88,7 +88,8 @@ public class JavaTXCompiler {
|
|||||||
this(sourceFiles, null);
|
this(sourceFiles, null);
|
||||||
}
|
}
|
||||||
public JavaTXCompiler(List<File> sources, List<File> contextPath) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(List<File> sources, List<File> contextPath) throws IOException, ClassNotFoundException {
|
||||||
statistics = new FileWriter(new File(System.getProperty("user.dir") + "/" + sources.get(0).getName() + "_"+ new Timestamp(System.currentTimeMillis())));
|
//statistics = new FileWriter(new File(System.getProperty("user.dir") + "/" + sources.get(0).getName() + "_"+ new Timestamp(System.currentTimeMillis())));
|
||||||
|
statistics = new OutputStreamWriter(new NullOutputStream());
|
||||||
statistics.write("test");
|
statistics.write("test");
|
||||||
if(contextPath == null || contextPath.isEmpty()){
|
if(contextPath == null || contextPath.isEmpty()){
|
||||||
//When no contextPaths are given, the working directory is the sources root
|
//When no contextPaths are given, the working directory is the sources root
|
||||||
|
@@ -2609,7 +2609,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void writeLog(String str) {
|
void writeLog(String str) {
|
||||||
synchronized ( this ) {
|
|
||||||
if (log && finalresult) {
|
if (log && finalresult) {
|
||||||
try {
|
try {
|
||||||
logFile.write("Thread no.:" + thNo + "\n");
|
logFile.write("Thread no.:" + thNo + "\n");
|
||||||
@@ -2617,18 +2616,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
logFile.write("parallel:" + parallel + "\n");
|
logFile.write("parallel:" + parallel + "\n");
|
||||||
logFile.write(str+"\n\n");
|
logFile.write(str+"\n\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("kein LogFile");
|
System.err.println("kein LogFile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeStatistics(String str) {
|
void writeStatistics(String str) {
|
||||||
if (finalresult) {
|
if (finalresult) {
|
||||||
synchronized ( this ) {
|
|
||||||
try {
|
try {
|
||||||
statistics.write("Thread No. " + thNo + ": " + str + "\n");
|
statistics.write("Thread No. " + thNo + ": " + str + "\n");
|
||||||
statistics.flush();
|
statistics.flush();
|
||||||
@@ -2637,6 +2633,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("kein StatisticsFile");
|
System.err.println("kein StatisticsFile");
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,27 @@
|
|||||||
package typeinference;
|
package typeinference;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||||
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.*;
|
||||||
|
import org.apache.commons.io.output.NullWriter;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -24,7 +38,60 @@ import java.util.Set;
|
|||||||
public class UnifyTest {
|
public class UnifyTest {
|
||||||
|
|
||||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/";
|
||||||
/*
|
|
||||||
|
@Test
|
||||||
|
public void unifyTest(){
|
||||||
|
UnifyType type1 = new PlaceholderType("a");
|
||||||
|
UnifyType type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("b")));
|
||||||
|
UnifyPair pair1 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
|
type1 = new ReferenceType("List", new TypeParams(new PlaceholderType("c")));
|
||||||
|
type2 = new PlaceholderType("a");
|
||||||
|
UnifyPair pair2 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
|
type1 = new ReferenceType("String");
|
||||||
|
type2 = new PlaceholderType("b");
|
||||||
|
UnifyPair pair3 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
|
type1 = new ReferenceType("Integer");
|
||||||
|
type2 = new PlaceholderType("c");
|
||||||
|
UnifyPair pair4 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
|
Set<UnifyPair> undConstraints = new HashSet<>();
|
||||||
|
undConstraints.add(pair1);
|
||||||
|
undConstraints.add(pair2);
|
||||||
|
undConstraints.add(pair3);
|
||||||
|
undConstraints.add(pair4);
|
||||||
|
|
||||||
|
List<Set<Constraint<UnifyPair>>> oderConstraints = new ArrayList<>();
|
||||||
|
|
||||||
|
Set<UnifyPair> constraints = new HashSet<>();
|
||||||
|
type1 = new ReferenceType("Object");
|
||||||
|
type2 = new ReferenceType("String");
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("Number");
|
||||||
|
type2 = new ReferenceType("Integer");
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("Object");
|
||||||
|
type2 = new ReferenceType("Number");
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("X")));
|
||||||
|
type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("X")));
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("Object");
|
||||||
|
type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("X")));
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
|
||||||
|
IFiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter());
|
||||||
|
|
||||||
|
TypeUnify unifyAlgo = new TypeUnify();
|
||||||
|
ConstraintSet< Pair> cons = new ConstraintSet<>();
|
||||||
|
UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure);
|
||||||
|
UnifyTaskModel tasks = new UnifyTaskModel();
|
||||||
|
Set<Set<UnifyPair>> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks);
|
||||||
|
System.out.println(solution.size());
|
||||||
|
}
|
||||||
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void finiteClosure() throws IOException, ClassNotFoundException {
|
public void finiteClosure() throws IOException, ClassNotFoundException {
|
||||||
execute(new File(rootDirectory+"fc.jav"));
|
execute(new File(rootDirectory+"fc.jav"));
|
||||||
|
Reference in New Issue
Block a user