forked from JavaTX/JavaCompilerCore
Compare commits
1 Commits
8abe7f6c28
...
unif23Full
Author | SHA1 | Date | |
---|---|---|---|
|
4affe5074d |
13
Makefile
13
Makefile
@@ -1,3 +1,16 @@
|
|||||||
|
full:
|
||||||
|
mvn -DskipTests package
|
||||||
|
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_full.jar
|
||||||
|
|
||||||
|
NoMinMax:
|
||||||
|
mvn -DskipTests package
|
||||||
|
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoMinMax.jar
|
||||||
|
|
||||||
|
NoOpt:
|
||||||
|
mvn -DskipTests package
|
||||||
|
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoOpt.jar
|
||||||
|
|
||||||
NoOptParallel:
|
NoOptParallel:
|
||||||
mvn -DskipTests package
|
mvn -DskipTests package
|
||||||
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoOptParallel.jar
|
cp target/JavaTXcompiler-0.1-jar-with-dependencies.jar target/JavaTXcompiler-0.1-jar-with-dependencies_NoOptParallel.jar
|
||||||
|
|
||||||
|
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>21</source>
|
<source>19</source>
|
||||||
<target>21</target>
|
<target>19</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@@ -70,7 +70,7 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
//public static JavaTXCompiler INSTANCE;
|
//public static JavaTXCompiler INSTANCE;
|
||||||
final CompilationEnvironment environment;
|
final CompilationEnvironment environment;
|
||||||
Boolean resultmodel = true;
|
Boolean resultmodel = false;
|
||||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||||
Boolean log = false; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
|
Boolean log = false; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
|
||||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||||
@@ -88,8 +88,7 @@ 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
|
||||||
|
@@ -44,14 +44,14 @@ import org.apache.commons.io.output.NullOutputStream;
|
|||||||
*/
|
*/
|
||||||
public class RuleSet implements IRuleSet{
|
public class RuleSet implements IRuleSet{
|
||||||
|
|
||||||
WriterActiveObject logFile;
|
Writer logFile;
|
||||||
|
|
||||||
public RuleSet() {
|
public RuleSet() {
|
||||||
super();
|
super();
|
||||||
logFile = new WriterActiveObject(new OutputStreamWriter(new NullOutputStream()));
|
logFile = new OutputStreamWriter(new NullOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleSet(WriterActiveObject logFile) {
|
RuleSet(Writer logFile) {
|
||||||
this.logFile = logFile;
|
this.logFile = logFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,8 +867,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
logFile.write("FUNgreater: " + pair + "\n");
|
try {
|
||||||
logFile.write("FUNred: " + result + "\n");
|
logFile.write("FUNgreater: " + pair + "\n");
|
||||||
|
logFile.write("FUNred: " + result + "\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("logFile-Error");
|
||||||
|
}
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,10 +917,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
try {
|
||||||
logFile.write("FUNgreater: " + pair + "\n");
|
logFile.write("FUNgreater: " + pair + "\n");
|
||||||
logFile.write("FUNgreater: " + result + "\n");
|
logFile.write("FUNgreater: " + result + "\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("lofFile-Error");
|
||||||
|
}
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -957,9 +967,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
try {
|
||||||
logFile.write("FUNgreater: " + pair + "\n");
|
logFile.write("FUNgreater: " + pair + "\n");
|
||||||
logFile.write("FUNsmaller: " + result + "\n");
|
logFile.write("FUNsmaller: " + result + "\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("lofFile-Error");
|
||||||
|
}
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,13 +1,19 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify;
|
package de.dhbwstuttgart.typeinference.unify;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
|
|
||||||
public class TypeUnify {
|
public class TypeUnify {
|
||||||
@@ -24,7 +30,7 @@ public class TypeUnify {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, new WriterActiveObject(logFile), log, 0, ret, usedTasks);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
@@ -50,7 +56,7 @@ public class TypeUnify {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, new WriterActiveObject(logFile), log, 0, ret, usedTasks);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -69,15 +75,13 @@ public class TypeUnify {
|
|||||||
*/
|
*/
|
||||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||||
TypeUnifyTask unifyTask = //new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
TypeUnifyTask unifyTask = //new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
||||||
new TypeUnifyTask(undConstrains, oderConstraints, fc, true, new WriterActiveObject(logFile), log, 0, ret, usedTasks, statistics);
|
new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks, statistics);
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
try {
|
try {
|
||||||
logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n");
|
logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
unifyTask.statisticsFile.write("Backtracking: " + unifyTask.noBacktracking);
|
|
||||||
unifyTask.statisticsFile.write("\nLoops: " + unifyTask.noLoop);
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("no log-File");
|
System.err.println("no log-File");
|
||||||
@@ -104,8 +108,8 @@ public class TypeUnify {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, new WriterActiveObject(logFile), log, 0, ret, usedTasks);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, usedTasks);
|
||||||
unifyTask.statisticsFile = statistics;
|
unifyTask.statistics = statistics;
|
||||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||||
try {
|
try {
|
||||||
logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n");
|
logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n");
|
||||||
|
@@ -23,13 +23,13 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
|||||||
TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq,
|
TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq,
|
||||||
List<Set<Constraint<UnifyPair>>> oderConstraints,
|
List<Set<Constraint<UnifyPair>>> oderConstraints,
|
||||||
Set<UnifyPair> nextSetElement,
|
Set<UnifyPair> nextSetElement,
|
||||||
IFiniteClosure fc, boolean parallel, WriterActiveObject logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks,
|
IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks,
|
||||||
Set<UnifyPair> methodSignatureConstraintUebergabe, Writer statistics) {
|
Set<UnifyPair> methodSignatureConstraintUebergabe, Writer statistics) {
|
||||||
this(setToFlatten, eq, oderConstraints, nextSetElement, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, methodSignatureConstraintUebergabe );
|
this(setToFlatten, eq, oderConstraints, nextSetElement, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, methodSignatureConstraintUebergabe );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, WriterActiveObject logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, Set<UnifyPair> methodSignatureConstraintUebergabe) {
|
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, Set<UnifyPair> methodSignatureConstraintUebergabe) {
|
||||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
this.setToFlatten = setToFlatten;
|
this.setToFlatten = setToFlatten;
|
||||||
this.nextSetElement = nextSetElement;
|
this.nextSetElement = nextSetElement;
|
||||||
@@ -64,6 +64,13 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void closeLogFile() {
|
public void closeLogFile() {
|
||||||
logFile.close();
|
|
||||||
|
try {
|
||||||
|
logFile.close();
|
||||||
|
}
|
||||||
|
catch (IOException ioE) {
|
||||||
|
System.err.println("no log-File" + thNo);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,12 +17,17 @@ import java.util.concurrent.RecursiveTask;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.commons.io.output.NullOutputStream;
|
import org.apache.commons.io.output.NullOutputStream;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||||
import de.dhbwstuttgart.parser.NullToken;
|
import de.dhbwstuttgart.parser.NullToken;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IMatch;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IMatch;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IRuleSet;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IRuleSet;
|
||||||
@@ -42,6 +47,7 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.WildcardType;
|
import de.dhbwstuttgart.typeinference.unify.model.WildcardType;
|
||||||
import de.dhbwstuttgart.util.Pair;
|
import de.dhbwstuttgart.util.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.OrderingUnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.OrderingUnifyPair;
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@@ -49,6 +55,8 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
|
import com.google.common.collect.Ordering;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the type unification algorithm
|
* Implementation of the type unification algorithm
|
||||||
@@ -74,10 +82,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
private static int totalnoOfThread = 0;
|
private static int totalnoOfThread = 0;
|
||||||
int thNo;
|
int thNo;
|
||||||
protected boolean one = false;
|
protected boolean one = false;
|
||||||
Integer MaxNoOfThreads = 128;
|
Integer MaxNoOfThreads = 8;
|
||||||
|
|
||||||
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||||
protected WriterActiveObject logFile;
|
Writer logFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation of setOps that will be used during the unification
|
* The implementation of setOps that will be used during the unification
|
||||||
*/
|
*/
|
||||||
@@ -126,7 +135,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
volatile UnifyTaskModel usedTasks;
|
volatile UnifyTaskModel usedTasks;
|
||||||
|
|
||||||
static Writer statisticsFile;
|
static Writer statistics;
|
||||||
|
|
||||||
public TypeUnifyTask() {
|
public TypeUnifyTask() {
|
||||||
rules = new RuleSet();
|
rules = new RuleSet();
|
||||||
@@ -147,11 +156,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//statistics
|
//statistics
|
||||||
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, WriterActiveObject logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, Writer statisticsFile) {
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, Writer statistics) {
|
||||||
this(eq,oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
this(eq,oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
this.statisticsFile = statisticsFile;
|
this.statistics = statistics;
|
||||||
}
|
}
|
||||||
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, WriterActiveObject logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
||||||
|
synchronized (this) {
|
||||||
this.eq = eq;
|
this.eq = eq;
|
||||||
//this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
//this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
||||||
this.oderConstraintsField = oderConstraints; /*.stream().map(x -> {
|
this.oderConstraintsField = oderConstraints; /*.stream().map(x -> {
|
||||||
@@ -177,11 +187,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
thNo = totalnoOfThread;
|
thNo = totalnoOfThread;
|
||||||
writeLog("thNo2 " + thNo);
|
writeLog("thNo2 " + thNo);
|
||||||
try {
|
try {
|
||||||
if(log){
|
this.logFile = log ? new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "Thread_"+thNo))
|
||||||
this.logFile = new WriterActiveObject(new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "Thread_"+thNo)));
|
: new OutputStreamWriter(new NullOutputStream());
|
||||||
}else{
|
|
||||||
this.logFile = new WriterActiveObject(new OutputStreamWriter(new NullOutputStream()));
|
|
||||||
}
|
|
||||||
logFile.write("");
|
logFile.write("");
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
@@ -206,6 +213,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
this.urm = urm;
|
this.urm = urm;
|
||||||
this.usedTasks = usedTasks;
|
this.usedTasks = usedTasks;
|
||||||
this.usedTasks.add(this);
|
this.usedTasks.add(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,7 +258,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
protected Set<Set<UnifyPair>> compute() {
|
protected Set<Set<UnifyPair>> compute() {
|
||||||
if (one) {
|
if (one) {
|
||||||
//System.out.println("two");
|
System.out.println("two");
|
||||||
}
|
}
|
||||||
one = true;
|
one = true;
|
||||||
Set<UnifyPair> neweq = new HashSet<>(eq);
|
Set<UnifyPair> neweq = new HashSet<>(eq);
|
||||||
@@ -263,9 +271,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, new HashSet<>());
|
||||||
noOfThread--;
|
noOfThread--;
|
||||||
|
try {
|
||||||
logFile.close();
|
logFile.close();
|
||||||
|
}
|
||||||
|
catch (IOException ioE) {
|
||||||
|
System.err.println("no log-File");
|
||||||
|
}
|
||||||
if (isUndefinedPairSetSet(res)) {
|
if (isUndefinedPairSetSet(res)) {
|
||||||
//fuer debug-Zwecke
|
//fuer debug-Zwecke
|
||||||
ArrayList al = res.stream().map(x -> x.stream().collect(Collectors.toCollection(ArrayList::new)))
|
ArrayList al = res.stream().map(x -> x.stream().collect(Collectors.toCollection(ArrayList::new)))
|
||||||
@@ -648,7 +659,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//a <. theta, theta <. a oder a =. theta enthalten
|
//a <. theta, theta <. a oder a =. theta enthalten
|
||||||
|
|
||||||
//statistics
|
//statistics
|
||||||
//writeStatistics("\nNumber of Constraints (" + rekTiefe + "): " + topLevelSets.size());
|
writeStatistics("\nNumber of Constraints (" + rekTiefe + "): " + topLevelSets.size());
|
||||||
|
|
||||||
Set<Set<UnifyPair>> oneElems = new HashSet<>();
|
Set<Set<UnifyPair>> oneElems = new HashSet<>();
|
||||||
oneElems.addAll(topLevelSets.stream()
|
oneElems.addAll(topLevelSets.stream()
|
||||||
@@ -668,7 +679,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//writeLog("nextSet: " + nextSet.toString());
|
//writeLog("nextSet: " + nextSet.toString());
|
||||||
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
||||||
|
|
||||||
//writeStatistics(" Start Number of elements ( " /* + nextSetasList.get(0).stream().findFirst().get().getBasePair()*/ +"): (" + rekTiefe + "): " + nextSetasList.size());
|
writeStatistics(" Start Number of elements ( " /* + nextSetasList.get(0).stream().findFirst().get().getBasePair()*/ +"): (" + rekTiefe + "): " + nextSetasList.size());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
@@ -786,7 +797,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
while (nextSetasList.size() > 0) {
|
while (nextSetasList.size() > 0) {
|
||||||
|
|
||||||
//statistics
|
//statistics
|
||||||
//writeStatistics(" Actual Number of elements( " + nextSetasList.get(0).stream().findFirst().get().getBasePair() +"): (" + rekTiefe + "): " + nextSetasList.size());
|
writeStatistics(" Actual Number of elements( " + nextSetasList.get(0).stream().findFirst().get().getBasePair() +"): (" + rekTiefe + "): " + nextSetasList.size());
|
||||||
Set<UnifyPair> a_last = a;
|
Set<UnifyPair> a_last = a;
|
||||||
|
|
||||||
/* Liste der Faelle für die parallele Verarbeitung
|
/* Liste der Faelle für die parallele Verarbeitung
|
||||||
@@ -806,7 +817,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("nextSet: " + nextSet.toString());
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
|
|
||||||
/* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang
|
///* staistics Nextvar an Hand Varianzbestimmung auskommentieren Anfang
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
a = oup.max(nextSetasList.iterator());
|
a = oup.max(nextSetasList.iterator());
|
||||||
nextSetasList.remove(a);
|
nextSetasList.remove(a);
|
||||||
@@ -878,10 +889,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Nextvar an Hand Varianzbestimmung auskommentieren Ende */
|
//Nextvar an Hand Varianzbestimmung auskommentieren Ende */
|
||||||
a = nextSetasList.remove(0); //statisticsList
|
//a = nextSetasList.remove(0); //statisticsList
|
||||||
|
|
||||||
//writeStatistics(a.toString());
|
writeStatistics(a.toString());
|
||||||
if (oderConstraint) {//Methodconstraints werden abgespeichert für die Bytecodegenerierung von Methodenaufrufen
|
if (oderConstraint) {//Methodconstraints werden abgespeichert für die Bytecodegenerierung von Methodenaufrufen
|
||||||
methodSignatureConstraint.addAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint());
|
methodSignatureConstraint.addAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint());
|
||||||
//System.out.println("ERSTELLUNG: " +methodSignatureConstraint);
|
//System.out.println("ERSTELLUNG: " +methodSignatureConstraint);
|
||||||
@@ -936,9 +947,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("a in " + variance + " "+ a);
|
writeLog("a in " + variance + " "+ a);
|
||||||
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
||||||
}
|
}
|
||||||
while (!nextSetasList.isEmpty()) {
|
while (!nextSetasListRest.isEmpty()) {
|
||||||
Set<UnifyPair> nSaL = nextSetasList.remove(0);
|
Set<UnifyPair> nSaL = nextSetasListRest.remove(0);
|
||||||
synchronized (this) { //nextSetasList.remove(nSaL);
|
synchronized (this) { nextSetasList.remove(nSaL);
|
||||||
writeLog("1 RM" + nSaL.toString());
|
writeLog("1 RM" + nSaL.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1038,9 +1049,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("a in " + variance + " "+ a);
|
writeLog("a in " + variance + " "+ a);
|
||||||
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
||||||
}
|
}
|
||||||
while (!nextSetasList.isEmpty()) {
|
while (!nextSetasListRest.isEmpty()) {
|
||||||
Set<UnifyPair> nSaL = nextSetasList.remove(0);
|
Set<UnifyPair> nSaL = nextSetasListRest.remove(0);
|
||||||
synchronized (this) { //nextSetasList.remove(nSaL);
|
synchronized (this) { nextSetasList.remove(nSaL);
|
||||||
writeLog("-1 RM" + nSaL.toString());
|
writeLog("-1 RM" + nSaL.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,9 +1151,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("a in " + variance + " "+ a);
|
writeLog("a in " + variance + " "+ a);
|
||||||
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
writeLog("nextSetasListRest: " + nextSetasListRest.toString());
|
||||||
}
|
}
|
||||||
while (!nextSetasList.isEmpty()) {
|
while (!nextSetasListRest.isEmpty()) {
|
||||||
Set<UnifyPair> nSaL = nextSetasList.remove(0);
|
Set<UnifyPair> nSaL = nextSetasListRest.remove(0);
|
||||||
//nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03
|
nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03
|
||||||
Set<UnifyPair> newEq = new HashSet<>(eq);
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
@@ -1202,9 +1213,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}}}
|
}}}
|
||||||
|
|
||||||
//Ab hier alle parallele Berechnungen wieder zusammengeführt.
|
//Ab hier alle parallele Berechnungen wieder zusammengeführt.
|
||||||
//if (hilf == 1)
|
if (hilf == 1)
|
||||||
//System.out.println();
|
System.out.println();
|
||||||
//writeStatistics("Zusammengeführt(" + rekTiefe + "): " + nextSetasList.size());
|
writeStatistics("Zusammengeführt(" + rekTiefe + "): " + nextSetasList.size());
|
||||||
if (oderConstraint) {//Wenn weiteres Element nextSetasList genommen wird, muss die vorherige methodsignatur geloescht werden
|
if (oderConstraint) {//Wenn weiteres Element nextSetasList genommen wird, muss die vorherige methodsignatur geloescht werden
|
||||||
methodSignatureConstraint.removeAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint());
|
methodSignatureConstraint.removeAll(((Constraint<UnifyPair>)a).getmethodSignatureConstraint());
|
||||||
//System.out.println("REMOVE: " +methodSignatureConstraint);
|
//System.out.println("REMOVE: " +methodSignatureConstraint);
|
||||||
@@ -1316,7 +1327,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
||||||
result = par_res;
|
result = par_res;
|
||||||
if (!par_res.isEmpty() && par_res.iterator().next() instanceof WildcardType) {
|
if (!par_res.isEmpty() && par_res.iterator().next() instanceof WildcardType) {
|
||||||
//System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1332,7 +1343,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG
|
// /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG
|
||||||
if (!result.isEmpty() && (!isUndefinedPairSetSet(res) || !aParDef.isEmpty())) {
|
if (!result.isEmpty() && (!isUndefinedPairSetSet(res) || !aParDef.isEmpty())) {
|
||||||
if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1)
|
if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||||
System.out.print("");
|
System.out.print("");
|
||||||
@@ -1469,7 +1480,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
|
//auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
|
||||||
|
|
||||||
if (isUndefinedPairSetSet(res) && aParDef.isEmpty()) {
|
if (isUndefinedPairSetSet(res) && aParDef.isEmpty()) {
|
||||||
int nofstred= 0;
|
int nofstred= 0;
|
||||||
@@ -1502,9 +1513,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
return new Pair<>(su, x.getGroundBasePair());})
|
return new Pair<>(su, x.getGroundBasePair());})
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
if (res.size() > 1) {
|
if (res.size() > 1) {
|
||||||
//System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
/* statistics no erase
|
// /* statistics no erase
|
||||||
writeLog("nextSetasList vor filter-Aufruf: " + nextSetasList);
|
writeLog("nextSetasList vor filter-Aufruf: " + nextSetasList);
|
||||||
if (!oderConstraint) {//PL 2023-02-08 eingefuegt: Bei oderconstraints sind Subststitutionen nicht als Substitutionen in idesem Sinne zu sehen
|
if (!oderConstraint) {//PL 2023-02-08 eingefuegt: Bei oderconstraints sind Subststitutionen nicht als Substitutionen in idesem Sinne zu sehen
|
||||||
nextSetasList = nextSetasList.stream().filter(x -> {
|
nextSetasList = nextSetasList.stream().filter(x -> {
|
||||||
@@ -1517,7 +1528,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
}
|
}
|
||||||
writeLog("nextSetasList nach filter-Aufruf: " + nextSetasList);
|
writeLog("nextSetasList nach filter-Aufruf: " + nextSetasList);
|
||||||
*/
|
// */
|
||||||
nofstred = nextSetasList.size();
|
nofstred = nextSetasList.size();
|
||||||
//NOCH NICHT korrekt PL 2018-10-12
|
//NOCH NICHT korrekt PL 2018-10-12
|
||||||
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
||||||
@@ -1535,11 +1546,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString());
|
writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString());
|
||||||
noBacktracking++;
|
noBacktracking++;
|
||||||
writeLog("Number of Backtracking: " + noBacktracking);
|
writeLog("Number of Backtracking: " + noBacktracking);
|
||||||
//writeStatistics("Number of erased elements: " + (len - nextSetasList.size()));
|
writeStatistics("Number of erased elements: " + (len - nextSetasList.size()));
|
||||||
//writeStatistics("Number of Backtracking: " + noBacktracking);
|
writeStatistics("Number of Backtracking: " + noBacktracking);
|
||||||
//System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
else //writeStatistics("res: " + res.toString());
|
else writeStatistics("res: " + res.toString());
|
||||||
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
||||||
// return result;
|
// return result;
|
||||||
//}
|
//}
|
||||||
@@ -1548,9 +1559,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//}
|
//}
|
||||||
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
||||||
writeLog("res: " + res.toString());
|
writeLog("res: " + res.toString());
|
||||||
//writeStatistics(" End Number of Elements (" + rekTiefe + "): " + nextSetasList.size());
|
writeStatistics(" End Number of Elements (" + rekTiefe + "): " + nextSetasList.size());
|
||||||
noLoop++;
|
noLoop++;
|
||||||
//writeStatistics("Number of Loops: " + noLoop);
|
writeStatistics("Number of Loops: " + noLoop);
|
||||||
}
|
}
|
||||||
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
||||||
writeLog("Return computeCR: " + result.toString());
|
writeLog("Return computeCR: " + result.toString());
|
||||||
@@ -2046,7 +2057,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//System.out.println(pair);
|
//System.out.println(pair);
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
if (((PlaceholderType)(pair.getLhsType())).getName().equals("AR")) {
|
if (((PlaceholderType)(pair.getLhsType())).getName().equals("AR")) {
|
||||||
//System.out.println("AR");
|
System.out.println("AR");
|
||||||
}
|
}
|
||||||
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
||||||
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
||||||
@@ -2598,25 +2609,34 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void writeLog(String str) {
|
void writeLog(String str) {
|
||||||
|
synchronized ( this ) {
|
||||||
if (log && finalresult) {
|
if (log && finalresult) {
|
||||||
logFile.write("Thread no.:" + thNo + "\n"
|
try {
|
||||||
+ "noOfThread:" + noOfThread + "\n"
|
logFile.write("Thread no.:" + thNo + "\n");
|
||||||
+ "parallel:" + parallel + "\n"
|
logFile.write("noOfThread:" + noOfThread + "\n");
|
||||||
+ str+"\n\n"
|
logFile.write("parallel:" + parallel + "\n");
|
||||||
);
|
logFile.write(str+"\n\n");
|
||||||
}
|
logFile.flush();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.err.println("kein LogFile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeStatistics(String str) {
|
void writeStatistics(String str) {
|
||||||
if (finalresult) {
|
if (finalresult) {
|
||||||
|
synchronized ( this ) {
|
||||||
try {
|
try {
|
||||||
statisticsFile.write("Thread No. " + thNo + ": " + str + "\n");
|
statistics.write(str + "\n");
|
||||||
statisticsFile.flush();
|
statistics.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("kein StatisticsFile");
|
System.err.println("kein StatisticsFile");
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.concurrent.ForkJoinPool;
|
|
||||||
|
|
||||||
public class WriterActiveObject {
|
|
||||||
private Writer writer;
|
|
||||||
private ForkJoinPool pool = new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true);
|
|
||||||
|
|
||||||
public WriterActiveObject(Writer writer){
|
|
||||||
this.writer = writer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close(){
|
|
||||||
pool.execute(()->{
|
|
||||||
try {
|
|
||||||
writer.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(String message){
|
|
||||||
pool.execute(()->{
|
|
||||||
try {
|
|
||||||
writer.write(message);
|
|
||||||
writer.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println(e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,27 +1,13 @@
|
|||||||
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;
|
||||||
@@ -38,60 +24,7 @@ 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