From d677d053d683ad62260b877df047291a04e7eb70 Mon Sep 17 00:00:00 2001
From: AluAli <memtoo@gmx.de>
Date: Thu, 29 Oct 2020 19:40:46 +0100
Subject: [PATCH] 	modified:  
 src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java
 	modified:  
 src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java

---
 .../FamilyOfGeneratedGenerics.java            | 122 +++++++++---------
 .../GeneratedGenericsFinder.java              |   2 +-
 2 files changed, 61 insertions(+), 63 deletions(-)

diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java
index 8a363983..0b696c13 100644
--- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java
+++ b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java
@@ -3,67 +3,52 @@ package de.dhbwstuttgart.bytecode.gGenericsAli;
 import de.dhbwstuttgart.bytecode.TPHExtractor;
 import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
 import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
-import de.dhbwstuttgart.bytecode.genericsGenerator.ConstraintsSimplierResult;
-import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
-import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
-import de.dhbwstuttgart.syntaxtree.Method;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
-    private final TPHExtractor tphExtractor = new TPHExtractor();
-    private final List<TPHConstraint> cs = tphExtractor.allCons; //alle Constraints bekommen wie?
-    public FamilyOfGeneratedGenerics(List<TPHConstraint> cs) {
-        this.cs = cs;
+//    private TPHExtractor tphExtractor = new TPHExtractor();
+    public List<TPHConstraint> cs; //alle Constraints bekommen wie?
+//    public FamilyOfGeneratedGenerics(List<TPHConstraint> cs) {
+//        this.cs = cs;
+//    }
+    public List<ClassConstraint> cs_cl;
+    public List<MethodConstraint> cs_m;
+
+    public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) {
+        cs = (List<TPHConstraint>) tphExtractor.allCons;
+        cs_cl = new ArrayList<ClassConstraint>();
+        cs_m = new ArrayList<MethodConstraint>();
+    }
+    public void printCs() {
+        System.out.println(cs);
+        System.out.println(cs);
+        System.out.println("-----------------------------------------------------------------------------");
     }
 
-    List<ClassConstraint> cs_cl = null;
-    List<MethodConstraint> cs_m = null;
-
-    /*public Type getLeftSideOfConstraint(TPHConstraint constraint) {
-        Type leftSideType = null;
-        if(!(getRelationOfConstraint(constraint) == Relation.EXTENDS)) {
-            continue;
-        } else {
-            leftSideType = constraint.getLeft();
-        }
-        return leftSideType;
-    }*/
-
-    public String getLeftSideOfConstraint(TPHConstraint constraint) {
-        if(constraint.getRel() == Relation.EXTENDS)
-            return constraint.getLeft();
-        return null;
-    }
-
-    /*public Type getRightSideOfConstraint(TPHConstraint constraint) {
-        Type rightSideType = null;
-        if(!(getRelationOfConstraint(constraint) == Relation.EXTENDS)) {
-            continue;
-        } else {
-            rightSideType = constraint.getRight();
-        }
-        return rightSideType;
-    }*/
-
-    public String getRightSideOfConstraint(TPHConstraint constraint) {
-        if(constraint.getRel() == Relation.EXTENDS)
-            return constraint.getRight();
-        return null;
-    }
-
-    /*public Relation getRelationOfConstraint(TPHConstraint constraint) {
-        return constraint.getRel();
-    }*/
-
-
-    public void addConstraintToClassConstraint(List<TPHConstraint> constraintsSet) {
-        //TODO: Regeln
-//        for(TPHConstraint cons: constraintsSet){
+//    public String getLeftSideOfConstraint(TPHConstraint constraint) {
+//        if(constraint.getRel() == Relation.EXTENDS)
+//            return constraint.getLeft();
+//        return null;
+//    }
 //
-//            cs_cl =
-//        }
-        List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(constraintsSet);
+//    public String getRightSideOfConstraint(TPHConstraint constraint) {
+//        if(constraint.getRel() == Relation.EXTENDS)
+//            return constraint.getRight();
+//        return null;
+//    }
+
+    public List<TPHConstraint> getCs() {
+        return cs;
+    }
+
+    //    public List<ClassConstraint,MethodConstraint> getFamilyOfGeneratedGenerics(){
+//
+//    }
+
+    public void addConstraintToClassConstraint() { //Inputparameter List<TPHConstraint> constraintsSet weg
+        List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(cs);
         cs_cl.addAll(classConstraints1);
         List<ClassConstraint> classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
         cs_cl.addAll(classConstraints2);
@@ -87,10 +72,14 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
     public List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> cs) {
         //TODO:
         for(TPHConstraint cons: cs){
+            System.out.println(cons);
+            System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
             if(cons.getRight()!=null && cons.getRel()==Relation.EXTENDS) {
                 cs_cl.add(new ClassConstraint(cons.getLeft(), cons.getRight(),cons.getRel()));
             }
         }
+        System.out.println(cs_cl);
+        System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
         return cs_cl;
     }
 
@@ -101,11 +90,14 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
     public List<ClassConstraint> transitiveSubtypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> classConstraints) {
         //TODO:
         for(ClassConstraint cCons: classConstraints) {
+            for(TPHConstraint allCons: allConstraints)
 //            if(tphExtractor.containsConstraint(allConstraints, cCons)) {
 //            }
-            if(cCons.getRight() == )
-        }
+            if(cCons.getRight() == allCons.getLeft()){
 
+            }
+        }
+        return cs_cl;
     }
 
     /**
@@ -114,7 +106,8 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
      *                  or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)}
      */
     public List<ClassConstraint> hasNoSupertypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> classConstraints) {
-
+        //TODO:
+        return cs_cl;
     }
 
 
@@ -123,7 +116,8 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
      * {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs}
      */
     public List<MethodConstraint> typeOfTheMethodInClSigma() { // cl_\sigma??
-
+        //TODO:
+        return cs_m;
     }
 
     /**
@@ -131,7 +125,8 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
      * {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs}
      */
     public List<MethodConstraint> firstTransitiveSubtypeForMethodTypes() { //transitive closure of cs
-
+        //TODO:
+        return cs_m;
     }
 
     /**
@@ -139,7 +134,8 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
      * {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs}
      */
     public List<MethodConstraint> secondTransitiveSubtypeForMethodTypes() {
-
+        //TODO:
+        return cs_m;
     }
 
     /**
@@ -148,14 +144,16 @@ public class FamilyOfGeneratedGenerics {    // extends TPHConstraint?
      *                  (\existsnot T': T <. T') \in cs)}
      */
     public List<MethodConstraint> hasNoSupertypeForMethodTypes() {
-
+        //TODO:
+        return cs_m;
     }
 
     /**
      * nimm die Menge cs_cl aus cs_m raus
      */
     public List<MethodConstraint> methodTypesWithoutClassTypes() {
-
+        //TODO:
+        return cs_m;
     }
 
 
diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java
index dbda63b3..8672ce8c 100644
--- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java
+++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java
@@ -136,7 +136,7 @@ public class GeneratedGenericsFinder implements ASTVisitor {
 			//PL 2020-10-16: Ab hier GGenerics implementieren durch Ali
 			//Rueckgabe an generatedGenericsForSF
 			fogg = new FamilyOfGeneratedGenerics(tphExtractor);
-			
+			fogg.addConstraintToClassConstraint();
 			
 			tphsClass = tphExtractor.tphsClass;
 			simplifiedConstraints = GenericsGenerator.simplifyConstraints(tphExtractor, tphsClass);