diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index 8c2b6d41..f03589ed 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -73,7 +73,7 @@ public class JavaTXCompiler { public static JavaTXCompiler INSTANCE; final CompilationEnvironment environment; - Boolean resultmodel = true; + Boolean resultmodel = false; public final Map sourceFiles = new HashMap<>(); 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(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index a392a2fa..755cbf0a 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -31,6 +31,9 @@ import de.dhbwstuttgart.typeinference.unify.distributeVariance; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; +import java.io.OutputStreamWriter; + +import org.apache.commons.io.output.NullOutputStream; /** * Implementation of the type inference rules. @@ -43,6 +46,7 @@ public class RuleSet implements IRuleSet{ public RuleSet() { super(); + logFile = new OutputStreamWriter(new NullOutputStream()); } RuleSet(Writer logFile) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 73fddb07..04ffb57f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -637,62 +637,17 @@ public class TypeUnifyTask extends RecursiveTask>> { .next() .stream() .filter(x -> x.getGroundBasePair().getLhsType() instanceof PlaceholderType && - x.getRhsType() instanceof ReferenceType && + ! (x.getRhsType() instanceof PlaceholderType) && x.getPairOp() == PairOperator.EQUALSDOT) .map(x -> ((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance()) .findAny(); - //Fuer Operatorenaufrufe wird variance auf 2 gesetzt + //Fuer Operatorenaufrufe wird variance auf 2 gesetzt. + //da kein Receiver existiert also keon x.getGroundBasePair().getLhsType() instanceof PlaceholderType //Es werden alle Elemente des Kartesischen Produkts abgearbeitet variance = optVariance.isPresent() ? optVariance.get() : 2; } - //if (variance == 1 && nextSetasList.size() > 1) { - // List> al = new ArrayList<>(nextSetasList.size()); - // for (int ii = 0; ii < nextSetasList.size();ii++) { - // al.add(0,nextSetasList.get(ii)); - // } - // nextSetasList = al; - //} - //Set a = nextSetasListIt.next(); - /*if (nextSetasList.size()>1) {zu loeschen - if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D")) - System.out.print(""); - if (variance == 1) { - a_next = oup.max(nextSetasList.iterator()); - } - else if (variance == -1) { - a_next = oup.min(nextSetasList.iterator()); - } - else if (variance == 0) { - a_next = nextSetasList.iterator().next(); - } - } - else { - a_next = nextSetasList.iterator().next(); - } - */ - if (variance == 2) { - writeLog("VARIANCE2 " + nextSetasList.toString()); - Set XX = nextSetasList.iterator() - .next() - .stream() - .filter(x -> - x.getGroundBasePair().getLhsType() instanceof PlaceholderType && - ! (x.getRhsType() instanceof PlaceholderType) && - x.getPairOp() == PairOperator.EQUALSDOT) - .collect(Collectors.toCollection(HashSet::new)); - - Set sI = XX.stream() - .map(x -> - ((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance()) - .collect(Collectors.toCollection(HashSet::new));; - Optional oI = sI.stream() - .findAny(); - variance = oI.isPresent() ? oI.get() : 2; - System.out.println(""); - - } if (!nextSetasList.iterator().hasNext()) System.out.print(""); if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1) @@ -741,6 +696,8 @@ public class TypeUnifyTask extends RecursiveTask>> { List> nextSetasListRest = new ArrayList<>(); //List> nextSetasListRestMin = new ArrayList<>(); //List> nextSetasListRestOder = new ArrayList<>(); + writeLog("WhileAnfangNextSet: " + nextSet.toString()); + writeLog("WhileAnfangNextSetasList: " + nextSetasList.toString()); if (variance == 1) { a = oup.max(nextSetasList.iterator()); nextSetasList.remove(a); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java index 690e4c43..76383920 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java @@ -203,7 +203,7 @@ public class OrderingUnifyPair extends Ordering> { Set lefteqOder = left.stream() .filter(x -> { UnifyPair y = x.getGroundBasePair(); - try { + /*try { ((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n"); ((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n"); ((FiniteClosure)fc).logFile.write("left: " + left.toString() +"\n"); @@ -214,15 +214,15 @@ public class OrderingUnifyPair extends Ordering> { ((FiniteClosure)fc).logFile.write("x.getPairOp(): " + x.getPairOp().toString() +"\n\n"); } catch (IOException ie) { - } + } */ return (y.getLhsType() instanceof PlaceholderType && - y.getRhsType() instanceof ReferenceType && + !(y.getRhsType() instanceof PlaceholderType) && x.getPairOp() == PairOperator.EQUALSDOT);}) .collect(Collectors.toCollection(HashSet::new)); Set righteqOder = right.stream() .filter(x -> { UnifyPair y = x.getGroundBasePair(); return (y.getLhsType() instanceof PlaceholderType && - y.getRhsType() instanceof ReferenceType && + !(y.getRhsType() instanceof PlaceholderType) && x.getPairOp() == PairOperator.EQUALSDOT);}) .collect(Collectors.toCollection(HashSet::new)); Set lefteqRet = left.stream() @@ -243,7 +243,7 @@ public class OrderingUnifyPair extends Ordering> { .collect(Collectors.toCollection(HashSet::new)); - synchronized(this) { + /* synchronized(this) { try { ((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n"); ((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n"); @@ -260,6 +260,7 @@ public class OrderingUnifyPair extends Ordering> { catch (IOException ie) { } } + */ if (lefteqOder.size() == 1 && righteqOder.size() == 1 && lefteqRet.size() == 1 && righteqRet.size() == 1) {