From 144c31a4cb96bf327bebeb78be18be4e2b6f13ac Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 8 Apr 2015 21:23:28 +0200 Subject: [PATCH] =?UTF-8?q?Bei=20der=20Generierung=20der=20FiniteClosure?= =?UTF-8?q?=20werden=20nun=20Beziehungen=20zu=20Superklassen,=20welche=20I?= =?UTF-8?q?mportiert=20wurden,=20korrekt=20angef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/de/dhbwstuttgart/syntaxtree/Class.java | 1 + src/de/dhbwstuttgart/syntaxtree/SourceFile.java | 17 ++++++++++++++--- .../typeinference/unify/Unify.java | 1 + test/plugindevelopment/TypeInsertTests/Add.java | 3 +++ .../TypeInsertTests/LambdaTest5.jav | 2 +- .../TypeInsertTests/OverloadingRecursive.java | 3 ++- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index 9bf64ff5..75108071 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -185,6 +185,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I public Class(String name, RefType superClass, Modifiers mod, int offset){ this(name,mod,offset); if(superClass == null)this.superClass = new Class("Object",-1).getType(); + else this.superClass = superClass; } // ino.method.Class.23044.definition diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 522727fb..360d2eef 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -310,15 +310,26 @@ public class SourceFile TypeAssumptions globalAssumptions = this.makeBasicAssumptionsFromJRE(imports, false); globalAssumptions.add(this.getPublicFieldAssumptions()); // 1. Menge <= in FC aufnehmen --> Iteration ueber alle Klassen - - Vector basicAssumptionsClassVector = new Vector<>(); //die Klassen aus den BasicAssumptions + + Vector ignoreTypes = new Vector<>(); //Enthält die Typen, welche nicht in der FC als Supertypen enthalten sein sollen. + ignoreTypes.add(new RefType("Long",null,-1).TYPE(globalAssumptions, parent).getType()); + ignoreTypes.add(new RefType("Float",null,-1).TYPE(globalAssumptions, parent).getType()); + ignoreTypes.add(new RefType("Double",null,-1).TYPE(globalAssumptions, parent).getType()); + ignoreTypes.add(new RefType("String",null,-1).TYPE(globalAssumptions, parent).getType()); + ignoreTypes.add(new RefType("Integer",null,-1).TYPE(globalAssumptions, parent).getType()); + ignoreTypes.add(new RefType("Object",null,-1).TYPE(globalAssumptions, parent).getType()); + + Vector basicAssumptionsClassVector = new Vector<>(); //die Klassen aus den BasicAssumptions und den Importierten Klassen for(ClassAssumption cAss : ass.getClassAssumptions()){ Type t1 = cAss.getAssumedClass().getType(); Type t2 = cAss.getAssumedClass().getSuperClass(); Pair p = new Pair(t1, t2); //System.out.println("FCPair: "+p); if(! t1.equals(t2)){//Um FC_TTO darf kein T <. T stehen. - //vFC.add(p); //Wird momentan nicht hinzugefügt + Type superTypeFromAssumptions = ass.getTypeFor(t2, t2).getType(); //In den Assumptions den SuperTyp nachschlagen + if(superTypeFromAssumptions != null && ! ignoreTypes.contains(superTypeFromAssumptions)){//Die Superklasse eines Typs nur anfügen, wenn er auch in den Assumptions vorkommt. + vFC.add(p); + } basicAssumptionsClassVector.add(cAss.getAssumedClass());//Klasse ohne die Superklasse anfügen }else{ //System.out.println("Wurde nicht aufgenommen"); diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index 75039c68..5977b8a2 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -620,6 +620,7 @@ public class Unify } } //Schritt 4, Teil 2: Kartesisches Produkt bilden. + //TODO: Vor der Bildung des Karthesischen Produkts unmögliche Kombinationen ausfiltern //Hier wird aus den in Schritt 4, Teil 1 erzeugten Vektoren das Kartesische Produkt gebilden. Vector helpvp; Vector> bigCartProductErg = new Vector>(); diff --git a/test/plugindevelopment/TypeInsertTests/Add.java b/test/plugindevelopment/TypeInsertTests/Add.java index 6a00e7b0..577d24c1 100644 --- a/test/plugindevelopment/TypeInsertTests/Add.java +++ b/test/plugindevelopment/TypeInsertTests/Add.java @@ -1,5 +1,7 @@ package plugindevelopment.TypeInsertTests; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import org.junit.Test; @@ -12,5 +14,6 @@ public class Add { Vector mustContain = new Vector(); //mustContain.add("TestIfStmt var"); MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); + ArrayList l = new ArrayList(); } } diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest5.jav b/test/plugindevelopment/TypeInsertTests/LambdaTest5.jav index 4c00bc85..8baed3b3 100755 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest5.jav +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest5.jav @@ -1,5 +1,5 @@ class LambdaTest{ -Fun1 op = (var) -> {return var;}; +Fun1 op = (var) -> {return var;}; } \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/OverloadingRecursive.java b/test/plugindevelopment/TypeInsertTests/OverloadingRecursive.java index 6c394ab4..65833bb1 100644 --- a/test/plugindevelopment/TypeInsertTests/OverloadingRecursive.java +++ b/test/plugindevelopment/TypeInsertTests/OverloadingRecursive.java @@ -13,6 +13,7 @@ public class OverloadingRecursive { Vector mustContain = new Vector(); //mustContain.add("Fun0>> op"); - MultipleTypesInsertTester.test(this.TEST_FILE, mustContain); + //Untypisierbar + //MultipleTypesInsertTester.test(this.TEST_FILE, mustContain); } }