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

This commit is contained in:
AluAli 2020-11-13 16:22:23 +01:00
parent 2e5581ab6e
commit f0db6cb901

View File

@ -50,6 +50,7 @@ public class FamilyOfGeneratedGenerics {
* {T < .T' | T is a type variable in a type of a node of a field} * {T < .T' | T is a type variable in a type of a node of a field}
*/ */
public static List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, HashMap<String, PositionFinder.Position> posOfTphs) { public static List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, HashMap<String, PositionFinder.Position> posOfTphs) {
//RuntimeException re = new RuntimeException("enthält EQUALS-Relation");
List<ClassConstraint> tempCC= new ArrayList<>(); List<ClassConstraint> tempCC= new ArrayList<>();
for(TPHConstraint allCons: allConstraints){ for(TPHConstraint allCons: allConstraints){
if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) { if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) {
@ -62,6 +63,9 @@ public class FamilyOfGeneratedGenerics {
} }
} }
} }
/*else if (allCons.getRel() != Relation.EXTENDS) {
throw re;
}*/
} }
return tempCC; return tempCC;
} }
@ -97,16 +101,11 @@ public class FamilyOfGeneratedGenerics {
for(TPHConstraint allCons: allConstraints) { for(TPHConstraint allCons: allConstraints) {
for(ClassConstraint cCons: cs_cl) { for(ClassConstraint cCons: cs_cl) {
for(String tph: posOfTphs.keySet()) { for(String tph: posOfTphs.keySet()) {
for(int i=0; i<allConstraints.size(); i++) { boolean tvInField = posOfTphs.get(tph) == PositionFinder.Position.FIELD;
if( ((posOfTphs.get(tph) == PositionFinder.Position.FIELD) || boolean hasSmallerTVInClCons = (posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null);
(posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null)) && if( ((tvInField || hasSmallerTVInClCons) && cCons.getRel()==Relation.EXTENDS) &&
cCons.getRel()==Relation.EXTENDS && checkUpperBound(allConstraints, tph) && allCons.getRel()==Relation.EXTENDS) {
// (allCons.getLeft() == tph && allCons.getRight() == null) && ClassConstraint consToAdd = new ClassConstraint(tph, "Object", Relation.EXTENDS);
// (tph != allCons.getLeft()) &&
// (allConstraints.in.getLeft() != tph))
allConstraints.get(i).getLeft() != tph &&
allCons.getRel()==Relation.EXTENDS) {
ClassConstraint consToAdd = new ClassConstraint(cCons.getRight(), "Object", Relation.EXTENDS);
if (!checkForDuplicates(consToAdd, tempCC)){ if (!checkForDuplicates(consToAdd, tempCC)){
tempCC.add(consToAdd); tempCC.add(consToAdd);
} }
@ -114,13 +113,18 @@ public class FamilyOfGeneratedGenerics {
} }
} }
} }
}
return tempCC; return tempCC;
} }
/*
public static boolean checkUpperBound(List<TPHConstraint> cs, String tph) {
for(int i=0; i<cs.size(); i++) {
if(cs.get(i).getLeft() == tph) {
return false;
}
}
return true;
}
*/
/** /**
* 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}