forked from JavaTX/JavaCompilerCore
modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
This commit is contained in:
parent
ba8df8b376
commit
d08e598649
@ -513,8 +513,10 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
|
|
||||||
public static List<MethodConstraint> secondLineMethodDefinition(List<TPHConstraint> allConstraints, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, MethodAndTPH methodAndTPH, ResultSet resSet, Set<Pair> oldCons) {
|
public static List<MethodConstraint> secondLineMethodDefinition(List<TPHConstraint> allConstraints, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, MethodAndTPH methodAndTPH, ResultSet resSet, Set<Pair> oldCons) {
|
||||||
List<MethodConstraint> tempMC = new ArrayList<>(); //für Ergebnisse basierend auf der neuen Datenstruktur (Ali)
|
List<MethodConstraint> tempMC = new ArrayList<>(); //für Ergebnisse basierend auf der neuen Datenstruktur (Ali)
|
||||||
Set<Pair> tempSet = new HashSet<>(); //für Ergebnisse basierend auf der alten Datenstruktur
|
Set<Pair> tempSet = new HashSet<>(); //für Ergebnisse des ersten Teils basierend auf der alten Datenstruktur
|
||||||
|
Set<Pair> tempSet2 = new HashSet<>(); //für Ergebnisse des zweiten Teils basierend auf der alten Datenstruktur
|
||||||
Set<Pair> tcOfoldConsSet = buildTransitiveClosureForCP(oldCons, resSet);
|
Set<Pair> tcOfoldConsSet = buildTransitiveClosureForCP(oldCons, resSet);
|
||||||
|
List<TPHConstraint> tcOfCs = buildTransitiveClosure(allConstraints);
|
||||||
MethodAndTPH methAndTphs = methodAndTPH;
|
MethodAndTPH methAndTphs = methodAndTPH;
|
||||||
List<Set<Constraint<Pair>>> orCons = methAndTphs.constraints.getOderConstraints();
|
List<Set<Constraint<Pair>>> orCons = methAndTphs.constraints.getOderConstraints();
|
||||||
List<HashMap<Relation, List<TPHConstraint>>> orConsListConverted = new ArrayList<>();
|
List<HashMap<Relation, List<TPHConstraint>>> orConsListConverted = new ArrayList<>();
|
||||||
@ -531,10 +533,10 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
if(p.GetOperator() == PairOperator.SMALLERDOT) {
|
if(p.GetOperator() == PairOperator.SMALLERDOT) {
|
||||||
r = Relation.EXTENDS;
|
r = Relation.EXTENDS;
|
||||||
orConsWithEXTENDS.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r));
|
orConsWithEXTENDS.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r));
|
||||||
MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r);
|
/*MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r);
|
||||||
if(!checkForDuplicates(mc, tempMC)) {
|
if(!checkForDuplicates(mc, tempMC)) {
|
||||||
tempMC.add(mc);
|
tempMC.add(mc);
|
||||||
}
|
}*/
|
||||||
} else if(p.GetOperator() == PairOperator.EQUALSDOT) {
|
} else if(p.GetOperator() == PairOperator.EQUALSDOT) {
|
||||||
r = Relation.EQUAL;
|
r = Relation.EQUAL;
|
||||||
orConsWithEQUAL.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r));
|
orConsWithEQUAL.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r));
|
||||||
@ -566,11 +568,13 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
|
|
||||||
// dies ist das "R" aus dem ersten Teil, wird im zweiten Teil gebraucht
|
// dies ist das "R" aus dem ersten Teil, wird im zweiten Teil gebraucht
|
||||||
TypePlaceholder tphR = null;
|
TypePlaceholder tphR = null;
|
||||||
|
Constraint<Pair> extendsSetAllOfOr = new Constraint<Pair>();
|
||||||
|
Constraint<Pair> equalSetAllOfOr = new Constraint<Pair>();
|
||||||
|
|
||||||
// Berechnung des ersten Teils der Regel
|
// Berechnung des ersten Teils der Regel
|
||||||
|
for(int i=0; i<orCons.size(); i++) {
|
||||||
Constraint<Pair> extendsSet = new Constraint<Pair>();
|
Constraint<Pair> extendsSet = new Constraint<Pair>();
|
||||||
Constraint<Pair> equalSet = new Constraint<Pair>();
|
Constraint<Pair> equalSet = new Constraint<Pair>();
|
||||||
for(int i=0; i<orCons.size(); i++) {
|
|
||||||
//für jede einzelne OrConstraint-Menge gehe durch
|
//für jede einzelne OrConstraint-Menge gehe durch
|
||||||
for(Constraint con: orCons.get(i)) {
|
for(Constraint con: orCons.get(i)) {
|
||||||
Iterator<Pair> it = con.iterator();
|
Iterator<Pair> it = con.iterator();
|
||||||
@ -579,8 +583,10 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
Pair p = it.next();
|
Pair p = it.next();
|
||||||
if (p.OperatorSmallerDot()) {
|
if (p.OperatorSmallerDot()) {
|
||||||
extendsSet.add(p);
|
extendsSet.add(p);
|
||||||
|
extendsSetAllOfOr.add(p);
|
||||||
} else if (p.OperatorEqual()) {
|
} else if (p.OperatorEqual()) {
|
||||||
equalSet.add(p);
|
equalSet.add(p);
|
||||||
|
equalSetAllOfOr.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iterator<Pair> itExtends = extendsSet.iterator();
|
Iterator<Pair> itExtends = extendsSet.iterator();
|
||||||
@ -605,28 +611,52 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Berechnung des zweiten Teils der Regel
|
|
||||||
|
|
||||||
|
/*// Berechnung des zweiten Teils der Regel
|
||||||
Iterator<Pair> itEqual = equalSet.iterator();
|
Iterator<Pair> itEqual = equalSet.iterator();
|
||||||
while(itEqual.hasNext()) {
|
while(itEqual.hasNext()) {
|
||||||
Pair pairEqual = itEqual.next();
|
Pair pairEqual = itEqual.next();
|
||||||
// prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht
|
|
||||||
if(tphR == pairEqual.TA1) {
|
|
||||||
tempSet.add();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Iterator<Pair> itExtends = equalSet.iterator();
|
Iterator<Pair> itExtends = equalSet.iterator();
|
||||||
while(itExtends.hasNext()) {
|
while(itExtends.hasNext()) {
|
||||||
Pair pairExtends = itExtends.next();
|
Pair pairExtends = itExtends.next();
|
||||||
|
Pair newPair = new Pair(resSet.resolveType((TypePlaceholder)(pairExtends.TA2)).resolvedType, resSet.resolveType((TypePlaceholder)(pairEqual.TA1)).resolvedType, PairOperator.SMALLERDOT);
|
||||||
|
Iterator<Pair> itTC = tcOfoldConsSet.iterator();
|
||||||
|
while(itTC.hasNext()) {
|
||||||
|
Pair pairTC = itTC.next();
|
||||||
|
|
||||||
// prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht
|
// prüfe, ob das "R" von vorhin in einem EqualConstraint links auftaucht
|
||||||
if(tphR == pairExtends.TA1) {
|
if(tphR == pairEqual.TA1) {
|
||||||
tempSet.add();
|
// tempSet.add();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Berechnung des zweiten Teils der Regel
|
||||||
|
Iterator<Pair> itExtends2 = extendsSetAllOfOr.iterator();
|
||||||
|
while(itExtends2.hasNext()) {
|
||||||
|
Pair pairExtends2 = itExtends2.next();
|
||||||
|
Iterator<Pair> itEqual2 = equalSetAllOfOr.iterator();
|
||||||
|
while (itEqual2.hasNext()) {
|
||||||
|
Pair pairEqual2 = itEqual2.next();
|
||||||
|
Pair newPair2 = new Pair(resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, resSet.resolveType((TypePlaceholder) (pairEqual2.TA1)).resolvedType, PairOperator.SMALLERDOT);
|
||||||
|
boolean rEqRtilde = (tphR == pairEqual2.TA1 && checkForDuplicatesForSets(new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairEqual2.TA2)).resolvedType, PairOperator.EQUALSDOT), equalSetAllOfOr));
|
||||||
|
boolean rExRtilde = (tphR == pairExtends2.TA1 && checkForDuplicatesForSets(new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT), extendsSetAllOfOr));
|
||||||
|
Pair rExRtildePair = new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT);
|
||||||
|
boolean isPairInTExTapostrophe = checkForDuplicatesForSets(rExRtildePair, extendsSetAllOfOr);
|
||||||
|
if (rEqRtilde || rExRtilde || !isPairInTExTapostrophe) {
|
||||||
|
if (newPair2.TA1 != newPair2.TA2) { //eliminieren der Fälle wie AA<.AA
|
||||||
|
if (!checkForDuplicatesForSets(newPair2, tempSet2)) {
|
||||||
|
tempSet2.add(newPair2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali)
|
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali) für ersten Teil
|
||||||
Iterator<Pair> itTemp = tempSet.iterator();
|
Iterator<Pair> itTemp = tempSet.iterator();
|
||||||
while(itTemp.hasNext()) {
|
while(itTemp.hasNext()) {
|
||||||
Pair p = itTemp.next();
|
Pair p = itTemp.next();
|
||||||
@ -639,13 +669,35 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
r = Relation.EQUAL;
|
r = Relation.EQUAL;
|
||||||
}
|
}
|
||||||
MethodConstraint mc = new MethodConstraint(ta1, ta2, r);
|
MethodConstraint mc = new MethodConstraint(ta1, ta2, r);
|
||||||
if(mc.getRel() != Relation.EQUAL) {
|
if(mc.getRel() == Relation.EXTENDS) {
|
||||||
if(!checkForDuplicates(mc, tempMC)) {
|
if(!checkForDuplicates(mc, tempMC)) {
|
||||||
tempMC.add(mc);
|
tempMC.add(mc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// aus der alten Datenstruktur in die neue Datenstruktur (von Ali) für zweiten Teil
|
||||||
|
Iterator<Pair> itTemp2 = tempSet2.iterator();
|
||||||
|
while(itTemp2.hasNext()) {
|
||||||
|
Pair p = itTemp2.next();
|
||||||
|
String ta1 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName();
|
||||||
|
String ta2 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName();
|
||||||
|
Relation r = null;
|
||||||
|
if (p.GetOperator() == PairOperator.SMALLERDOT) {
|
||||||
|
r = Relation.EXTENDS;
|
||||||
|
} else if (p.GetOperator() == PairOperator.EQUALSDOT) {
|
||||||
|
r = Relation.EQUAL;
|
||||||
|
}
|
||||||
|
for(TPHConstraint tphCons: tcOfCs) {
|
||||||
|
if(ta1 == tphCons.getLeft() && ta2 == tphCons.getRight() && r==Relation.EXTENDS) {
|
||||||
|
MethodConstraint mc = new MethodConstraint(ta1, ta2, r);
|
||||||
|
if(!checkForDuplicates(mc, tempMC)) {
|
||||||
|
tempMC.add(mc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return tempMC;
|
return tempMC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user