Revert " modified: src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java"
This reverts commit 47ec1dca5a
.
This commit is contained in:
parent
47ec1dca5a
commit
df0d02cdea
@ -35,7 +35,6 @@ import de.dhbwstuttgart.typeinference.unify.UnifyResultListener;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl;
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl;
|
||||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
||||||
import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel;
|
import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel;
|
||||||
import de.dhbwstuttgart.typeinference.unify.controlCancel;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -55,15 +54,6 @@ public class JavaTXCompiler {
|
|||||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
||||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||||
public controlCancel cC = () -> false; //kann z.B. durche eine Implementierung
|
|
||||||
//von dem Eclipse Interface IProgressMonitor
|
|
||||||
//instanziert werden.
|
|
||||||
|
|
||||||
public JavaTXCompiler(File sourceFile, controlCancel cC) throws IOException, ClassNotFoundException {
|
|
||||||
this(Arrays.asList(sourceFile));
|
|
||||||
this.cC = cC;
|
|
||||||
INSTANCE = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||||
this(Arrays.asList(sourceFile));
|
this(Arrays.asList(sourceFile));
|
||||||
@ -446,7 +436,7 @@ public class JavaTXCompiler {
|
|||||||
return ret;
|
return ret;
|
||||||
}).collect(Collectors.toCollection(ArrayList::new));
|
}).collect(Collectors.toCollection(ArrayList::new));
|
||||||
unify.unifyAsync(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
unify.unifyAsync(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
||||||
usedTasks, cC);
|
usedTasks);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("kein LogFile");
|
System.err.println("kein LogFile");
|
||||||
}
|
}
|
||||||
@ -617,7 +607,7 @@ public class JavaTXCompiler {
|
|||||||
UnifyResultListenerImpl li = new UnifyResultListenerImpl();
|
UnifyResultListenerImpl li = new UnifyResultListenerImpl();
|
||||||
urm.addUnifyResultListener(li);
|
urm.addUnifyResultListener(li);
|
||||||
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
||||||
usedTasks, cC);
|
usedTasks);
|
||||||
System.out.println("RESULT Final: " + li.getResults());
|
System.out.println("RESULT Final: " + li.getResults());
|
||||||
logFile.write("RES_FINAL: " + li.getResults().toString() + "\n");
|
logFile.write("RES_FINAL: " + li.getResults().toString() + "\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
@ -629,7 +619,7 @@ public class JavaTXCompiler {
|
|||||||
// oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons,
|
// oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons,
|
||||||
// finiteClosure));
|
// finiteClosure));
|
||||||
Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints,
|
Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints,
|
||||||
finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure), usedTasks, cC);
|
finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure), usedTasks);
|
||||||
System.out.println("RESULT: " + result);
|
System.out.println("RESULT: " + result);
|
||||||
logFile.write("RES: " + result.toString() + "\n");
|
logFile.write("RES: " + result.toString() + "\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
|
@ -28,8 +28,8 @@ public class TypeUnify {
|
|||||||
* @param cons
|
* @param cons
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<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, cC);
|
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();
|
||||||
@ -54,8 +54,8 @@ public class TypeUnify {
|
|||||||
* @param ret
|
* @param ret
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) {
|
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<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, cC);
|
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;
|
||||||
@ -72,8 +72,8 @@ public class TypeUnify {
|
|||||||
* @param ret
|
* @param ret
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) {
|
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<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, cC);
|
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();
|
||||||
@ -105,8 +105,8 @@ public class TypeUnify {
|
|||||||
* @param cons
|
* @param cons
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks, controlCancel cC) {
|
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, usedTasks, cC);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, usedTasks);
|
||||||
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");
|
||||||
|
@ -18,8 +18,8 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
|||||||
|
|
||||||
Set<Set<UnifyPair>> setToFlatten;
|
Set<Set<UnifyPair>> setToFlatten;
|
||||||
|
|
||||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, controlCancel cC) {
|
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
||||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
this.setToFlatten = setToFlatten;
|
this.setToFlatten = setToFlatten;
|
||||||
this.nextSetElement = nextSetElement;
|
this.nextSetElement = nextSetElement;
|
||||||
}
|
}
|
||||||
|
@ -122,16 +122,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
static Integer noShortendElements = 0;
|
static Integer noShortendElements = 0;
|
||||||
|
|
||||||
/* Field wird nicht mehr benutzt
|
|
||||||
* Der cancel-Mechanismus wird durch die Implementierung von controlCancel
|
|
||||||
* erledigt.
|
|
||||||
Boolean myIsCanceled = false;
|
Boolean myIsCanceled = false;
|
||||||
*/
|
|
||||||
|
|
||||||
volatile UnifyTaskModel usedTasks;
|
volatile UnifyTaskModel usedTasks;
|
||||||
|
|
||||||
volatile controlCancel cC;
|
|
||||||
|
|
||||||
public TypeUnifyTask() {
|
public TypeUnifyTask() {
|
||||||
rules = new RuleSet();
|
rules = new RuleSet();
|
||||||
}
|
}
|
||||||
@ -151,7 +145,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks, controlCancel cC) {
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
||||||
synchronized (this) {
|
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));
|
||||||
@ -171,7 +165,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
this.parallel = parallel;
|
this.parallel = parallel;
|
||||||
this.logFile = logFile;
|
this.logFile = logFile;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.cC = cC;
|
|
||||||
|
|
||||||
noOfThread++;
|
noOfThread++;
|
||||||
totalnoOfThread++;
|
totalnoOfThread++;
|
||||||
@ -235,17 +228,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* Methode wird nicht mehr benutzt
|
|
||||||
* Der cancel-Mechanismus wird durch die Implementierung von controlCancel
|
|
||||||
* erledigt.
|
|
||||||
void myCancel(Boolean b) {
|
void myCancel(Boolean b) {
|
||||||
myIsCanceled = true;
|
myIsCanceled = true;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public boolean myIsCancelled() {
|
public boolean myIsCancelled() {
|
||||||
//return myIsCanceled;
|
return myIsCanceled;
|
||||||
return cC.isCanceled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<Set<UnifyPair>> compute() {
|
protected Set<Set<UnifyPair>> compute() {
|
||||||
@ -851,7 +839,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
//forks.add(forkOrig);
|
//forks.add(forkOrig);
|
||||||
synchronized(usedTasks) {
|
synchronized(usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -903,7 +891,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
newElems.add(nSaL);
|
newElems.add(nSaL);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
synchronized(usedTasks) {
|
synchronized(usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -957,7 +945,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
//forks.add(forkOrig);
|
//forks.add(forkOrig);
|
||||||
synchronized(usedTasks) {
|
synchronized(usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1009,7 +997,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
newElems.add(nSaL);
|
newElems.add(nSaL);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
synchronized(usedTasks) {
|
synchronized(usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1064,7 +1052,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
//forks.add(forkOrig);
|
//forks.add(forkOrig);
|
||||||
synchronized(usedTasks) {
|
synchronized(usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
@ -1085,7 +1073,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
newElems.add(nSaL);
|
newElems.add(nSaL);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks, cC);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
synchronized(usedTasks) {
|
synchronized(usedTasks) {
|
||||||
if (this.myIsCancelled()) {
|
if (this.myIsCancelled()) {
|
||||||
|
@ -10,13 +10,9 @@ public class UnifyTaskModel {
|
|||||||
usedTasks.add(t);
|
usedTasks.add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Methode wird nicht mehr benutzt
|
|
||||||
* Der cancel-Mechanismus wird durch die Implementierung von controlCancel
|
|
||||||
* erledigt.
|
|
||||||
public synchronized void cancel() {
|
public synchronized void cancel() {
|
||||||
for(TypeUnifyTask t : usedTasks) {
|
for(TypeUnifyTask t : usedTasks) {
|
||||||
t.myCancel(true);
|
t.myCancel(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify;
|
|
||||||
|
|
||||||
public interface controlCancel {
|
|
||||||
public Boolean isCanceled();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user