diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 06fdd8f6..8a42a4c3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -715,19 +715,13 @@ public class SourceFile retValue = Unify.unify(pairs, finiteClosure); return retValue;}; //oderConstraints.filterWrongConstraints(unifier); - oderConstraints.unifyUndConstraints(unifier); + + //oderConstraints.unifyUndConstraints(unifier); //rausgeworfen für Tests (08.12.2015) + typinferenzLog.debug("Übriggebliebene Konstraints:\n"+oderConstraints+"\n", Section.TYPEINFERENCE); //Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden): Menge> xConstraints = oderConstraints.cartesianProduct(); - /* - for(Menge uC : oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt. - Menge cons = new Menge(); - for(UndConstraint undCons:uC){ - cons.addAll(undCons.getConstraintPairs()); - } - xConstraints.add(cons); - } - */ + typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints, Section.TYPEINFERENCE); finiteClosure.generateFullyNamedTypes(globalAssumptions); @@ -750,53 +744,9 @@ public class SourceFile } } - /* - //Alle Generischen Typvariablen in TPH umwandeln: - HashMap gtv2tph = new HashMap(); - for(Pair pair : constraints){ - if(pair.TA1 instanceof GenericTypeVar){ - TypePlaceholder tph = gtv2tph.get(pair.TA1); - if(tph == null){ - tph = TypePlaceholder.fresh(); - gtv2tph.put((GenericTypeVar)pair.TA1, tph); - } - pair.TA1 = tph; - } - if(pair.TA2 instanceof GenericTypeVar){ - TypePlaceholder tph = gtv2tph.get(pair.TA2); - if(tph == null){ - tph = TypePlaceholder.fresh(); - gtv2tph.put((GenericTypeVar)pair.TA2, tph); - } - pair.TA2 = tph; - } - } - */ //Erst die Unifizierung erstellen: Menge constraintsClone = (Menge)constraints.clone(); - /* - //Typen kontrollieren: - for(Pair p : constraintsClone){ - Type t = p.TA1; - //TypeCheck, falls es sich um einen RefType handelt: - if(t!=null && (t instanceof RefType)&& - !(t instanceof de.dhbwstuttgart.syntaxtree.type.Void)){ - Type replaceType = null; - replaceType = globalAssumptions.getTypeFor((RefType)t, null); - if(!(replaceType == null))p.TA1 = replaceType; - } - t = p.TA2; - //TypeCheck, falls es sich um einen RefType handelt: - if(t!=null && (t instanceof RefType)&& - !(t instanceof de.dhbwstuttgart.syntaxtree.type.Void)){ - Type replaceType = null; - replaceType = globalAssumptions.getTypeFor((RefType)t, null); - if(!(replaceType == null))p.TA2 = replaceType; - } - } - */ - //IDEE: Man bildet Zusammenhangskomponenten von Paaren, die gemeinsame Variablen haben // und unifizert nur die Zusammenhangskomponenten in Schritten 1 - 5 @@ -842,28 +792,6 @@ public class SourceFile Menge> cardprodret_start = new Menge<>(); cardprodret_start.add(new Menge()); - //cart. Produkt mit kopieren - //Menge> unifyResult = vecunifyResult.stream().reduce(cardprodret_start, (x, y) -> { - //Menge> cardprodret= new Menge<>(); - //if (y.size() > 0) { - ////System.out.println(y); - //Menge> cardprodretold = x; - //cardprodret = new Menge<>(); - //for(int j = 0; j < cardprodretold.size(); j++) { - //for (int k = 0; k < y.size(); k++){ - //Menge help; - //if (y.size() == 1) help = cardprodretold.elementAt(j); //bei einem hinzuzufuegenden Element muss nicht kopiert werden - //else help = Unify.copyMengePair(cardprodretold.elementAt(j)); - //help.addAll(y.elementAt(k)); - //cardprodret.add(help); - //} - //} - //} - //else - //return new Menge<>(); //kein unifiziertes Ergebnis, damit wird das Geseamtergebnis [] - //return cardprodret; - //}); - //cart. Produkt mit Linkverschiebung Menge> unifyResult = vecunifyResult.stream().reduce(cardprodret_start, (x, y) -> { Menge> cardprodret= new Menge<>(); @@ -885,34 +813,9 @@ public class SourceFile return cardprodret; }); - //Menge> unifyResult = Unify.unify(constraintsClone, finiteClosure); //Dann den Ergebnissen anfügen result.addAll(unifyResult); - // Debugoutput:Menge> - - //typinferenzLog.debug("Unifiziertes Ergebnis: "+result, Section.TYPEINFERENCE); - - /* - // Prüfe ob eindeutige Lösung: - if(result.size()>1 && !Unify.hasSolvedForm(result.elementAt(0))){ - - typinferenzLog.debug("Keine eindeutige Lösung!"); - - }else if(result.size()>1){ - - //Replace TPH: - for(Pair res : result.elementAt(0)){ - if(res.OperatorEqual()){ - if(res.TA1 instanceof TypePlaceholder)((TypePlaceholder)res.TA1).fireReplaceTypeEvent(new CReplaceTypeEvent(res.TA1, res.TA2)); - } - } - } - */ - //typinferenzLog.debug(); - //typinferenzLog.debug(supportData.getFiniteClosure()); - //typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers)); - typinferenzLog.debug("\nJavaFiles:\n", Section.TYPEINFERENCE); //typinferenzLog.debug(this.printJavaCode(new ResultSet(new Menge())));