modified: src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java

modified:   src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
This commit is contained in:
AluAli 2021-01-22 15:07:03 +01:00
parent c15953bbac
commit 1a135ebe5c
2 changed files with 32 additions and 11 deletions

View File

@ -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);
System.out.println("fogg.allConstraints: "+ fogg.allConstraints);
System.out.println("fogg.posOfTPHs: "+ fogg.posOfTPHs);
System.out.println("fogg.classConstraints: "+ fogg.classConstraints);

View File

@ -35,12 +35,26 @@ public class FamilyOfGeneratedGenerics {
cs_cl.add(cons);
}
}
List<ClassConstraint> classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
for (ClassConstraint cons: classConstraints2) {
if (!checkForDuplicates(cons, cs_cl)) {
cs_cl.add(cons);
boolean equalsConstraintsList = false;
List<ClassConstraint> tempList = new ArrayList<>();
do {
List<ClassConstraint> classConstraints2 = new ArrayList<>();
classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
if (classConstraints2 == tempList) {
equalsConstraintsList = true;
}
}
for (ClassConstraint cons: classConstraints2) {
if (!checkForDuplicates(cons, cs_cl)) {
cs_cl.add(cons);
}
}
tempList = new ArrayList<>(classConstraints2);
for (ClassConstraint cc : tempList) {
classConstraints2.remove(cc);
System.out.println(classConstraints2);
}
}while(!equalsConstraintsList);
List<ClassConstraint> classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs);
for (ClassConstraint cons: classConstraints3) {
if (!checkForDuplicates(cons, cs_cl)) {
@ -113,7 +127,7 @@ public class FamilyOfGeneratedGenerics {
*/
public static List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> allConstraints, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) {
//RuntimeException re = new RuntimeException("enthält EQUALS-Relation");
List<ClassConstraint> tempCC= new ArrayList<>();
List<ClassConstraint> tempCC = new ArrayList<>();
for(TPHConstraint allCons: allConstraints){
if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) {
for(String tph: posOfTphs.keySet()) {
@ -137,15 +151,19 @@ public class FamilyOfGeneratedGenerics {
* {T' <. T'' | \exists T: (T <. T') \in cs_cl, (T' <. T'') \in cs }
*/
public static List<ClassConstraint> transitiveSubtypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl) {
List<ClassConstraint> tempCC= new ArrayList<>();
List<ClassConstraint> tempCC = new ArrayList<>();
ClassConstraint consToAdd;
for(ClassConstraint cCons: cs_cl) {
if(cCons.getLeft() != null && cCons.getRel()==Relation.EXTENDS) {
for(TPHConstraint allCons: allConstraints) {
if(cCons.getRight() == allCons.getLeft() && allCons.getRight() != null && allCons.getRel()==Relation.EXTENDS){
ClassConstraint consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
if (!checkForDuplicates(consToAdd, tempCC)) {
tempCC.add(consToAdd);
}
// if (tempCC != null) {
// transitiveSubtypeForClassTypes(allConstraints, tempCC);
// }
}
}
}
@ -279,12 +297,15 @@ public class FamilyOfGeneratedGenerics {
* nimm die Menge cs_cl aus cs_m raus
*/
public static List<MethodConstraint> methodTypesWithoutClassTypes(List<ClassConstraint> cs_cl, List<MethodConstraint> cs_m) {
//TODO:
// erstelle Kopie der Liste cs_cl
List<TPHConstraint> tempCC = new ArrayList<>();
for(ClassConstraint cc: cs_cl) {
TPHConstraint tphC = new TPHConstraint(cc.getLeft(), cc.getRight(), cc.getRel());
tempCC.add(tphC);
}
// Transitive Hülle von cs_cl
List<TPHConstraint> tcOfCsCl = buildTransitiveClosure(tempCC);
List<TPHConstraint> tempMC = new ArrayList<>();
for(MethodConstraint mc: cs_m) {
TPHConstraint tphC = new TPHConstraint(mc.getLeft(), mc.getRight(), mc.getRel());
@ -294,7 +315,7 @@ public class FamilyOfGeneratedGenerics {
tempMC2.addAll(tempMC);
List<MethodConstraint> tempMCToReturn = new ArrayList<>();
for(TPHConstraint cc: tempCC) {
for(TPHConstraint cc: tcOfCsCl) {
for(TPHConstraint mc: tempMC) {
if(cc.getLeft().equals(mc.getLeft()) && cc.getRight().equals(mc.getRight())) {
tempMC2.remove(mc);