diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index a9d02c955..103f46b02 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -830,8 +830,10 @@ public class TypeUnifyTask extends RecursiveTask>> { //erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen Set fstElemResult = result.iterator().next(); Set compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));; - if (variance == 1) { + writeLog("a_last:" + a_last + " a: " + a); + writeLog("varsLast_a:" + varsLast_a + " vars_a: " + vars_a); + writeLog("compResult:" + compResult + " compRes: " + compRes); int resOfCompare = oup.compare(compResult, compRes); if (resOfCompare == -1) { writeLog("Geloescht result: " + result); @@ -845,6 +847,9 @@ public class TypeUnifyTask extends RecursiveTask>> { //result = result; }}} else { if (variance == -1) { + writeLog("a_last:" + a_last + " a: " + a); + writeLog("varsLast_a:" + varsLast_a + " vars_a: " + vars_a); + writeLog("compResult:" + compResult + " compRes: " + compRes); int resOfCompare = oup.compare(compResult, compRes); if (resOfCompare == 1) { writeLog("Geloescht result: " + result); @@ -886,27 +891,33 @@ public class TypeUnifyTask extends RecursiveTask>> { Iterator> nextSetasListIt = new ArrayList>(nextSetasList).iterator(); if (variance == 1) { System.out.println(""); + writeLog("a: " + a.toString()); while (nextSetasListIt.hasNext()) { Set a_next = nextSetasListIt.next(); if (a.equals(a_next) || (oup.compare(a, a_next) == 1)) { + writeLog("Removed: " + a_next.toString()); nextSetasList.remove(a_next); } else { + writeLog("Not Removed: " + a_next.toString()); System.out.println(""); } } } else { if (variance == -1) { System.out.println(""); + writeLog("a: " + a.toString()); while (nextSetasListIt.hasNext()) { Set a_next = nextSetasListIt.next(); if (a.equals(a_next) || (oup.compare(a, a_next) == -1)) { - nextSetasList.remove(0); + writeLog("Removed: " + a_next.toString()); + nextSetasList.remove(a_next); //PL geaendert 2019-01-09 } else { System.out.println(""); + writeLog("Not Removed: " + a_next.toString()); } } } @@ -1670,13 +1681,12 @@ public class TypeUnifyTask extends RecursiveTask>> { } //eingefuegt PL 2019-01-03 ANFANG - fc.setLogTrue(); - writeLog("FBOUNDED: " + pair.getfBounded()); - writeLog("Pair: " + pair); + //fc.setLogTrue(); + //writeLog("FBOUNDED: " + pair.getfBounded()); + //writeLog("Pair: " + pair); Set greater = fc.greater(theta, pair.getfBounded()); - writeLog("GREATER: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " "); - - /*if (a.isWildcardable()) { + //writeLog("GREATER: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " "); + if (a.isWildcardable()) { Set greater_ext = greater.stream().filter(x -> !(x instanceof ExtendsType) && !(x instanceof SuperType)) .map(x -> { //BinaryOperator> combiner = (aa,b) -> { aa.putAll(b); return aa;}; //Variablenumbenennung rausgenommen @@ -1688,7 +1698,7 @@ public class TypeUnifyTask extends RecursiveTask>> { greater.addAll(greater_ext); } //eingefuegt PL 2019-01-03 ENDE - */ + //for(UnifyType thetaS : fc.greater(theta, pair.getfBounded())) { for(UnifyType thetaS : greater) { Set resultPrime = new HashSet<>(); @@ -1726,7 +1736,7 @@ public class TypeUnifyTask extends RecursiveTask>> { resultPrime.add(new UnifyPair(a, thetaS.setTypeParams(new TypeParams(freshTphs)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new)); result.add(resultPrime); - writeLog("FBOUNDED2: " + pair.getfBounded()); + //writeLog("FBOUNDED2: " + pair.getfBounded()); //writeLog("resultPrime Theta < a: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " " + resultPrime.toString()); } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java index b0198f87f..f928ea24f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -223,6 +223,7 @@ implements IFiniteClosure { // if T <* T' then sigma(T) <* sigma(T') Set> candidates = strInheritanceGraph.get(type.getName()); + /* try { if (log) logFile.write(candidates.toString()); //log = false; @@ -230,6 +231,7 @@ implements IFiniteClosure { catch (IOException e) { System.err.println("no LogFile"); } + */ for(Node candidate : candidates) { UnifyType theta1 = candidate.getContent(); @@ -240,10 +242,6 @@ implements IFiniteClosure { Optional optSigma = match.match(termList); //PL 18-04-05 Unifier durch Matcher ersetzt ENDE if(!optSigma.isPresent()) { - if ((type.getName().equals("java.util.Vector")) && (type instanceof ReferenceType) && - (((ReferenceType)type).getTypeParams().get(0).getName().equals("java.lang.Integer"))) { - System.out.println(type.toString() + candidates); - } continue; } Unifier sigma = optSigma.get(); @@ -258,6 +256,7 @@ implements IFiniteClosure { PairResultFBounded.add(new Pair<>(theta2.apply(sigma), fBoundedNew)); } } + /* try { if (log) logFile.write(PairResultFBounded.toString()); log = false; @@ -265,6 +264,7 @@ implements IFiniteClosure { catch (IOException e) { System.err.println("no LogFile"); } + */ for(Pair> pt : PairResultFBounded) { UnifyType t = pt.getKey(); Set lfBounded = pt.getValue().get(); 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 636a60291..249892eda 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java @@ -54,6 +54,20 @@ public class OrderingUnifyPair extends Ordering> { UnifyPair up; if (left instanceof WildcardType || right instanceof WildcardType) { up = new UnifyPair(left, right, PairOperator.SMALLERDOTWC); + if (((left instanceof ExtendsType) + && (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) || + ((right instanceof ExtendsType) + && (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType))) + { + System.out.println(""); + } + if (((right instanceof SuperType) && (((SuperType)right).getSuperedType().getName().equals("java.lang.Object"))) + ||((left instanceof SuperType) && (((SuperType)left).getSuperedType().getName().equals("java.lang.Object")))) +{ + System.out.println(""); + } } else { up = new UnifyPair(left, right, PairOperator.SMALLERDOT); @@ -67,6 +81,19 @@ public class OrderingUnifyPair extends Ordering> { else { if (left instanceof WildcardType || right instanceof WildcardType) { up = new UnifyPair(right, left, PairOperator.SMALLERDOTWC); + if (((left instanceof ExtendsType) + && (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) || + ((right instanceof ExtendsType) + && (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType))) + { + System.out.println(""); + } + if (right instanceof SuperType) + { + System.out.println(""); + } } else { up = new UnifyPair(right, left, PairOperator.SMALLERDOT); @@ -87,6 +114,16 @@ public class OrderingUnifyPair extends Ordering> { * @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object) */ public int compare (Set left, Set right) { + if ((left.size() == 1) && right.size() == 1) { + if (left.iterator().next().getLhsType().getName().equals("AFS")) { + System.out.println(""); + } + if (((right.iterator().next().getRhsType() instanceof SuperType) && (((SuperType)right.iterator().next().getRhsType()).getSuperedType().getName().equals("java.lang.Object"))) + ||((left.iterator().next().getRhsType() instanceof SuperType) && (((SuperType)left.iterator().next().getRhsType()).getSuperedType().getName().equals("java.lang.Object")))) + { + System.out.println(""); + } + } Set lefteq = left.stream() .filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT)) .collect(Collectors.toCollection(HashSet::new)); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java index 1266a8241..f3e5eb023 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java @@ -224,7 +224,7 @@ public class UnifyPair { if (rhs instanceof PlaceholderType) { ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString(); } - return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + "])"; //+ ", [" + getfBounded().toString()+ "])"; + return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ")"; //+ ", [" + getfBounded().toString()+ "])"; } /*