diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index 6f25a763..c09c90b0 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -29,6 +29,7 @@ import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; +import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask; import java.io.File; import java.io.FileOutputStream; @@ -200,7 +201,9 @@ public class JavaTXCompiler { if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); return y; //alle Paare a <.? b erden durch a =. b ersetzt }).collect(Collectors.toCollection(HashSet::new))); - if (res.isPresent()) return res.get(); //wenn subst ein Erg liefert wurde was veraendert + if (res.isPresent()) {//wenn subst ein Erg liefert wurde was veraendert + return new TypeUnifyTask().applyTypeUnificationRules(res.get(), finiteClosure); + } else return x; //wenn nichts veraendert wurde wird x zurueckgegeben }).collect(Collectors.toCollection(HashSet::new)); System.out.println("RESULT Final: " + results); diff --git a/src/de/dhbwstuttgart/typeinference/result/ResultSet.java b/src/de/dhbwstuttgart/typeinference/result/ResultSet.java index 44cd749c..eef72ab0 100644 --- a/src/de/dhbwstuttgart/typeinference/result/ResultSet.java +++ b/src/de/dhbwstuttgart/typeinference/result/ResultSet.java @@ -48,6 +48,7 @@ class Resolver implements ResultSetVisitor { public ResolvedType resolve(TypePlaceholder tph){ toResolve = tph; resolved = null; + System.out.println(tph.toString()); for(ResultPair resultPair : result.results){ if(resultPair instanceof PairTPHEqualTPH && ((PairTPHEqualTPH) resultPair).getLeft().equals(toResolve)){ return resolve(((PairTPHEqualTPH) resultPair).getRight()); @@ -113,6 +114,8 @@ class Resolver implements ResultSetVisitor { } + + } /** diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index c66c6220..5a9085cd 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -379,6 +379,8 @@ public class TYPEStmt implements StatementVisitor{ return; } if (literal.value instanceof Integer) { + //constraintsSet.addUndConstraint(new Pair(literal.getType(),integer, PairOperator.EQUALSDOT)); + // /* Set oderConstraints = new HashSet<>(); Constraint constraint = new Constraint(); constraint.add(new Pair(literal.getType(), integer, PairOperator.EQUALSDOT)); @@ -387,6 +389,7 @@ public class TYPEStmt implements StatementVisitor{ constraint.add(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT)); oderConstraints.add(constraint); constraintsSet.addOderConstraint(oderConstraints); + // */ return; } if (literal.value instanceof Short) { diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index f51c351e..42cd4835 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -25,6 +25,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify; import de.dhbwstuttgart.typeinference.unify.model.ExtendsType; import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType; +import de.dhbwstuttgart.typeinference.unify.model.ReferenceType; import de.dhbwstuttgart.typeinference.unify.model.SuperType; import de.dhbwstuttgart.typeinference.unify.model.TypeParams; import de.dhbwstuttgart.typeinference.unify.model.Unifier; @@ -589,8 +590,10 @@ public class TypeUnifyTask extends RecursiveTask>> { })//.filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) fuer testzwecke auskommentiert um nofstred zu bestimmen PL 2018-10-10 .collect(Collectors.toCollection(ArrayList::new)); nofstred = nextSetasList.size(); - nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) - .collect(Collectors.toCollection(ArrayList::new)); + //NOCH NICHT korrekt PL 2018-10-12 + //nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) + // .collect(Collectors.toCollection(ArrayList::new)); + writeLog("res (undef): " + res.toString()); writeLog("abhSubst: " + abhSubst.toString()); writeLog("a: " + a.toString()); writeLog("Durchschnitt: " + durchschnitt.toString()); @@ -625,10 +628,15 @@ public class TypeUnifyTask extends RecursiveTask>> { if (!substRes.isPresent()) { return true; } + //PL 2018-10-12 + //Evtl. zurest applyTypeUnification aufrufen + //evtl auch unify aufrufen else { UnifyPair checkPair = substRes.get().stream() .filter(x -> x.getGroundBasePair().equals(pair.getValue().get())).findFirst().get(); - if ((checkPair.getLhsType() instanceof PlaceholderType) || (checkPair.getRhsType() instanceof PlaceholderType)) { + if (((checkPair.getLhsType() instanceof PlaceholderType) || (checkPair.getRhsType() instanceof PlaceholderType)) + && (checkPair.getPairOp() == PairOperator.SMALLERDOT || checkPair.getPairOp() == PairOperator.SMALLERDOTWC)) + { Set up = new HashSet<>(); up.add(checkPair); Set undef = new HashSet<>(); @@ -637,11 +645,19 @@ public class TypeUnifyTask extends RecursiveTask>> { return true; } else { + writeLog("Second erase:" +checkPair.toString()); return false; } + } else { + if ((checkPair.getLhsType() instanceof ReferenceType) && (checkPair.getRhsType() instanceof ReferenceType)) + // && (checkPair.getPairOp() == PairOperator.SMALLERDOT || checkPair.getPairOp() == PairOperator.SMALLERDOTWC) + { + Set setCheckPair = new HashSet<>(); + setCheckPair.add(checkPair); + return isUndefinedPairSet(applyTypeUnificationRules(setCheckPair, fc)); + } else { + //Pair type <. ? extends ? extends type betrachten TODO PL 2018-10-09 } - else { - //Pair type <. type' betrachten TODO PL 2018-10-09 } } return true;}).reduce((xx, yy) -> xx || yy).get(); diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/Pair.java b/src/de/dhbwstuttgart/typeinference/unify/model/Pair.java index 08c4aa1c..de05c97d 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/Pair.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/Pair.java @@ -18,4 +18,8 @@ public class Pair { public T getKey() { return key; } + + public String toString() { + return "(" + key.toString() + "," + "," + value.toString() + ")\n"; + } }