From e9bcea4b9e3b0c788a9a2421f5215e1759626ffb Mon Sep 17 00:00:00 2001 From: AluAli Date: Mon, 21 Dec 2020 14:06:47 +0100 Subject: [PATCH 1/3] modified: src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java --- .../bytecode/genericsGenerator/GeneratedGenericsFinder.java | 2 +- .../bytecode/insertGenerics/FamilyOfGeneratedGenerics.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java index 5718e72d..871dd300 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java @@ -151,7 +151,7 @@ public class GeneratedGenericsFinder implements ASTVisitor { if(ggResult != null) generatedGenericsForSF.addGenericGeneratorResultClass(ggResult); - + System.out.println("ddd"); } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 4f7d25ed..05d7b3d7 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -11,6 +11,7 @@ import java.util.List; public class FamilyOfGeneratedGenerics { public List allConstraints = new ArrayList<>(); + // HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode public HashMap> posOfTPHs = new HashMap<>(); public List classConstraints = new ArrayList<>(); From 7139a1709edcf14fe9bf3506752912534332ea58 Mon Sep 17 00:00:00 2001 From: AluAli Date: Tue, 22 Dec 2020 16:08:01 +0100 Subject: [PATCH 2/3] modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java --- .../FamilyOfGeneratedGenerics.java | 39 +++++++++++++++++-- .../FamilyOfGeneratedGenericsTest.java | 4 ++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 05d7b3d7..71b4886b 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -3,6 +3,7 @@ package de.dhbwstuttgart.bytecode.insertGenerics; import de.dhbwstuttgart.bytecode.TPHExtractor; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult; import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; import java.util.ArrayList; @@ -14,11 +15,13 @@ public class FamilyOfGeneratedGenerics { // HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode public HashMap> posOfTPHs = new HashMap<>(); public List classConstraints = new ArrayList<>(); + public List methodConstraints = new ArrayList<>(); public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) { this.allConstraints = tphExtractor.allCons; this.posOfTPHs = positionConverter(tphExtractor.allTPHS, tphExtractor.ListOfMethodsAndTph); this.classConstraints = getClassConstraints(allConstraints,posOfTPHs); +// this.methodConstraints = } public static List getClassConstraints(List cs, HashMap> posOfTphs) { //Inputparameter List constraintsSet weg @@ -44,6 +47,11 @@ public class FamilyOfGeneratedGenerics { return cs_cl; } + public static List getMethodConstraintsAlternative() { + List ggRes = GenericsGeneratorResult. + return null; + } + public static List getMethodConstraints(List cs, HashMap> posOfTphs) { //TODO: Regeln List cs_m = new ArrayList<>(); @@ -166,9 +174,22 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs} */ - public static List firstTransitiveSubtypeForMethodTypes() { //transitive closure of cs + public static List firstTransitiveSubtypeForMethodTypes(List allConstraints, List cs_m, HashMap> posOfTphs) { //transitive closure of cs //TODO: - return null; + List tempCC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(MethodConstraint mC1 : cs_m) { + for(MethodConstraint mC2 : cs_m) { + String rightSide = mC1.getRight(); + String leftSide = mC2.getLeft(); + for(TPHConstraint tphC : tcOfCs) { + if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) { + tempCC.add((MethodConstraint) tphC); + } + } + } + } + return tempCC; } /** @@ -176,8 +197,20 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs} */ - public static List secondTransitiveSubtypeForMethodTypes() { + public static List secondTransitiveSubtypeForMethodTypes(List allConstraints, List cs_m, HashMap> posOfTphs) { //TODO: + List tempCC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(MethodConstraint mC1 : cs_m) { + for(MethodConstraint mC2 : cs_m) { + String rightSide = mC1.getRight(); + String leftSide = mC2.getLeft(); + for(TPHConstraint tphC : tcOfCs) { + + } + } + } + return null; return null; } diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index b6eb41ce..cb3f6840 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -199,4 +199,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } + public void testFirstTransitiveSubtypeForMethodTypes(){ + + } + } \ No newline at end of file From 5ed6a4617a2d0aaaf2662fa10649e92fedd60d30 Mon Sep 17 00:00:00 2001 From: AluAli Date: Tue, 22 Dec 2020 16:11:24 +0100 Subject: [PATCH 3/3] modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java --- .../FamilyOfGeneratedGenerics.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 71b4886b..50170cdf 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -197,21 +197,22 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs} */ - public static List secondTransitiveSubtypeForMethodTypes(List allConstraints, List cs_m, HashMap> posOfTphs) { + public static List secondTransitiveSubtypeForMethodTypes(List allConstraints, List cs_cl, List cs_m, HashMap> posOfTphs) { //TODO: List tempCC= new ArrayList<>(); List tcOfCs = buildTransitiveClosure(allConstraints); - for(MethodConstraint mC1 : cs_m) { - for(MethodConstraint mC2 : cs_m) { - String rightSide = mC1.getRight(); - String leftSide = mC2.getLeft(); + for(ClassConstraint cC : cs_cl) { + for(MethodConstraint mC : cs_m) { + String rightSide = mC.getRight(); + String leftSide = cC.getLeft(); for(TPHConstraint tphC : tcOfCs) { - + if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) { + tempCC.add((MethodConstraint) tphC); + } } } } - return null; - return null; + return tempCC; } /**