modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnify.java
modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: ../bytecode/javFiles/Matrix.jav einige Aenderungen
This commit is contained in:
parent
9d37e8f637
commit
883ab50f94
@ -1,6 +1,7 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify;
|
package de.dhbwstuttgart.typeinference.unify;
|
||||||
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
|
|
||||||
@ -11,7 +12,12 @@ public class TypeUnify {
|
|||||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
|
try {
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
|
}
|
||||||
|
catch (ConcurrentModificationException v) {
|
||||||
|
v.printStackTrace();
|
||||||
|
}
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* @param fc The finite closure
|
* @param fc The finite closure
|
||||||
* @return The set of all principal type unifiers
|
* @return The set of all principal type unifiers
|
||||||
*/
|
*/
|
||||||
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
protected Set<Set<UnifyPair>> unify(final Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||||
//Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
//Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
// ).collect(Collectors.toCollection(HashSet::new));
|
// ).collect(Collectors.toCollection(HashSet::new));
|
||||||
//writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
//writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
||||||
@ -463,7 +463,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
List<Set<UnifyPair>> nextSetasListRest= new ArrayList<>();
|
List<Set<UnifyPair>> nextSetasListRest= new ArrayList<>();
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
a = oup.max(nextSetasList.iterator());
|
a = oup.max(nextSetasList.iterator());
|
||||||
//nextSetasList.remove(a);
|
nextSetasList.remove(a);
|
||||||
nextSetasListRest = new ArrayList<>(nextSetasList);
|
nextSetasListRest = new ArrayList<>(nextSetasList);
|
||||||
Iterator<Set<UnifyPair>> nextSetasListItRest = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
|
Iterator<Set<UnifyPair>> nextSetasListItRest = new ArrayList<Set<UnifyPair>>(nextSetasListRest).iterator();
|
||||||
while (nextSetasListItRest.hasNext()) {
|
while (nextSetasListItRest.hasNext()) {
|
||||||
@ -511,6 +511,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt
|
//if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt
|
||||||
//writeLog("Vor unify2 Aufruf: " + eq.toString());
|
//writeLog("Vor unify2 Aufruf: " + eq.toString());
|
||||||
Set<Set<UnifyPair>> res = new HashSet<>();
|
Set<Set<UnifyPair>> res = new HashSet<>();
|
||||||
|
Set<Set<UnifyPair>> add_res = new HashSet<>();
|
||||||
if(parallel && (variance == 1)) {
|
if(parallel && (variance == 1)) {
|
||||||
/*
|
/*
|
||||||
elems.add(a);
|
elems.add(a);
|
||||||
@ -520,15 +521,21 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Set<TypeUnifyTask> forks = new HashSet<>();
|
Set<TypeUnifyTask> forks = new HashSet<>();
|
||||||
|
|
||||||
|
//TypeUnify2Task fork1 = new TypeUnify2Task(elems, eq, fc, parallel, logFile, log);
|
||||||
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
||||||
for(Set<UnifyPair> nSaL : nextSetasListRest) {
|
for(Set<UnifyPair> nSaL : nextSetasListRest) {
|
||||||
elems.add(nSaL);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
TypeUnify2Task fork = new TypeUnify2Task(elems, eq, fc, parallel, logFile, log);
|
newElems.add(nSaL);
|
||||||
|
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, fc, parallel, logFile, log);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
|
res = unify2(elems, eq, fc, parallel);
|
||||||
|
//res = fork1.join();
|
||||||
for(TypeUnifyTask fork : forks) {
|
for(TypeUnifyTask fork : forks) {
|
||||||
res.addAll(fork.join());
|
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||||
System.out.println("");
|
add_res.addAll(fork_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -566,6 +573,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
System.out.print("");
|
System.out.print("");
|
||||||
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
|
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
|
if (parallel) {
|
||||||
|
result.addAll(add_res);
|
||||||
|
break;
|
||||||
|
}
|
||||||
/* nextSetasList = nextSetasListRest; */
|
/* nextSetasList = nextSetasListRest; */
|
||||||
/* wird bereits vor den unify2-Aufruf durchgefuehrt und nextSetasListRest zugeordnet
|
/* wird bereits vor den unify2-Aufruf durchgefuehrt und nextSetasListRest zugeordnet
|
||||||
*/
|
*/
|
||||||
@ -578,6 +589,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else { if (variance == -1) {
|
else { if (variance == -1) {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
//import java.lang.Byte;
|
import java.lang.Byte;
|
||||||
import java.lang.Boolean;
|
import java.lang.Boolean;
|
||||||
|
|
||||||
public class Matrix extends Vector<Vector<Integer>> {
|
public class Matrix extends Vector<Vector<Integer>> {
|
||||||
|
Loading…
Reference in New Issue
Block a user