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

modified:   src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java
This commit is contained in:
AluAli 2020-10-29 19:40:46 +01:00
parent 5060cca6db
commit d677d053d6
2 changed files with 61 additions and 63 deletions

View File

@ -3,67 +3,52 @@ package de.dhbwstuttgart.bytecode.gGenericsAli;
import de.dhbwstuttgart.bytecode.TPHExtractor;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
import de.dhbwstuttgart.bytecode.genericsGenerator.ConstraintsSimplierResult;
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
import de.dhbwstuttgart.syntaxtree.Method;
import java.util.ArrayList;
import java.util.List;
public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
private final TPHExtractor tphExtractor = new TPHExtractor();
private final List<TPHConstraint> cs = tphExtractor.allCons; //alle Constraints bekommen wie?
public FamilyOfGeneratedGenerics(List<TPHConstraint> cs) {
this.cs = cs;
}
List<ClassConstraint> cs_cl = null;
List<MethodConstraint> cs_m = null;
/*public Type getLeftSideOfConstraint(TPHConstraint constraint) {
Type leftSideType = null;
if(!(getRelationOfConstraint(constraint) == Relation.EXTENDS)) {
continue;
} else {
leftSideType = constraint.getLeft();
}
return leftSideType;
}*/
public String getLeftSideOfConstraint(TPHConstraint constraint) {
if(constraint.getRel() == Relation.EXTENDS)
return constraint.getLeft();
return null;
}
/*public Type getRightSideOfConstraint(TPHConstraint constraint) {
Type rightSideType = null;
if(!(getRelationOfConstraint(constraint) == Relation.EXTENDS)) {
continue;
} else {
rightSideType = constraint.getRight();
}
return rightSideType;
}*/
public String getRightSideOfConstraint(TPHConstraint constraint) {
if(constraint.getRel() == Relation.EXTENDS)
return constraint.getRight();
return null;
}
/*public Relation getRelationOfConstraint(TPHConstraint constraint) {
return constraint.getRel();
}*/
public void addConstraintToClassConstraint(List<TPHConstraint> constraintsSet) {
//TODO: Regeln
// for(TPHConstraint cons: constraintsSet){
//
// cs_cl =
// private TPHExtractor tphExtractor = new TPHExtractor();
public List<TPHConstraint> cs; //alle Constraints bekommen wie?
// public FamilyOfGeneratedGenerics(List<TPHConstraint> cs) {
// this.cs = cs;
// }
List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(constraintsSet);
public List<ClassConstraint> cs_cl;
public List<MethodConstraint> cs_m;
public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) {
cs = (List<TPHConstraint>) tphExtractor.allCons;
cs_cl = new ArrayList<ClassConstraint>();
cs_m = new ArrayList<MethodConstraint>();
}
public void printCs() {
System.out.println(cs);
System.out.println(cs);
System.out.println("-----------------------------------------------------------------------------");
}
// public String getLeftSideOfConstraint(TPHConstraint constraint) {
// if(constraint.getRel() == Relation.EXTENDS)
// return constraint.getLeft();
// return null;
// }
//
// public String getRightSideOfConstraint(TPHConstraint constraint) {
// if(constraint.getRel() == Relation.EXTENDS)
// return constraint.getRight();
// return null;
// }
public List<TPHConstraint> getCs() {
return cs;
}
// public List<ClassConstraint,MethodConstraint> getFamilyOfGeneratedGenerics(){
//
// }
public void addConstraintToClassConstraint() { //Inputparameter List<TPHConstraint> constraintsSet weg
List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(cs);
cs_cl.addAll(classConstraints1);
List<ClassConstraint> classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
cs_cl.addAll(classConstraints2);
@ -87,10 +72,14 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
public List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> cs) {
//TODO:
for(TPHConstraint cons: cs){
System.out.println(cons);
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
if(cons.getRight()!=null && cons.getRel()==Relation.EXTENDS) {
cs_cl.add(new ClassConstraint(cons.getLeft(), cons.getRight(),cons.getRel()));
}
}
System.out.println(cs_cl);
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
return cs_cl;
}
@ -101,12 +90,15 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
public List<ClassConstraint> transitiveSubtypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> classConstraints) {
//TODO:
for(ClassConstraint cCons: classConstraints) {
for(TPHConstraint allCons: allConstraints)
// if(tphExtractor.containsConstraint(allConstraints, cCons)) {
// }
if(cCons.getRight() == )
}
if(cCons.getRight() == allCons.getLeft()){
}
}
return cs_cl;
}
/**
* Def. FGG: dritte Zeile von cs_cl
@ -114,7 +106,8 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
* or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)}
*/
public List<ClassConstraint> hasNoSupertypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> classConstraints) {
//TODO:
return cs_cl;
}
@ -123,7 +116,8 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
* {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs}
*/
public List<MethodConstraint> typeOfTheMethodInClSigma() { // cl_\sigma??
//TODO:
return cs_m;
}
/**
@ -131,7 +125,8 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
* {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs}
*/
public List<MethodConstraint> firstTransitiveSubtypeForMethodTypes() { //transitive closure of cs
//TODO:
return cs_m;
}
/**
@ -139,7 +134,8 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
* {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs}
*/
public List<MethodConstraint> secondTransitiveSubtypeForMethodTypes() {
//TODO:
return cs_m;
}
/**
@ -148,14 +144,16 @@ public class FamilyOfGeneratedGenerics { // extends TPHConstraint?
* (\existsnot T': T <. T') \in cs)}
*/
public List<MethodConstraint> hasNoSupertypeForMethodTypes() {
//TODO:
return cs_m;
}
/**
* nimm die Menge cs_cl aus cs_m raus
*/
public List<MethodConstraint> methodTypesWithoutClassTypes() {
//TODO:
return cs_m;
}

View File

@ -136,7 +136,7 @@ public class GeneratedGenericsFinder implements ASTVisitor {
//PL 2020-10-16: Ab hier GGenerics implementieren durch Ali
//Rueckgabe an generatedGenericsForSF
fogg = new FamilyOfGeneratedGenerics(tphExtractor);
fogg.addConstraintToClassConstraint();
tphsClass = tphExtractor.tphsClass;
simplifiedConstraints = GenericsGenerator.simplifyConstraints(tphExtractor, tphsClass);