forked from JavaTX/JavaCompilerCore
modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
This commit is contained in:
parent
539cacef86
commit
13144d0ac9
@ -60,7 +60,7 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
}
|
}
|
||||||
} while (addedToConstraintsListForCC2);
|
} while (addedToConstraintsListForCC2);
|
||||||
|
|
||||||
List<ClassConstraint> classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs);
|
List<ClassConstraint> classConstraints3 = hasNoSupertypeForClassTypes(cs_cl, posOfTphs);
|
||||||
for (ClassConstraint cons: classConstraints3) {
|
for (ClassConstraint cons: classConstraints3) {
|
||||||
if (!checkForDuplicates(cons, cs_cl)) {
|
if (!checkForDuplicates(cons, cs_cl)) {
|
||||||
cs_cl.add(cons);
|
cs_cl.add(cons);
|
||||||
@ -224,28 +224,34 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
* {T <. Object | ((T is a type variable in a type of a node of a field
|
* {T <. Object | ((T is a type variable in a type of a node of a field
|
||||||
* or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)}
|
* or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)}
|
||||||
*/
|
*/
|
||||||
public static List<ClassConstraint> hasNoSupertypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) {
|
public static List<ClassConstraint> hasNoSupertypeForClassTypes(List<ClassConstraint> cs_cl, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) {
|
||||||
List<ClassConstraint> tempCC= new ArrayList<>();
|
List<ClassConstraint> tempCC= new ArrayList<>();
|
||||||
for(TPHConstraint allCons: allConstraints) {
|
List<TPHConstraint> clCons = new ArrayList<>(cs_cl);
|
||||||
for(ClassConstraint cCons: cs_cl) {
|
for(String tph: posOfTphs.keySet()) {
|
||||||
for(String tph: posOfTphs.keySet()) {
|
for(PairTphMethod pair: posOfTphs.get(tph)) {
|
||||||
for(PairTphMethod pair: posOfTphs.get(tph)) {
|
boolean tvInField = pair.fst == PositionFinder.Position.FIELD;
|
||||||
boolean tvInField = pair.fst == PositionFinder.Position.FIELD;
|
boolean hasSmallerTVInClCons = hasSmallerTVInClCons(tph, cs_cl);
|
||||||
boolean hasSmallerTVInClCons = (posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null);
|
if ((tvInField || hasSmallerTVInClCons) &&
|
||||||
if( ((tvInField || hasSmallerTVInClCons) && cCons.getRel()==Relation.EXTENDS) &&
|
!checkUpperBound(clCons, tph)) {
|
||||||
!checkUpperBound(allConstraints, tph) && allCons.getRel()==Relation.EXTENDS) {
|
ClassConstraint consToAdd = new ClassConstraint(tph, objectType, Relation.EXTENDS);
|
||||||
ClassConstraint consToAdd = new ClassConstraint(tph, objectType, Relation.EXTENDS);
|
if (!checkForDuplicates(consToAdd, tempCC)) {
|
||||||
if (!checkForDuplicates(consToAdd, tempCC)){
|
tempCC.add(consToAdd);
|
||||||
tempCC.add(consToAdd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return tempCC;
|
return tempCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasSmallerTVInClCons(String tph, List<ClassConstraint> cs_cl) {
|
||||||
|
for(ClassConstraint cC: cs_cl) {
|
||||||
|
if(tph == cC.getRight() && cC.getRel() == Relation.EXTENDS) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Def. FGG: erste Zeile von cs_m
|
* Def. FGG: erste Zeile von cs_m
|
||||||
* {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs}
|
* {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs}
|
||||||
@ -496,7 +502,7 @@ 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);
|
||||||
}
|
}
|
||||||
@ -678,20 +684,16 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<MethodConstraint> hasNoSupertypeForMethodTypesNew(List<TPHConstraint> allConstraints, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, MethodAndTPH methodAndTPH) {
|
public static List<MethodConstraint> hasNoSupertypeForMethodTypesNew(HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, MethodAndTPH methodAndTPH, List<MethodConstraint> cs_m) {
|
||||||
List<MethodConstraint> tempMC = new ArrayList<>();
|
List<MethodConstraint> tempMC = new ArrayList<>();
|
||||||
List<TPHConstraint> allCons = allConstraints;
|
List<TPHConstraint> methCons = new ArrayList<>(cs_m);
|
||||||
MethodAndTPH methAndTphs = methodAndTPH;
|
MethodAndTPH methAndTphs = methodAndTPH;
|
||||||
for(String tph: posOfTphs.keySet()) {
|
for(String tph: posOfTphs.keySet()) {
|
||||||
for(int i=0; i<posOfTphs.get(tph).size(); i++)
|
for(int i=0; i<posOfTphs.get(tph).size(); i++)
|
||||||
if(posOfTphs.get(tph).get(i).fst == PositionFinder.Position.METHOD && posOfTphs.get(tph).get(i).snd == methAndTphs.getId()) {
|
if(posOfTphs.get(tph).get(i).fst == PositionFinder.Position.METHOD && posOfTphs.get(tph).get(i).snd == methAndTphs.getId() && !checkUpperBound(methCons,tph)) {
|
||||||
for(TPHConstraint ac: allCons) {
|
MethodConstraint mc2 = new MethodConstraint(tph, objectType, Relation.EXTENDS);
|
||||||
if(tph==ac.getRight() && !checkUpperBound(allCons,tph)) {
|
if (!checkForDuplicates(mc2, tempMC)) {
|
||||||
MethodConstraint mc2 = new MethodConstraint(tph, objectType, Relation.EXTENDS);
|
tempMC.add(mc2);
|
||||||
if(!checkForDuplicates(mc2, tempMC)) {
|
|
||||||
tempMC.add(mc2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -736,7 +738,7 @@ public class FamilyOfGeneratedGenerics {
|
|||||||
tempMethodConstraintsWithPosition.put(currentMethod, newMCList2);
|
tempMethodConstraintsWithPosition.put(currentMethod, newMCList2);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
hasNoSupType = hasNoSupertypeForMethodTypesNew(cs,posOfTphs,method);
|
hasNoSupType = hasNoSupertypeForMethodTypesNew(posOfTphs,method,listToAdd);
|
||||||
for (MethodConstraint cons: hasNoSupType) {
|
for (MethodConstraint cons: hasNoSupType) {
|
||||||
if (!checkForDuplicates(cons, listToAdd)) {
|
if (!checkForDuplicates(cons, listToAdd)) {
|
||||||
listToAdd.add(cons);
|
listToAdd.add(cons);
|
||||||
|
Loading…
Reference in New Issue
Block a user