From bbfd8aa203b98b55286b229e0f6eb8d499d190ad Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Thu, 1 Apr 2021 17:13:06 +0200 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java --- .../FamilyOfGeneratedGenerics.java | 143 +++--------------- 1 file changed, 23 insertions(+), 120 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index d293fe6c..fc29b869 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -571,79 +571,6 @@ public class FamilyOfGeneratedGenerics { oldConsListConverted.add(new TPHConstraint(((TypePlaceholder) pair.TA1).getName(), ((TypePlaceholder) pair.TA2).getName(), r)); } - // dies ist das "R" aus dem ersten Teil, wird im zweiten Teil gebraucht -// TypePlaceholder tphR = null; -// Constraint extendsSetAllOfOr = new Constraint(); -// Constraint equalSetAllOfOr = new Constraint(); - - - // Berechnung des ersten Teils der Bedingung der Regel - for(int i=0; i extendsSet = new Constraint(); - Constraint equalSet = new Constraint(); - //für jede einzelne OrConstraint-Menge gehe durch - for(Constraint con: orCons.get(i)) { - Iterator it = con.iterator(); - //für jeden Eintrag der Menge - while (it.hasNext()) { - Pair p = it.next(); - if (p.OperatorSmallerDot()) { - extendsSet.add(p); -// extendsSetAllOfOr.add(p); - } else if (p.OperatorEqual()) { - equalSet.add(p); -// equalSetAllOfOr.add(p); - } - } - Iterator itExtends = extendsSet.iterator(); - while(itExtends.hasNext()) { - Pair pairExtends = itExtends.next(); - Iterator itEqual = equalSet.iterator(); - while(itEqual.hasNext()) { - Pair pairEqual = itEqual.next(); -// tphR = (TypePlaceholder) (pairEqual.TA2); - //newPair entspricht \sigma(T'_0) < \sigma(R_0) - //TODO: Überprüfen: newPair und tras clos ohne resolvedType - Pair newPair = new Pair(resSet.resolveType((TypePlaceholder)(pairExtends.TA2)).resolvedType, - resSet.resolveType((TypePlaceholder)(pairEqual.TA1)).resolvedType, PairOperator.SMALLERDOT); - Iterator itTC = tcOfoldConsSet.iterator(); - while(itTC.hasNext()) {//ueberpruefen ob newPair in transitiv closure - Pair pairTC = itTC.next(); - if(resSet.resolveType((TypePlaceholder)(pairTC.TA1)).resolvedType == newPair.TA1 && resSet.resolveType((TypePlaceholder)(pairTC.TA2)).resolvedType == newPair.TA2 && pairTC.OperatorSmallerDot() && newPair.OperatorSmallerDot()) { //erst 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(newPair.TA1 != newPair.TA2) { //eliminieren der Fälle wie AA<.AA - if (!checkForDuplicatesForSets(newPair, tempSet)) { - //TODO: evtl. pairExtends hinzufuegen - //tempSet.add(newPair); - } - } - } - } - } - } - } - - - /*// Berechnung des zweiten Teils der Regel - Iterator itEqual = equalSet.iterator(); - while(itEqual.hasNext()) { - Pair pairEqual = itEqual.next(); - Iterator itExtends = equalSet.iterator(); - while(itExtends.hasNext()) { - Pair pairExtends = itExtends.next(); - Pair newPair = new Pair(resSet.resolveType((TypePlaceholder)(pairExtends.TA2)).resolvedType, resSet.resolveType((TypePlaceholder)(pairEqual.TA1)).resolvedType, PairOperator.SMALLERDOT); - Iterator itTC = tcOfoldConsSet.iterator(); - while(itTC.hasNext()) { - Pair pairTC = itTC.next(); - - // prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht - if(tphR == pairEqual.TA1) { -// tempSet.add(); - } - } - } - }*/ - - } // Berechnung des zweiten Teils der Bedingung der Regel for(int i=0; i itTC = tcOfCs.iterator(); //tcOfoldConsSet.iterator(); - /* - buildTransitiveClosureForCP( - mapMethodsAndTph.get(posOfTPHs.get(((TypePlaceholder)pairExtends2.TA2) - .getName()).get(0).snd) - .constraints.getAll(), - resSet).iterator(); - */ - //while(itTC.hasNext()) {//ueberpruefen ob newPair in transitiv closure - //Pair pairTC = itTC.next(); - //if //((pairTC.TA1.equals(newPairOld.TA1)) - // ((resSet.resolveType((TypePlaceholder)(pairTC.TA1)).resolvedType.equals(newPair2.TA1)) - // && resSet.resolveType((TypePlaceholder)(pairTC.TA2)).resolvedType.equals(newPair2.TA2) - // //&& pairTC.OperatorSmallerDot() - // //&& newPair2.OperatorSmallerDot() - // ) - //TPHConstraint tPHCons = itTC.next(); - //if newPairTPHConstraint - //{ //erst hier bei pairTC resolvedType, damit Pairs aus oldCons in der Methode zur Berechnung von der transitiven Hülle nicht in eine Endlosschleife kommen (Cycles!) - // transClo = true; - // break; - //} - //} if (tcOfCs.contains(newPairTPHConstraint)|| (newPairTPHConstraint.getLeft().equals(newPairTPHConstraint.getRight()))) { transClo = true; } @@ -705,34 +608,34 @@ public class FamilyOfGeneratedGenerics { while (itUndCons.hasNext()) { Pair pairUndCons2 = itUndCons.next(); rEqExRtilde = rEqExRtilde || (tphR == pairUndCons2.TA1); -// Pair rExRtildePair = new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT); } - boolean isPairInTExTapostrophe = false; -// Constraint allOfOr = new Constraint(); - for(Set> scp: orCons) { - Iterator> itSCP = scp.iterator(); - while(itSCP.hasNext()) { - Constraint cp = itSCP.next(); - Iterator itCP = cp.iterator(); - while(itCP.hasNext()) { - Pair p = itCP.next(); - if(p.OperatorSmallerDot()) { - isPairInTExTapostrophe = isPairInTExTapostrophe || tphR.equals(p.TA1); - } + boolean isPairInTExTapostrophe = false; + for(Set> scp: orCons) { + Iterator> itSCP = scp.iterator(); + while(itSCP.hasNext()) { + Constraint cp = itSCP.next(); + Iterator itCP = cp.iterator(); + while(itCP.hasNext()) { + Pair p = itCP.next(); + if(p.OperatorSmallerDot()) { + isPairInTExTapostrophe = isPairInTExTapostrophe || tphR.equals(p.TA1); } } + } - } + } - if (transClo && (rEqExRtilde || isPairInTExTapostrophe)) { - if (!newPair2.TA1.equals(newPair2.TA2)) { //eliminieren der Fälle wie AA<.AA - if (transClo && !checkForDuplicatesForSets(newPair2, tempSet2)) - tempSet2.add(newPair2); - } - if (!checkForDuplicatesForSets(pairExtends2, tempSet2)) - tempSet2.add(pairExtends2); - } - } + if (transClo && (rEqExRtilde || isPairInTExTapostrophe)) { + if (!newPair2.TA1.equals(newPair2.TA2)) { //eliminieren der Fälle wie AA<.AA + if (!checkForDuplicatesForSets(newPair2, tempSet2)) { + tempSet2.add(newPair2); + } + } + if (!checkForDuplicatesForSets(pairExtends2, tempSet2)) { + tempSet2.add(pairExtends2); + } + } + } String key = ((TypePlaceholder)pairExtends2.TA2).getName(); if (posOfTphs.containsKey(key)) { if (posOfTphs.get(key).contains(new PairTphMethod<>(PositionFinder.Position.METHOD, methodAndTPH.getId()))) {