modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java

This commit is contained in:
AluAli 2021-03-19 14:42:22 +01:00
parent 13144d0ac9
commit 661fa53937

View File

@ -519,6 +519,7 @@ public class FamilyOfGeneratedGenerics {
List<Set<Constraint<Pair>>> orCons = methAndTphs.constraints.getOderConstraints();
List<List<Constraint<Pair>>> orConsList = new ArrayList<>();
List<HashMap<Relation, List<TPHConstraint>>> orConsListConverted = new ArrayList<>();
//gehe die OrConstraints der aktuellen Methode durch und teile nach Operator auf (
for(int i=0; i<orCons.size(); i++) {
HashMap<Relation, List<TPHConstraint>> orConsInternal = new HashMap<>();
List<TPHConstraint> orConsWithEQUAL = new ArrayList();
@ -550,6 +551,8 @@ public class FamilyOfGeneratedGenerics {
orConsListConverted.add(orConsInternal);
}
// oldCons sind alle Und- und Oder-Constraints
// zunächst in meine Datenstruktur(Ali) konvertieren
List<Pair> oldConsList = new ArrayList<>(oldCons);
List<TPHConstraint> oldConsListConverted = new ArrayList<>();
for(Pair pair: oldConsList) {
@ -561,10 +564,8 @@ public class FamilyOfGeneratedGenerics {
}
oldConsListConverted.add(new TPHConstraint(((TypePlaceholder) pair.TA1).getName(), ((TypePlaceholder) pair.TA2).getName(), r));
}
// List<TPHConstraint> tcOfoldCons = buildTransitiveClosure(oldConsListConverted);
// Set<Pair> tcOfoldConsSet = buildTransitiveClosureForCP(oldCons);
// for(int i=0; i<orConsListConverted.size(); i++) {
// Berechnung der Regel
for(int i=0; i<orCons.size(); i++) {
Constraint<Pair> extendsSet = new Constraint<Pair>();
Constraint<Pair> equalSet = new Constraint<Pair>();
@ -572,31 +573,23 @@ public class FamilyOfGeneratedGenerics {
Iterator<Pair> it = con.iterator();
while (it.hasNext()) {
Pair p = it.next();
// List<TPHConstraint> extendsList = orConsListConverted.get(i).get(Relation.EXTENDS);
// List<TPHConstraint> equalList = orConsListConverted.get(i).get(Relation.EQUAL);
if (p.OperatorSmallerDot()) {
extendsSet.add(p);
} else if (p.OperatorEqual()) {
equalSet.add(p);
}
}
// for (TPHConstraint ex : extendsList) {
Iterator<Pair> itExtends = extendsSet.iterator();
while(itExtends.hasNext()) {
Pair pairExtends = itExtends.next();
// for (TPHConstraint eq : equalList) {
Iterator<Pair> itEqual = equalSet.iterator();
while(itEqual.hasNext()) {
Pair pairEqual = itEqual.next();
// MethodConstraint mc = new MethodConstraint(ex.getRight(), eq.getLeft(), Relation.EXTENDS);
Pair newPair = new Pair(resSet.resolveType((TypePlaceholder)(pairExtends.TA2)).resolvedType, resSet.resolveType((TypePlaceholder)(pairEqual.TA1)).resolvedType, PairOperator.SMALLERDOT);
// for (TPHConstraint tc : tcOfoldCons) {
Iterator<Pair> itTC = tcOfoldConsSet.iterator();
while(itTC.hasNext()) {
Pair pairTC = itTC.next();
// if (tc.getLeft() == mc.getLeft() && tc.getRight() == mc.getRight() && tc.getRel() == mc.getRel()) {
if(resSet.resolveType((TypePlaceholder)(pairTC.TA1)).resolvedType == newPair.TA1 && resSet.resolveType((TypePlaceholder)(pairTC.TA2)).resolvedType == newPair.TA2 && pairTC.OperatorSmallerDot() && newPair.OperatorSmallerDot()) { //hier bei pairTC resolvedType, damit Pairs aus oldCons in der Methode zur Berechnung von der transitiven Hülle nicht in eine Endlosschleife kommen (Cycles!)
// if (!checkForDuplicates(mc, tempMC)) {
if(newPair.TA1 != newPair.TA2) {
if (!checkForDuplicatesForSets(newPair, tempSet)) {
tempSet.add(newPair);
@ -609,6 +602,7 @@ public class FamilyOfGeneratedGenerics {
}
}
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali)
Iterator<Pair> itTemp = tempSet.iterator();
while(itTemp.hasNext()) {
Pair p = itTemp.next();