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