forked from JavaTX/JavaCompilerCore
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: ../../resources/bytecode/javFiles/Matrix.jav
This commit is contained in:
parent
33f2bf3d21
commit
e52181a0c7
@ -15,9 +15,14 @@ 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, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log, int rekTiefe, UnifyResultModel urm, ConstraintSet<Pair> cons) {
|
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log, int rekTiefe, UnifyResultModel urm, ConstraintSet<Pair> cons) {
|
||||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
this.setToFlatten = setToFlatten;
|
this.setToFlatten = setToFlatten;
|
||||||
|
this.nextSetElement = nextSetElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<UnifyPair> getNextSetElement() {
|
||||||
|
return nextSetElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,6 +59,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
private boolean printtag = false;
|
private boolean printtag = false;
|
||||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll?
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element, das aus dem nextSet den Gleichunen dieses Threads hinzugefuegt wurde
|
||||||
|
*/
|
||||||
|
Set<UnifyPair> nextSetElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fuer die Threads
|
* Fuer die Threads
|
||||||
*/
|
*/
|
||||||
@ -142,6 +147,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
//x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
||||||
|
this.nextSetElement = nextSetElement;
|
||||||
this.fc = fc;
|
this.fc = fc;
|
||||||
this.oup = new OrderingUnifyPair(fc);
|
this.oup = new OrderingUnifyPair(fc);
|
||||||
this.parallel = parallel;
|
this.parallel = parallel;
|
||||||
@ -918,15 +924,16 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//writeLog("Vor unify2 Aufruf: " + elems.toString());
|
//writeLog("Vor unify2 Aufruf: " + elems.toString());
|
||||||
Set<Set<UnifyPair>> res = new HashSet<>();
|
Set<Set<UnifyPair>> res = new HashSet<>();
|
||||||
Set<Set<Set<UnifyPair>>> add_res = new HashSet<>();
|
Set<Set<Set<UnifyPair>>> add_res = new HashSet<>();
|
||||||
|
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
||||||
if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) {
|
||||||
Set<TypeUnifyTask> forks = new HashSet<>();
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||||
List<Set<Set<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
List<Set<Set<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
//forks.add(forkOrig);
|
//forks.add(forkOrig);
|
||||||
forkOrig.fork();
|
forkOrig.fork();
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
@ -944,7 +951,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, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
@ -960,24 +967,27 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
};
|
};
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
|
|
||||||
for(TypeUnifyTask fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||||
//noOfThread--; an das Ende von compute verschoben
|
//noOfThread--; an das Ende von compute verschoben
|
||||||
add_res.add(fork_res);
|
add_res.add(fork_res);
|
||||||
|
if (!isUndefinedPairSetSet(fork_res)) {
|
||||||
|
aParDef.add(fork.getNextSetElement());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
||||||
Set<TypeUnifyTask> forks = new HashSet<>();
|
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||||
List<Set<Set<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
List<Set<Set<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
||||||
newElemsOrig.add(a);
|
newElemsOrig.add(a);
|
||||||
|
|
||||||
/* FORK ANFANG */
|
/* FORK ANFANG */
|
||||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
//forks.add(forkOrig);
|
//forks.add(forkOrig);
|
||||||
forkOrig.fork();
|
forkOrig.fork();
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
@ -995,7 +1005,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, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
@ -1011,12 +1021,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
};
|
};
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
|
|
||||||
for(TypeUnifyTask fork : forks) {
|
for(TypeUnify2Task fork : forks) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||||
//noOfThread--; an das Ende von compute verschoben
|
//noOfThread--; an das Ende von compute verschoben
|
||||||
add_res.add(fork_res);
|
add_res.add(fork_res);
|
||||||
|
if (!isUndefinedPairSetSet(fork_res)) {
|
||||||
|
aParDef.add(fork.getNextSetElement());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1029,7 +1042,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, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
//forks.add(forkOrig);
|
//forks.add(forkOrig);
|
||||||
forkOrig.fork();
|
forkOrig.fork();
|
||||||
/* FORK ENDE */
|
/* FORK ENDE */
|
||||||
@ -1045,7 +1058,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, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
@ -1230,18 +1243,24 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
while (nextSetasListIt.hasNext()) {
|
writeLog("aParDef: " + aParDef.toString());
|
||||||
Set<UnifyPair> a_next = nextSetasListIt.next();
|
aParDef.add(a);
|
||||||
if (a.equals(a_next) ||
|
Iterator<Set<UnifyPair>> aParDefIt = aParDef.iterator();
|
||||||
(oup.compare(a, a_next) == 1)) {
|
while(aParDefIt.hasNext()) {
|
||||||
writeLog("Removed: " + a_next.toString());
|
Set<UnifyPair> a_new = aParDefIt.next();
|
||||||
nextSetasList.remove(a_next);
|
while (nextSetasListIt.hasNext()) {
|
||||||
|
Set<UnifyPair> a_next = nextSetasListIt.next();
|
||||||
|
if (a_new.equals(a_next) ||
|
||||||
|
(oup.compare(a_new, a_next) == 1)) {
|
||||||
|
writeLog("Removed: " + a_next.toString());
|
||||||
|
nextSetasList.remove(a_next);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
writeLog("Not Removed: " + a_next.toString());
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
writeLog("Not Removed: " + a_next.toString());
|
|
||||||
System.out.println("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else { if (variance == -1) {
|
else { if (variance == -1) {
|
||||||
/* vorgezogen vor das if
|
/* vorgezogen vor das if
|
||||||
@ -1272,19 +1291,25 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
while (nextSetasListIt.hasNext()) {
|
writeLog("aParDef: " + aParDef.toString());
|
||||||
Set<UnifyPair> a_next = nextSetasListIt.next();
|
aParDef.add(a);
|
||||||
if (a.equals(a_next) ||
|
Iterator<Set<UnifyPair>> aParDefIt = aParDef.iterator();
|
||||||
(oup.compare(a, a_next) == -1)) {
|
while(aParDefIt.hasNext()) {
|
||||||
writeLog("Removed: " + a_next.toString());
|
Set<UnifyPair> a_new = aParDefIt.next();
|
||||||
nextSetasList.remove(a_next); //PL geaendert 2019-01-09
|
while (nextSetasListIt.hasNext()) {
|
||||||
}
|
Set<UnifyPair> a_next = nextSetasListIt.next();
|
||||||
else {
|
if (a_new.equals(a_next) ||
|
||||||
System.out.println("");
|
(oup.compare(a_new, a_next) == -1)) {
|
||||||
writeLog("Not Removed: " + a_next.toString());
|
writeLog("Removed: " + a_next.toString());
|
||||||
|
nextSetasList.remove(a_next); //PL geaendert 2019-01-09
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("");
|
||||||
|
writeLog("Not Removed: " + a_next.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else { if (variance == 0) {
|
else { if (variance == 0) {
|
||||||
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
break; }
|
break; }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
import java.lang.Float;
|
//import java.lang.Float;
|
||||||
//import java.lang.Byte;
|
//import java.lang.Byte;
|
||||||
//import java.lang.Boolean;
|
//import java.lang.Boolean;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user