diff --git a/src/control/Start.java b/src/control/Start.java index f5a6bba1..0e16aa09 100644 --- a/src/control/Start.java +++ b/src/control/Start.java @@ -5,7 +5,7 @@ import de.dhbwstuttgart.strucTypes4.syntaxtree.Class; import de.dhbwstuttgart.strucTypes4.syntaxtree.Field; import de.dhbwstuttgart.strucTypes4.syntaxtree.Method; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarType; import java.util.ArrayList; @@ -19,7 +19,7 @@ import java.util.Map; public class Start { - Map assumptionsGlobal = new HashMap<>(); + Map assumptionsGlobal = new HashMap<>(); List results = new ArrayList<>(); diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintField.java b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintField.java index 0ef9bd66..cbfe3e17 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintField.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintField.java @@ -1,27 +1,27 @@ package de.dhbwstuttgart.strucTypes4.algo; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 09.04.17. */ public class ConstraintField extends ConstraintAbstract { - TypeVarAbstract receiver; + RefTypeOrTPHOrWildcardOrGeneric receiver; String nameField; - TypeVarAbstract caller; + RefTypeOrTPHOrWildcardOrGeneric caller; - public ConstraintField(TypeVarAbstract receiver, String nameField, TypeVarAbstract caller) { + public ConstraintField(RefTypeOrTPHOrWildcardOrGeneric receiver, String nameField, RefTypeOrTPHOrWildcardOrGeneric caller) { this.receiver = receiver; this.nameField = nameField; this.caller = caller; } - public TypeVarAbstract getReceiver() { + public RefTypeOrTPHOrWildcardOrGeneric getReceiver() { return receiver; } - public void setReceiver(TypeVarAbstract receiver) { + public void setReceiver(RefTypeOrTPHOrWildcardOrGeneric receiver) { this.receiver = receiver; } @@ -33,11 +33,11 @@ public class ConstraintField extends ConstraintAbstract { this.nameField = nameField; } - public TypeVarAbstract getCaller() { + public RefTypeOrTPHOrWildcardOrGeneric getCaller() { return caller; } - public void setCaller(TypeVarAbstract caller) { + public void setCaller(RefTypeOrTPHOrWildcardOrGeneric caller) { this.caller = caller; } diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintMethod.java b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintMethod.java index 25d0e6ed..ac591828 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintMethod.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintMethod.java @@ -1,6 +1,6 @@ package de.dhbwstuttgart.strucTypes4.algo; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -9,13 +9,13 @@ import java.util.List; */ public class ConstraintMethod extends ConstraintAbstract { - TypeVarAbstract receiver; + RefTypeOrTPHOrWildcardOrGeneric receiver; String methodName; - List argsTypes; - TypeVarAbstract returnType; - List argsBetaTypes; + List argsTypes; + RefTypeOrTPHOrWildcardOrGeneric returnType; + List argsBetaTypes; - public ConstraintMethod(TypeVarAbstract receiver, String methodName, List argsTypes, TypeVarAbstract returnType, List argsBetaTypes) { + public ConstraintMethod(RefTypeOrTPHOrWildcardOrGeneric receiver, String methodName, List argsTypes, RefTypeOrTPHOrWildcardOrGeneric returnType, List argsBetaTypes) { this.receiver = receiver; this.methodName = methodName; this.argsTypes = argsTypes; @@ -24,11 +24,11 @@ public class ConstraintMethod extends ConstraintAbstract { } - public TypeVarAbstract getReceiver() { + public RefTypeOrTPHOrWildcardOrGeneric getReceiver() { return receiver; } - public void setReceiver(TypeVarAbstract receiver) { + public void setReceiver(RefTypeOrTPHOrWildcardOrGeneric receiver) { this.receiver = receiver; } @@ -40,27 +40,27 @@ public class ConstraintMethod extends ConstraintAbstract { this.methodName = methodName; } - public List getArgsTypes() { + public List getArgsTypes() { return argsTypes; } - public void setArgsTypes(List argsTypes) { + public void setArgsTypes(List argsTypes) { this.argsTypes = argsTypes; } - public TypeVarAbstract getReturnType() { + public RefTypeOrTPHOrWildcardOrGeneric getReturnType() { return returnType; } - public void setReturnType(TypeVarAbstract returnType) { + public void setReturnType(RefTypeOrTPHOrWildcardOrGeneric returnType) { this.returnType = returnType; } - public List getArgsBetaTypes() { + public List getArgsBetaTypes() { return argsBetaTypes; } - public void setArgsBetaTypes(List argsBetaTypes) { + public void setArgsBetaTypes(List argsBetaTypes) { this.argsBetaTypes = argsBetaTypes; } diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubType.java b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubType.java index b3d44c33..69492000 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubType.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubType.java @@ -1,16 +1,16 @@ package de.dhbwstuttgart.strucTypes4.algo; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 09.04.17. */ public class ConstraintSubType extends ConstraintAbstract { - TypeVarAbstract typeKleiner; - TypeVarAbstract typeGroeßer; + RefTypeOrTPHOrWildcardOrGeneric typeKleiner; + RefTypeOrTPHOrWildcardOrGeneric typeGroeßer; - public ConstraintSubType(TypeVarAbstract typeKleiner, TypeVarAbstract typeGroeßer) { + public ConstraintSubType(RefTypeOrTPHOrWildcardOrGeneric typeKleiner, RefTypeOrTPHOrWildcardOrGeneric typeGroeßer) { this.typeKleiner = typeKleiner; this.typeGroeßer = typeGroeßer; } @@ -19,19 +19,19 @@ public class ConstraintSubType extends ConstraintAbstract { - public TypeVarAbstract getTypeKleiner() { + public RefTypeOrTPHOrWildcardOrGeneric getTypeKleiner() { return typeKleiner; } - public void setTypeKleiner(TypeVarAbstract typeKleiner) { + public void setTypeKleiner(RefTypeOrTPHOrWildcardOrGeneric typeKleiner) { this.typeKleiner = typeKleiner; } - public TypeVarAbstract getTypeGroeßer() { + public RefTypeOrTPHOrWildcardOrGeneric getTypeGroeßer() { return typeGroeßer; } - public void setTypeGroeßer(TypeVarAbstract typeGroeßer) { + public void setTypeGroeßer(RefTypeOrTPHOrWildcardOrGeneric typeGroeßer) { this.typeGroeßer = typeGroeßer; } diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubTypeInterface.java b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubTypeInterface.java index 7438b631..8625a253 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubTypeInterface.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/ConstraintSubTypeInterface.java @@ -1,7 +1,7 @@ package de.dhbwstuttgart.strucTypes4.algo; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -10,11 +10,11 @@ import java.util.List; */ public class ConstraintSubTypeInterface extends ConstraintAbstract{ - TypeVarAbstract kleiner; - TypeVarAbstract strucType; - List generics; + RefTypeOrTPHOrWildcardOrGeneric kleiner; + RefTypeOrTPHOrWildcardOrGeneric strucType; + List generics; - public ConstraintSubTypeInterface(TypeVarAbstract kleiner, TypeVarAbstract strucType, List generics) { + public ConstraintSubTypeInterface(RefTypeOrTPHOrWildcardOrGeneric kleiner, RefTypeOrTPHOrWildcardOrGeneric strucType, List generics) { this.kleiner = kleiner; this.strucType = strucType; this.generics = generics; diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/Construct2.java b/src/de/dhbwstuttgart/strucTypes4/algo/Construct2.java index 12b0ca28..11243065 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/Construct2.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/Construct2.java @@ -25,7 +25,7 @@ public class Construct2 { List interfaceList = new ArrayList<>(); // Sammeln der Constriants - Map> sortetConstr = sortiereConstraints(constraints); + Map> sortetConstr = sortiereConstraints(constraints); // Erstellen der Interfaces @@ -41,8 +41,8 @@ public class Construct2 { for (ConstraintAbstract constraint : constraints) { if (constraint.getClass().equals(ConstraintSubType.class)) { ConstraintSubType constraintSubType = (ConstraintSubType) constraint; - TypeVarAbstract kleiner = mapAN.getNeu(constraintSubType.getTypeKleiner()); - TypeVarAbstract groeßer = mapAN.getNeu(constraintSubType.getTypeGroeßer()); + RefTypeOrTPHOrWildcardOrGeneric kleiner = mapAN.getNeu(constraintSubType.getTypeKleiner()); + RefTypeOrTPHOrWildcardOrGeneric groeßer = mapAN.getNeu(constraintSubType.getTypeGroeßer()); ConstraintSubType cNeu = new ConstraintSubType(kleiner,groeßer); constraintsNeu.add(cNeu); } @@ -58,7 +58,7 @@ public class Construct2 { // Erstelle constraints + Interfaces für den strukturellen Typen - for (TypeVarAbstract typeVar : sortetConstr.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric typeVar : sortetConstr.keySet()) { ConstructInterfaceForType2 constructInterfaceForType2 = new ConstructInterfaceForType2(sortetConstr.get(typeVar),typeVar,mapAN.getNeu(typeVar) , mapAN); interfaceList.add(constructInterfaceForType2.getResultInterface()); constraintsNeu.addAll(constructInterfaceForType2.getResultConstraints()); @@ -75,13 +75,13 @@ public class Construct2 { // Sortieren der Constriants nach Strukturellem Typ - private Map> sortiereConstraints(List constraints) { + private Map> sortiereConstraints(List constraints) { - Map> constraintMap = new ConcurrentHashMap<>(); + Map> constraintMap = new ConcurrentHashMap<>(); for (ConstraintAbstract con : constraints) { - TypeVarAbstract receiver = null; + RefTypeOrTPHOrWildcardOrGeneric receiver = null; // Suche den Receiver der Metohde oder des Feldes if (con.getClass().equals(ConstraintMethod.class)) { @@ -118,14 +118,14 @@ class ConstructInterfaceForType2 { private List resultConstraints; - public ConstructInterfaceForType2(List constraints , TypeVarAbstract receiverAlt , TypeVarAbstract receiverNeu , MappingAltNeu altNeu) { + public ConstructInterfaceForType2(List constraints , RefTypeOrTPHOrWildcardOrGeneric receiverAlt , RefTypeOrTPHOrWildcardOrGeneric receiverNeu , MappingAltNeu altNeu) { resultConstraints = new ArrayList<>(); List fields = new ArrayList<>(); List methods = new ArrayList<>(); - List genericsInterface = new ArrayList<>(); + List genericsInterface = new ArrayList<>(); // Erstelle Felder sowie Methoden des Interfaces @@ -142,10 +142,10 @@ class ConstructInterfaceForType2 { // Erstelle Methoden if (constraint.getClass().equals(ConstraintMethod.class)) { ConstraintMethod constraintMethod = (ConstraintMethod) constraint; - TypeVarAbstract rtType = TypeVarFactory.makeTypeVar(); + RefTypeOrTPHOrWildcardOrGeneric rtType = TypeVarFactory.makeTypeVar(); - List neueArgsTV = new ArrayList<>(); - for (TypeVarAbstract tv : constraintMethod.getArgsTypes()) { + List neueArgsTV = new ArrayList<>(); + for (RefTypeOrTPHOrWildcardOrGeneric tv : constraintMethod.getArgsTypes()) { neueArgsTV.add(TypeVarFactory.makeTypeVar()); } diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/MappingAltNeu.java b/src/de/dhbwstuttgart/strucTypes4/algo/MappingAltNeu.java index 967f6d34..241e3a18 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/MappingAltNeu.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/MappingAltNeu.java @@ -1,6 +1,6 @@ package de.dhbwstuttgart.strucTypes4.algo; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarType; import java.util.ArrayList; @@ -12,10 +12,10 @@ import java.util.List; public class MappingAltNeu { - List altList = new ArrayList<>(); - List neuList = new ArrayList<>(); + List altList = new ArrayList<>(); + List neuList = new ArrayList<>(); - public void addTypeVar(TypeVarAbstract alt, TypeVarAbstract neu) { + public void addTypeVar(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) { altList.add(alt); // Versuch bereits bekannte Typen mitzunehmen @@ -28,7 +28,7 @@ public class MappingAltNeu { } } - public TypeVarAbstract getNeu (TypeVarAbstract altTypeVar) { + public RefTypeOrTPHOrWildcardOrGeneric getNeu (RefTypeOrTPHOrWildcardOrGeneric altTypeVar) { // Wenn typ bereits bekannt ist if (altTypeVar.getClass().equals(TypeVarType.class)) { diff --git a/src/de/dhbwstuttgart/strucTypes4/algo/TypeExpr.java b/src/de/dhbwstuttgart/strucTypes4/algo/TypeExpr.java index 3b28679d..0e62a980 100644 --- a/src/de/dhbwstuttgart/strucTypes4/algo/TypeExpr.java +++ b/src/de/dhbwstuttgart/strucTypes4/algo/TypeExpr.java @@ -2,7 +2,7 @@ package de.dhbwstuttgart.strucTypes4.algo; import de.dhbwstuttgart.strucTypes4.syntaxtree.*; import de.dhbwstuttgart.strucTypes4.syntaxtree.Class; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarType; @@ -15,7 +15,7 @@ import java.util.Map; */ public class TypeExpr { - public static List typeExpr(ExpressionAbstract exp, Map ass , TypeVarAbstract rec , TypeVarAbstract returnType , TypeVarStore typeVarStore) { + public static List typeExpr(ExpressionAbstract exp, Map ass , RefTypeOrTPHOrWildcardOrGeneric rec , RefTypeOrTPHOrWildcardOrGeneric returnType , TypeVarStore typeVarStore) { if (exp.getClass().equals(ExprVar.class )) { ExprVar exprVar = (ExprVar) exp; @@ -38,8 +38,8 @@ public class TypeExpr { // Reihenfolge wichtig wg Rekursiven aufrufen und TypVariablen !!! constraints.addAll(typeExpr(expression.getReceiver(), ass, null ,null , typeVarStore)); - TypeVarAbstract tvReceiver = typeVarStore.storeTPH(expression.getReceiver().getTypePlaceHolder()); - TypeVarAbstract tvThis = typeVarStore.storeTPH(expression.getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tvReceiver = typeVarStore.storeTPH(expression.getReceiver().getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tvThis = typeVarStore.storeTPH(expression.getTypePlaceHolder()); constraints.addAll(typeExpr(expression.getCaller(),ass, tvReceiver , tvThis , typeVarStore)); return constraints; } @@ -52,7 +52,7 @@ public class TypeExpr { String klassenname = exprNew.getClassType(); String assumptionKey = "$" + klassenname; - TypeVarAbstract tv = ass.get(assumptionKey); + RefTypeOrTPHOrWildcardOrGeneric tv = ass.get(assumptionKey); Class typeClass = ((TypeVarType) tv).getTypeClass(); typeVarStore.addTuple(new TypeVarType(typeClass) , exprNew.getTypePlaceHolder()); @@ -66,7 +66,7 @@ public class TypeExpr { //constriants.forEach((ConstraintAbstract cs) -> cs.replace(new TPH(gen) , new TPH(generic.get(gen)) )); String typeVar = key; String klasse = generic.get(key); - TypeVarAbstract klasseType = ass.get("$" + klasse); + RefTypeOrTPHOrWildcardOrGeneric klasseType = ass.get("$" + klasse); TypeVarType klasseTypeCast = (TypeVarType) klasseType; } diff --git a/src/de/dhbwstuttgart/strucTypes4/parserFWJ/Parser.java b/src/de/dhbwstuttgart/strucTypes4/parserFWJ/Parser.java index 96295278..1ab5f6c1 100644 --- a/src/de/dhbwstuttgart/strucTypes4/parserFWJ/Parser.java +++ b/src/de/dhbwstuttgart/strucTypes4/parserFWJ/Parser.java @@ -12,7 +12,7 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker; import de.dhbwstuttgart.strucTypes4.syntaxtree.*; import de.dhbwstuttgart.strucTypes4.syntaxtree.Class; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import java.util.*; @@ -43,7 +43,7 @@ public class Parser { // Quellcode wird geparst. Evtl. bekannte Klassen müssen über die Assumptions mitgegeben werden - public Class parseCode(String quellcode , Map ass ) { + public Class parseCode(String quellcode , Map ass ) { SourceFile sf = parse(quellcode); TI typeinference = new TI(ass,sf.getClassList().get(0)); return typeinference.getResultClassTypedWithInterfaces(); @@ -59,7 +59,7 @@ class TI { Class resultClassTypedWithInterfaces; - public TI (Map ass, Class aClass) { + public TI (Map ass, Class aClass) { Type type = new Type(ass,aClass); @@ -114,10 +114,10 @@ class Type { Class resultClassTyped; List resultConstraintSet = new ArrayList<>(); - public Type(Map ass, Class aClass) { + public Type(Map ass, Class aClass) { // 1. Erstellen der Assumptions für die Klasse - Map fass_mass = aClass.makeAssumptions(); + Map fass_mass = aClass.makeAssumptions(); // ToDo Vereinigen der Assumptions fass_mass.putAll(ass); @@ -134,7 +134,7 @@ class Type { // AssAll Ass und fass und mass und this:A // ToDo this:a - Map assMethod = method.makeAssumptions(aClass.typeVarStore); + Map assMethod = method.makeAssumptions(aClass.typeVarStore); assMethod.putAll(fass_mass); resultConstraintSet.addAll(method.typeExpr(assMethod , aClass.typeVarStore)); diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Class.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Class.java index c697d857..bda12464 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Class.java @@ -2,7 +2,7 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; import de.dhbwstuttgart.strucTypes4.algo.ConstraintAbstract; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore; import java.util.HashMap; @@ -32,24 +32,24 @@ public class Class extends SyntaxNode{ } - public Map makeAssumptions() { + public Map makeAssumptions() { // Name bei Feldern feld, name bei methoden methode() - Map ass = new HashMap<>(); + Map ass = new HashMap<>(); // felder for (Field f : felder) { - TypeVarAbstract tv = typeVarStore.storeTPH(f.getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tv = typeVarStore.storeTPH(f.getTypePlaceHolder()); ass.put(f.getVar_name() , tv); } // methoden for (Method m : methoden) { - TypeVarAbstract tv = typeVarStore.storeTPH(m.getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tv = typeVarStore.storeTPH(m.getTypePlaceHolder()); ass.put(m.getName()+"()", tv); } // This einfügen - TypeVarAbstract tv = typeVarStore.storeTPH(getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tv = typeVarStore.storeTPH(getTypePlaceHolder()); ass.put("this" , tv); return ass; diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprMCall.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprMCall.java index 1dea881c..18c3b600 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprMCall.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprMCall.java @@ -1,7 +1,7 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; import de.dhbwstuttgart.strucTypes4.algo.*; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarType; @@ -23,7 +23,7 @@ public class ExprMCall extends ExpressionAbstract { } - public List typeExpr (Map ass , TypeVarAbstract receiver , TypeVarAbstract returnType, TypeVarStore typeVarStore) { + public List typeExpr (Map ass , RefTypeOrTPHOrWildcardOrGeneric receiver , RefTypeOrTPHOrWildcardOrGeneric returnType, TypeVarStore typeVarStore) { List constraints = new ArrayList<>(); @@ -38,7 +38,7 @@ public class ExprMCall extends ExpressionAbstract { List arguments = m.getArgs(); - List typeVars = new ArrayList<>(); + List typeVars = new ArrayList<>(); // Ermitteln der TypeVars der alten Klasse for (Argument argument : arguments ) { typeVars.add(c.getTypeVarStore().getTypeVarByTPH(argument.getTypePlaceHolder())); @@ -51,8 +51,8 @@ public class ExprMCall extends ExpressionAbstract { // Hinzufügen von Constraints for (int i = 0; i < args.size() ; i++) { - TypeVarAbstract tvInNewKlasse = typeVars.get(i); - TypeVarAbstract typeInAktKlasse = typeVarStore.getTypeVarByTPH(args.get(i).getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tvInNewKlasse = typeVars.get(i); + RefTypeOrTPHOrWildcardOrGeneric typeInAktKlasse = typeVarStore.getTypeVarByTPH(args.get(i).getTypePlaceHolder()); constraints.add(new ConstraintSubType(tvInNewKlasse , typeInAktKlasse)); } @@ -68,11 +68,11 @@ public class ExprMCall extends ExpressionAbstract { args.forEach(x -> constraints.addAll( TypeExpr.typeExpr( x,ass,null,null,typeVarStore) )); // Liste mit Typen der Argumente der Methode sammeln - List types = new ArrayList<>(); + List types = new ArrayList<>(); args.forEach(x -> types.add(typeVarStore.getTypeVarByTPH(x.getTypePlaceHolder()))); // Neue Liste mit neuen Beta - Argumenten erstellen - List betaTypes = new ArrayList<>(); + List betaTypes = new ArrayList<>(); args.forEach(x -> betaTypes.add( typeVarStore.makeFreshTypeVar() )); diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprVar.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprVar.java index 78ad5757..3bf50ff2 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprVar.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/ExprVar.java @@ -1,7 +1,7 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; import de.dhbwstuttgart.strucTypes4.algo.ConstraintAbstract; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore; import java.util.ArrayList; @@ -16,10 +16,10 @@ public class ExprVar extends ExpressionAbstract { String name; - public List typeExpr(Map ass, TypeVarStore typeVarStore) { + public List typeExpr(Map ass, TypeVarStore typeVarStore) { List constriants = new ArrayList<>(); - TypeVarAbstract tv = ass.get(name); + RefTypeOrTPHOrWildcardOrGeneric tv = ass.get(name); typeVarStore.addTuple(tv,getTypePlaceHolder()); return constriants; } diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/FieldInterface.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/FieldInterface.java index 337ff52a..7c04fd04 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/FieldInterface.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/FieldInterface.java @@ -1,26 +1,26 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 09.04.17. */ public class FieldInterface { - TypeVarAbstract type; + RefTypeOrTPHOrWildcardOrGeneric type; String name; - public FieldInterface(TypeVarAbstract type, String name) { + public FieldInterface(RefTypeOrTPHOrWildcardOrGeneric type, String name) { this.type = type; this.name = name; } - public TypeVarAbstract getType() { + public RefTypeOrTPHOrWildcardOrGeneric getType() { return type; } - public void setType(TypeVarAbstract type) { + public void setType(RefTypeOrTPHOrWildcardOrGeneric type) { this.type = type; } diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Interface.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Interface.java index 1c30c80a..07a45daa 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Interface.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Interface.java @@ -1,7 +1,7 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -11,13 +11,13 @@ import java.util.List; */ public class Interface { - TypeVarAbstract strucType; + RefTypeOrTPHOrWildcardOrGeneric strucType; List fields; List methods; - List generics; + List generics; - public Interface(TypeVarAbstract strucType, List fields, List methods, List generics) { + public Interface(RefTypeOrTPHOrWildcardOrGeneric strucType, List fields, List methods, List generics) { this.strucType = strucType; this.fields = fields; this.methods = methods; @@ -40,11 +40,11 @@ public class Interface { this.methods = methods; } - public List getGenerics() { + public List getGenerics() { return generics; } - public void setGenerics(List generics) { + public void setGenerics(List generics) { this.generics = generics; } diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Method.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Method.java index 62abad0f..2f2d180b 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/Method.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; import de.dhbwstuttgart.strucTypes4.algo.ConstraintAbstract; import de.dhbwstuttgart.strucTypes4.algo.TypeExpr; import de.dhbwstuttgart.strucTypes4.typePlaceHolder.TPH; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarStore; import java.util.HashMap; @@ -29,16 +29,16 @@ public class Method extends SyntaxNode { } - public Map makeAssumptions(TypeVarStore typeVarStore) { - Map assLokal = new HashMap<>(); + public Map makeAssumptions(TypeVarStore typeVarStore) { + Map assLokal = new HashMap<>(); for (Argument arg : args ) { - TypeVarAbstract tv = typeVarStore.storeTPH(arg.getTypePlaceHolder()); + RefTypeOrTPHOrWildcardOrGeneric tv = typeVarStore.storeTPH(arg.getTypePlaceHolder()); assLokal.put(arg.getName(), tv ); } return assLokal; } - public List typeExpr(Map ass, TypeVarStore typeVarStore) { + public List typeExpr(Map ass, TypeVarStore typeVarStore) { return TypeExpr.typeExpr(expression,ass,null , null , typeVarStore); } diff --git a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/MethodInterface.java b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/MethodInterface.java index 6accccb7..274f4f91 100644 --- a/src/de/dhbwstuttgart/strucTypes4/syntaxtree/MethodInterface.java +++ b/src/de/dhbwstuttgart/strucTypes4/syntaxtree/MethodInterface.java @@ -1,6 +1,6 @@ package de.dhbwstuttgart.strucTypes4.syntaxtree; -import de.dhbwstuttgart.strucTypes4.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.strucTypes4.typeVars.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -10,11 +10,11 @@ import java.util.List; public class MethodInterface { String name; - TypeVarAbstract rtType; - List argsTypes; + RefTypeOrTPHOrWildcardOrGeneric rtType; + List argsTypes; - public MethodInterface(String name, TypeVarAbstract rtType, List argsTypes) { + public MethodInterface(String name, RefTypeOrTPHOrWildcardOrGeneric rtType, List argsTypes) { this.name = name; this.rtType = rtType; this.argsTypes = argsTypes; @@ -29,19 +29,19 @@ public class MethodInterface { this.name = name; } - public TypeVarAbstract getRtType() { + public RefTypeOrTPHOrWildcardOrGeneric getRtType() { return rtType; } - public void setRtType(TypeVarAbstract rtType) { + public void setRtType(RefTypeOrTPHOrWildcardOrGeneric rtType) { this.rtType = rtType; } - public List getArgsTypes() { + public List getArgsTypes() { return argsTypes; } - public void setArgsTypes(List argsTypes) { + public void setArgsTypes(List argsTypes) { this.argsTypes = argsTypes; } diff --git a/src/de/dhbwstuttgart/strucTypes4/typeVars/RefTypeOrTPHOrWildcardOrGeneric.java b/src/de/dhbwstuttgart/strucTypes4/typeVars/RefTypeOrTPHOrWildcardOrGeneric.java index 6559154b..deb66a95 100644 --- a/src/de/dhbwstuttgart/strucTypes4/typeVars/RefTypeOrTPHOrWildcardOrGeneric.java +++ b/src/de/dhbwstuttgart/strucTypes4/typeVars/RefTypeOrTPHOrWildcardOrGeneric.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.strucTypes4.typeVars; /** * Created by sebastian on 14.04.17. */ -public abstract class TypeVarAbstract { +public abstract class RefTypeOrTPHOrWildcardOrGeneric { diff --git a/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVar.java b/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVar.java index 802c267e..5d88ec50 100644 --- a/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVar.java +++ b/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVar.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.strucTypes4.typeVars; /** * Created by sebastian on 14.04.17. */ -public class TypeVar extends TypeVarAbstract { +public class TypeVar extends RefTypeOrTPHOrWildcardOrGeneric { private String id; diff --git a/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarStore.java b/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarStore.java index 97db1dfd..1dfdb9e7 100644 --- a/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarStore.java +++ b/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarStore.java @@ -14,11 +14,11 @@ import java.util.List; public class TypeVarStore { - private HashMap> map = new HashMap<>(); + private HashMap> map = new HashMap<>(); - public TypeVarAbstract storeTPH(TPH tph) { + public RefTypeOrTPHOrWildcardOrGeneric storeTPH(TPH tph) { if (getTypeVarByTPH(tph) == null) { TypeVar tvNeu = TypeVarFactory.makeTypeVar(); @@ -31,7 +31,7 @@ public class TypeVarStore { } - public TypeVarAbstract makeFreshTypeVar() { + public RefTypeOrTPHOrWildcardOrGeneric makeFreshTypeVar() { TypeVar neu = TypeVarFactory.makeTypeVar(); List tphList = new ArrayList<>(); map.put(neu,tphList); @@ -40,7 +40,7 @@ public class TypeVarStore { - public void addTuple(TypeVarAbstract tv, TPH tph) { + public void addTuple(RefTypeOrTPHOrWildcardOrGeneric tv, TPH tph) { // TypVar bereits vorhandne @@ -65,13 +65,13 @@ public class TypeVarStore { } - public List getTPHByTypeVar(TypeVarAbstract tv) { + public List getTPHByTypeVar(RefTypeOrTPHOrWildcardOrGeneric tv) { return map.get(tv); } - public TypeVarAbstract getTypeVarByTPH(TPH tph) { + public RefTypeOrTPHOrWildcardOrGeneric getTypeVarByTPH(TPH tph) { // TPH ist bereits einer TypVar zugeordnet - for (TypeVarAbstract typeVar : map.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric typeVar : map.keySet()) { if (map.get(typeVar).contains(tph)) { return typeVar; } @@ -87,7 +87,7 @@ public class TypeVarStore { public TypeVarStore freshVariables() { TypeVarStore typeVarStore = new TypeVarStore(); - for (TypeVarAbstract tvarOld : map.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric tvarOld : map.keySet()) { TypeVar tvNew = TypeVarFactory.makeTypeVar(); typeVarStore.map.put(tvNew,map.get(tvarOld)); } @@ -101,11 +101,11 @@ public class TypeVarStore { TypeVarStore typeVarStore = new TypeVarStore(); - for (TypeVarAbstract tvarOld : map.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric tvarOld : map.keySet()) { // Wenn der Typ bereits bekannt ist, wird dieser nicht ersetzt. if (tvarOld.getClass().equals(TypeVarType.class)) { - TypeVarAbstract tvNew = tvarOld; + RefTypeOrTPHOrWildcardOrGeneric tvNew = tvarOld; typeVarStore.map.put(tvNew,map.get(tvarOld)); mappingAltNeu.addTypeVar(tvarOld,tvNew); } @@ -121,7 +121,7 @@ public class TypeVarStore { - public boolean replaceTypeVar(TypeVarAbstract old, TypeVarAbstract neu) { + public boolean replaceTypeVar(RefTypeOrTPHOrWildcardOrGeneric old, RefTypeOrTPHOrWildcardOrGeneric neu) { if (map.containsKey(old)) { List tphList = map.get(old); @@ -139,7 +139,7 @@ public class TypeVarStore { @Override public String toString() { String res = "--- TypeVarStore ---\n"; - for (TypeVarAbstract tvar : map.keySet() ) { + for (RefTypeOrTPHOrWildcardOrGeneric tvar : map.keySet() ) { res = res + tvar.toString() + " : " + map.get(tvar).toString() + "\n"; } return String.format(res); diff --git a/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarType.java b/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarType.java index 2e85ec81..617f8889 100644 --- a/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarType.java +++ b/src/de/dhbwstuttgart/strucTypes4/typeVars/TypeVarType.java @@ -6,7 +6,7 @@ import de.dhbwstuttgart.strucTypes4.syntaxtree.Class; /** * Created by sebastian on 14.04.17. */ -public class TypeVarType extends TypeVarAbstract { +public class TypeVarType extends RefTypeOrTPHOrWildcardOrGeneric { private Class typeClass; diff --git a/src/de/dhbwstuttgart/strucTypes5/algo/ConstructInterfaceTemplates.java b/src/de/dhbwstuttgart/strucTypes5/algo/ConstructInterfaceTemplates.java index 16f02be1..7252c622 100644 --- a/src/de/dhbwstuttgart/strucTypes5/algo/ConstructInterfaceTemplates.java +++ b/src/de/dhbwstuttgart/strucTypes5/algo/ConstructInterfaceTemplates.java @@ -12,7 +12,7 @@ import de.dhbwstuttgart.strucTypes5.interfaceTemplates.Interface; import de.dhbwstuttgart.strucTypes5.interfaceTemplates.MethodInterface; import de.dhbwstuttgart.strucTypes5.typeVars.*; import de.dhbwstuttgart.syntaxtree.*; - +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.*; @@ -107,8 +107,8 @@ public class ConstructInterfaceTemplates { List fields = new ArrayList<>(); List methods = new ArrayList<>(); - List generics = new ArrayList<>(); - List genericsForConstraint = new ArrayList<>(); + List generics = new ArrayList<>(); + List genericsForConstraint = new ArrayList<>(); for (ConstraintAbstract constraint : constraintSet) { @@ -127,7 +127,7 @@ public class ConstructInterfaceTemplates { } // Erstelle Generic für neuen Typvariablen für das Interface - List args = new ArrayList<>(); + List args = new ArrayList<>(); for (TypeVar tv : cm.getArgumentTypes()) { TypeVar generic = typeVarStore.makeFreshTypeVar(); args.add(generic); @@ -151,8 +151,8 @@ public class ConstructInterfaceTemplates { TypeVar neuerTypeReveiver = (TypeVar) mappingAltNeu.getNeu(receiver); InterfaceForConstraint interfaceForConstraint = new InterfaceForConstraint(receiver, genericsForConstraint); - TypeVarAbstract tSub = neuerTypeReveiver; - TypeVarAbstract tSuper = TypeVarFactory.makeTypeVar(interfaceForConstraint); + RefTypeOrTPHOrWildcardOrGeneric tSub = neuerTypeReveiver; + RefTypeOrTPHOrWildcardOrGeneric tSuper = TypeVarFactory.makeTypeVar(interfaceForConstraint); ConstraintSubType newConstraint = new ConstraintSubType(tSub, tSuper); remainingConstraints.add(newConstraint); diff --git a/src/de/dhbwstuttgart/strucTypes5/algo/TI.java b/src/de/dhbwstuttgart/strucTypes5/algo/TI.java index 3ee42dc5..67110356 100644 --- a/src/de/dhbwstuttgart/strucTypes5/algo/TI.java +++ b/src/de/dhbwstuttgart/strucTypes5/algo/TI.java @@ -11,11 +11,12 @@ import de.dhbwstuttgart.strucTypes5.constraints.OldConstraints; import de.dhbwstuttgart.strucTypes5.solve.Rules; import de.dhbwstuttgart.strucTypes5.typeVars.ResultTuple; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.Method; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.constraints.Constraint; import java.util.ArrayList; @@ -58,7 +59,7 @@ public class TI { // Generiere Generics für die Klasse - List generics = new ArrayList<>(); + List generics = new ArrayList<>(); for (Method m : cl.getMethods()) { generics.add(tp.getTypeVarStore().getTypeVarByTPH(m.getType())); for (FormalParameter fp : m.getParameterList().getFormalparalist()) { @@ -151,12 +152,12 @@ public class TI { if (rc instanceof ConstraintSubType) { ConstraintSubType cSub = (ConstraintSubType) rc; - TypeVarAbstract tSubNeu = null; - TypeVarAbstract tSuperNeu = null; + RefTypeOrTPHOrWildcardOrGeneric tSubNeu = null; + RefTypeOrTPHOrWildcardOrGeneric tSuperNeu = null; // Check for Klasse - TypeVarAbstract tSub = cSub.getSubtype(); - TypeVarAbstract tSuper = cSub.getSuperType(); + RefTypeOrTPHOrWildcardOrGeneric tSub = cSub.getSubtype(); + RefTypeOrTPHOrWildcardOrGeneric tSuper = cSub.getSuperType(); if (tSub instanceof TypeVar) { tSubNeu = typeVarStore.isType((TypeVar) tSub); diff --git a/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java b/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java index 6cd0f0af..1810296d 100644 --- a/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java +++ b/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java @@ -7,7 +7,7 @@ import de.dhbwstuttgart.strucTypes5.assumptions.ChangeTypeVars; import de.dhbwstuttgart.strucTypes5.ausgabe.Class2String; import de.dhbwstuttgart.strucTypes5.constraints.*; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarFactory; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore; import de.dhbwstuttgart.syntaxtree.Method; @@ -38,7 +38,7 @@ public class TypeExpr { Return rt = (Return) method.get_Block().getStatements().get(0); // Adds the Relation TypVariable Method == TypVariable Return Expression - TypeVarAbstract typeVarMethod = typeVarStore.getTypeVarByTPH(method.getType()); + RefTypeOrTPHOrWildcardOrGeneric typeVarMethod = typeVarStore.getTypeVarByTPH(method.getType()); typeVarStore.addTuple(typeVarMethod, rt.getType()); @@ -69,7 +69,7 @@ public class TypeExpr { LocalVar localVar = (LocalVar) expression; // Erstellung keines Constriants // Lediglich eintrag in TypeVarStore - TypeVarAbstract typeVar = assumptionMap.getVarAssumption(localVar.get_expression()); + RefTypeOrTPHOrWildcardOrGeneric typeVar = assumptionMap.getVarAssumption(localVar.get_expression()); typeVarStore.addTuple(typeVar,localVar.getType()); List result = new ArrayList<>(); return result; diff --git a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionArgument.java b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionArgument.java index 42b3d66e..30a75155 100644 --- a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionArgument.java +++ b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionArgument.java @@ -1,6 +1,8 @@ package de.dhbwstuttgart.strucTypes5.assumptions; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; + +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; /** * Created by sebastian on 20.04.17. * @@ -11,9 +13,9 @@ import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; public class AssumptionArgument extends AssumptionAbstract { private String nameOfArgument; - private TypeVarAbstract typeOfArgument; + private RefTypeOrTPHOrWildcardOrGeneric typeOfArgument; - public AssumptionArgument(String nameOfArgument, TypeVarAbstract typeOfArgument) { + public AssumptionArgument(String nameOfArgument, RefTypeOrTPHOrWildcardOrGeneric typeOfArgument) { this.nameOfArgument = nameOfArgument; this.typeOfArgument = typeOfArgument; } @@ -27,11 +29,11 @@ public class AssumptionArgument extends AssumptionAbstract { this.nameOfArgument = nameOfArgument; } - public TypeVarAbstract getTypeOfArgument() { + public RefTypeOrTPHOrWildcardOrGeneric getTypeOfArgument() { return typeOfArgument; } - public void setTypeOfArgument(TypeVarAbstract typeOfArgument) { + public void setTypeOfArgument(RefTypeOrTPHOrWildcardOrGeneric typeOfArgument) { this.typeOfArgument = typeOfArgument; } diff --git a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionClass.java b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionClass.java index fbabc0da..ab94a617 100644 --- a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionClass.java +++ b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionClass.java @@ -4,9 +4,10 @@ package de.dhbwstuttgart.strucTypes5.assumptions; import de.dhbwstuttgart.strucTypes5.constraints.ConstraintAbstract; import de.dhbwstuttgart.strucTypes5.interfaceTemplates.Interface; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -21,13 +22,13 @@ public class AssumptionClass extends AssumptionAbstract { private AssumptionMap assumptionMap; private List constraints; private List generatedinterfaces; - private List genericsForClass; + private List genericsForClass; public AssumptionClass() { } - public AssumptionClass(ClassOrInterface cl, TypeVarStore typeVarStore, AssumptionMap assumptionMap, List constraints, List generatedinterfaces, List genericsForClass) { + public AssumptionClass(ClassOrInterface cl, TypeVarStore typeVarStore, AssumptionMap assumptionMap, List constraints, List generatedinterfaces, List genericsForClass) { this.cl = cl; this.typeVarStore = typeVarStore; this.assumptionMap = assumptionMap; @@ -77,11 +78,11 @@ public class AssumptionClass extends AssumptionAbstract { this.generatedinterfaces = generatedinterfaces; } - public List getGenericsForClass() { + public List getGenericsForClass() { return genericsForClass; } - public void setGenericsForClass(List genericsForClass) { + public void setGenericsForClass(List genericsForClass) { this.genericsForClass = genericsForClass; } diff --git a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionFactory.java b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionFactory.java index accb21bc..3f173915 100644 --- a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionFactory.java +++ b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionFactory.java @@ -1,12 +1,13 @@ package de.dhbwstuttgart.strucTypes5.assumptions; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarFactory; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore; import de.dhbwstuttgart.syntaxtree.Field; import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.Method; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.ArrayList; import java.util.List; @@ -56,7 +57,7 @@ public class AssumptionFactory { public static AssumptionArgument makeArgumentAssumption(FormalParameter formalParameter , TypeVarStore typeVarStore) { - TypeVarAbstract typeVar = typeVarStore.storeTPH(formalParameter.getType()); + RefTypeOrTPHOrWildcardOrGeneric typeVar = typeVarStore.storeTPH(formalParameter.getType()); return new AssumptionArgument(formalParameter.getName(), typeVar); } diff --git a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionMap.java b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionMap.java index 9d68a9f1..0200e6cb 100644 --- a/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionMap.java +++ b/src/de/dhbwstuttgart/strucTypes5/assumptions/AssumptionMap.java @@ -1,7 +1,8 @@ package de.dhbwstuttgart.strucTypes5.assumptions; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.HashMap; import java.util.List; @@ -55,7 +56,7 @@ public class AssumptionMap { } - public TypeVarAbstract getVarAssumption(String name) { + public RefTypeOrTPHOrWildcardOrGeneric getVarAssumption(String name) { // gibt lokale Var zurück. wenn nicht vorhanden gloable. wenn nicht vorhanden null if (argAss.containsKey(name)) { @@ -77,7 +78,7 @@ public class AssumptionMap { return true; } - public TypeVarAbstract getThisVar(String name) { + public RefTypeOrTPHOrWildcardOrGeneric getThisVar(String name) { return fass.get(name).getTypeVar(); } diff --git a/src/de/dhbwstuttgart/strucTypes5/assumptions/ChangeTypeVars.java b/src/de/dhbwstuttgart/strucTypes5/assumptions/ChangeTypeVars.java index 7dc39672..8fad0135 100644 --- a/src/de/dhbwstuttgart/strucTypes5/assumptions/ChangeTypeVars.java +++ b/src/de/dhbwstuttgart/strucTypes5/assumptions/ChangeTypeVars.java @@ -6,7 +6,8 @@ import de.dhbwstuttgart.strucTypes5.constraints.ConstraintSubType; import de.dhbwstuttgart.strucTypes5.typeVars.MappingAltNeu; import de.dhbwstuttgart.strucTypes5.typeVars.ResultTuple; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.ArrayList; import java.util.List; @@ -38,11 +39,11 @@ public class ChangeTypeVars { if (c instanceof ConstraintSubType) { ConstraintSubType csub = (ConstraintSubType) c; - TypeVarAbstract tsub = csub.getSubtype(); - TypeVarAbstract tsuper = csub.getSuperType(); + RefTypeOrTPHOrWildcardOrGeneric tsub = csub.getSubtype(); + RefTypeOrTPHOrWildcardOrGeneric tsuper = csub.getSuperType(); - TypeVarAbstract newTSub = mappingAltNeu.getNeu(tsub); - TypeVarAbstract newTsuper = mappingAltNeu.getNeu(tsuper); + RefTypeOrTPHOrWildcardOrGeneric newTSub = mappingAltNeu.getNeu(tsub); + RefTypeOrTPHOrWildcardOrGeneric newTsuper = mappingAltNeu.getNeu(tsuper); ConstraintSubType newC = new ConstraintSubType(newTSub , newTsuper); newConstraints.add(newC); @@ -59,8 +60,8 @@ public class ChangeTypeVars { // Tausche Generics aus - List genericsneu = new ArrayList<>(); - for (TypeVarAbstract tv : oldAssClass.getGenericsForClass()) { + List genericsneu = new ArrayList<>(); + for (RefTypeOrTPHOrWildcardOrGeneric tv : oldAssClass.getGenericsForClass()) { if (tv instanceof TypeVar) { TypeVar genericNeu = (TypeVar) mappingAltNeu.getNeu(tv); genericsneu.add(genericNeu); diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintAbstract.java b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintAbstract.java index 75bbc9d3..04b9b623 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintAbstract.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintAbstract.java @@ -1,20 +1,21 @@ package de.dhbwstuttgart.strucTypes5.constraints; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarInterface; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 20.04.17. */ public abstract class ConstraintAbstract { - public boolean replaceTypeVarAbstract(TypeVarAbstract alt, TypeVarAbstract neu) { + public boolean replaceTypeVarAbstract(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) { return false; } - public static TypeVarAbstract helpChange(TypeVarAbstract old, TypeVarAbstract neu, TypeVarAbstract inFrage) { + public static RefTypeOrTPHOrWildcardOrGeneric helpChange(RefTypeOrTPHOrWildcardOrGeneric old, RefTypeOrTPHOrWildcardOrGeneric neu, RefTypeOrTPHOrWildcardOrGeneric inFrage) { if (inFrage instanceof TypeVarInterface) { ((TypeVarInterface) inFrage).getInterfaceForConstraint().replaceTypeVarAbstract(old,neu); return inFrage; @@ -25,7 +26,7 @@ public abstract class ConstraintAbstract { } - public static boolean helpChange2(TypeVarAbstract old, TypeVarAbstract neu, TypeVarAbstract inFrage) { + public static boolean helpChange2(RefTypeOrTPHOrWildcardOrGeneric old, RefTypeOrTPHOrWildcardOrGeneric neu, RefTypeOrTPHOrWildcardOrGeneric inFrage) { if (inFrage instanceof TypeVarInterface) { ConstraintAbstract.helpChange(old,neu,inFrage); return true; diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintInterface.java b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintInterface.java index 8c65ed51..cc96ea51 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintInterface.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintInterface.java @@ -1,34 +1,35 @@ package de.dhbwstuttgart.strucTypes5.constraints; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 02.05.17. */ public class ConstraintInterface extends ConstraintAbstract { - private TypeVarAbstract SubType; - private TypeVarAbstract SuperType; + private RefTypeOrTPHOrWildcardOrGeneric SubType; + private RefTypeOrTPHOrWildcardOrGeneric SuperType; - public ConstraintInterface(TypeVarAbstract subType, TypeVarAbstract superType) { + public ConstraintInterface(RefTypeOrTPHOrWildcardOrGeneric subType, RefTypeOrTPHOrWildcardOrGeneric superType) { SubType = subType; SuperType = superType; } - public TypeVarAbstract getSubType() { + public RefTypeOrTPHOrWildcardOrGeneric getSubType() { return SubType; } - public void setSubType(TypeVarAbstract subType) { + public void setSubType(RefTypeOrTPHOrWildcardOrGeneric subType) { SubType = subType; } - public TypeVarAbstract getSuperType() { + public RefTypeOrTPHOrWildcardOrGeneric getSuperType() { return SuperType; } - public void setSuperType(TypeVarAbstract superType) { + public void setSuperType(RefTypeOrTPHOrWildcardOrGeneric superType) { SuperType = superType; } diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintShouldEqual.java b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintShouldEqual.java index 9b1128f1..458ee8b6 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintShouldEqual.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintShouldEqual.java @@ -1,24 +1,25 @@ package de.dhbwstuttgart.strucTypes5.constraints; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 01.05.17. */ public class ConstraintShouldEqual extends ConstraintAbstract{ - private TypeVarAbstract t1; - private TypeVarAbstract t2; + private RefTypeOrTPHOrWildcardOrGeneric t1; + private RefTypeOrTPHOrWildcardOrGeneric t2; - public ConstraintShouldEqual(TypeVarAbstract t1, TypeVarAbstract t2) { + public ConstraintShouldEqual(RefTypeOrTPHOrWildcardOrGeneric t1, RefTypeOrTPHOrWildcardOrGeneric t2) { this.t1 = t1; this.t2 = t2; } @Override - public boolean replaceTypeVarAbstract(TypeVarAbstract alt, TypeVarAbstract neu) { + public boolean replaceTypeVarAbstract(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) { if (t1.equals(alt)) { t1 = ConstraintAbstract.helpChange(alt,neu,t1); } @@ -30,19 +31,19 @@ public class ConstraintShouldEqual extends ConstraintAbstract{ return true; } - public TypeVarAbstract getT1() { + public RefTypeOrTPHOrWildcardOrGeneric getT1() { return t1; } - public void setT1(TypeVarAbstract t1) { + public void setT1(RefTypeOrTPHOrWildcardOrGeneric t1) { this.t1 = t1; } - public TypeVarAbstract getT2() { + public RefTypeOrTPHOrWildcardOrGeneric getT2() { return t2; } - public void setT2(TypeVarAbstract t2) { + public void setT2(RefTypeOrTPHOrWildcardOrGeneric t2) { this.t2 = t2; } diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubType.java b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubType.java index 88231204..b6a84a50 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubType.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubType.java @@ -2,7 +2,8 @@ package de.dhbwstuttgart.strucTypes5.constraints; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 20.04.17. @@ -13,17 +14,17 @@ public class ConstraintSubType extends ConstraintAbstract{ // TODO Hier muss ich mir das noch überlegen wie es geht. Evtl ist eine TypeVarType nicht notwenidg // Eine Typvariable kann TypVar sein, ein Typ kann auch eine TypVar sein , ein Interface kann was sein ? - private TypeVarAbstract subtype; - private TypeVarAbstract superType; + private RefTypeOrTPHOrWildcardOrGeneric subtype; + private RefTypeOrTPHOrWildcardOrGeneric superType; - public ConstraintSubType(TypeVarAbstract subtype, TypeVarAbstract superType) { + public ConstraintSubType(RefTypeOrTPHOrWildcardOrGeneric subtype, RefTypeOrTPHOrWildcardOrGeneric superType) { this.subtype = subtype; this.superType = superType; } @Override - public boolean replaceTypeVarAbstract(TypeVarAbstract alt, TypeVarAbstract neu) { + public boolean replaceTypeVarAbstract(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) { if (subtype.equals(alt)) { subtype = ConstraintAbstract.helpChange(alt,neu,subtype); } @@ -36,19 +37,19 @@ public class ConstraintSubType extends ConstraintAbstract{ } - public TypeVarAbstract getSubtype() { + public RefTypeOrTPHOrWildcardOrGeneric getSubtype() { return subtype; } - public void setSubtype(TypeVarAbstract subtype) { + public void setSubtype(RefTypeOrTPHOrWildcardOrGeneric subtype) { this.subtype = subtype; } - public TypeVarAbstract getSuperType() { + public RefTypeOrTPHOrWildcardOrGeneric getSuperType() { return superType; } - public void setSuperType(TypeVarAbstract superType) { + public void setSuperType(RefTypeOrTPHOrWildcardOrGeneric superType) { this.superType = superType; } diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubstitution.java b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubstitution.java index 88b414dc..42d4e83a 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubstitution.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubstitution.java @@ -1,33 +1,34 @@ package de.dhbwstuttgart.strucTypes5.constraints; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 01.05.17. */ public class ConstraintSubstitution extends ConstraintAbstract { - private TypeVarAbstract t1; - private TypeVarAbstract t2; + private RefTypeOrTPHOrWildcardOrGeneric t1; + private RefTypeOrTPHOrWildcardOrGeneric t2; - public ConstraintSubstitution(TypeVarAbstract t1, TypeVarAbstract t2) { + public ConstraintSubstitution(RefTypeOrTPHOrWildcardOrGeneric t1, RefTypeOrTPHOrWildcardOrGeneric t2) { this.t1 = t1; this.t2 = t2; } - public TypeVarAbstract getT1() { + public RefTypeOrTPHOrWildcardOrGeneric getT1() { return t1; } - public void setT1(TypeVarAbstract t1) { + public void setT1(RefTypeOrTPHOrWildcardOrGeneric t1) { this.t1 = t1; } - public TypeVarAbstract getT2() { + public RefTypeOrTPHOrWildcardOrGeneric getT2() { return t2; } - public void setT2(TypeVarAbstract t2) { + public void setT2(RefTypeOrTPHOrWildcardOrGeneric t2) { this.t2 = t2; } diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java b/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java index 53148ed8..56e6385b 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java @@ -1,7 +1,8 @@ package de.dhbwstuttgart.strucTypes5.constraints; import de.dhbwstuttgart.strucTypes5.algo.Type; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.ArrayList; import java.util.List; @@ -11,21 +12,21 @@ import java.util.List; */ public class InterfaceForConstraint { - private TypeVarAbstract strucType; - private List generics; + private RefTypeOrTPHOrWildcardOrGeneric strucType; + private List generics; - public InterfaceForConstraint(TypeVarAbstract strucType, List generics) { + public InterfaceForConstraint(RefTypeOrTPHOrWildcardOrGeneric strucType, List generics) { this.strucType = strucType; this.generics = generics; } - public boolean replaceTypeVarAbstract(TypeVarAbstract alt, TypeVarAbstract neu) { + public boolean replaceTypeVarAbstract(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) { - List genericsneu = new ArrayList<>(); + List genericsneu = new ArrayList<>(); - for (TypeVarAbstract tv : generics) { + for (RefTypeOrTPHOrWildcardOrGeneric tv : generics) { if (tv.equals(alt)) { genericsneu.add(neu); } @@ -40,19 +41,19 @@ public class InterfaceForConstraint { - public TypeVarAbstract getStrucType() { + public RefTypeOrTPHOrWildcardOrGeneric getStrucType() { return strucType; } - public void setStrucType(TypeVarAbstract strucType) { + public void setStrucType(RefTypeOrTPHOrWildcardOrGeneric strucType) { this.strucType = strucType; } - public List getGenerics() { + public List getGenerics() { return generics; } - public void setGenerics(List generics) { + public void setGenerics(List generics) { this.generics = generics; } diff --git a/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/FieldInterface.java b/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/FieldInterface.java index 2348893b..b3358190 100644 --- a/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/FieldInterface.java +++ b/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/FieldInterface.java @@ -1,26 +1,27 @@ package de.dhbwstuttgart.strucTypes5.interfaceTemplates; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 09.04.17. */ public class FieldInterface { - TypeVarAbstract type; + RefTypeOrTPHOrWildcardOrGeneric type; String name; - public FieldInterface(TypeVarAbstract type, String name) { + public FieldInterface(RefTypeOrTPHOrWildcardOrGeneric type, String name) { this.type = type; this.name = name; } - public TypeVarAbstract getType() { + public RefTypeOrTPHOrWildcardOrGeneric getType() { return type; } - public void setType(TypeVarAbstract type) { + public void setType(RefTypeOrTPHOrWildcardOrGeneric type) { this.type = type; } diff --git a/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/Interface.java b/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/Interface.java index d5487de2..03fcd867 100644 --- a/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/Interface.java +++ b/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/Interface.java @@ -3,7 +3,8 @@ package de.dhbwstuttgart.strucTypes5.interfaceTemplates; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -13,13 +14,13 @@ import java.util.List; */ public class Interface { - TypeVarAbstract strucType; + RefTypeOrTPHOrWildcardOrGeneric strucType; List fields; List methods; - List generics; + List generics; - public Interface(TypeVarAbstract strucType, List fields, List methods, List generics) { + public Interface(RefTypeOrTPHOrWildcardOrGeneric strucType, List fields, List methods, List generics) { this.strucType = strucType; this.fields = fields; this.methods = methods; @@ -42,11 +43,11 @@ public class Interface { this.methods = methods; } - public List getGenerics() { + public List getGenerics() { return generics; } - public void setGenerics(List generics) { + public void setGenerics(List generics) { this.generics = generics; } diff --git a/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/MethodInterface.java b/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/MethodInterface.java index e0b6d7b7..1755de3f 100644 --- a/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/MethodInterface.java +++ b/src/de/dhbwstuttgart/strucTypes5/interfaceTemplates/MethodInterface.java @@ -2,7 +2,8 @@ package de.dhbwstuttgart.strucTypes5.interfaceTemplates; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.List; @@ -12,11 +13,11 @@ import java.util.List; public class MethodInterface { String name; - TypeVarAbstract rtType; - List argsTypes; + RefTypeOrTPHOrWildcardOrGeneric rtType; + List argsTypes; - public MethodInterface(String name, TypeVarAbstract rtType, List argsTypes) { + public MethodInterface(String name, RefTypeOrTPHOrWildcardOrGeneric rtType, List argsTypes) { this.name = name; this.rtType = rtType; this.argsTypes = argsTypes; @@ -31,19 +32,19 @@ public class MethodInterface { this.name = name; } - public TypeVarAbstract getRtType() { + public RefTypeOrTPHOrWildcardOrGeneric getRtType() { return rtType; } - public void setRtType(TypeVarAbstract rtType) { + public void setRtType(RefTypeOrTPHOrWildcardOrGeneric rtType) { this.rtType = rtType; } - public List getArgsTypes() { + public List getArgsTypes() { return argsTypes; } - public void setArgsTypes(List argsTypes) { + public void setArgsTypes(List argsTypes) { this.argsTypes = argsTypes; } diff --git a/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java b/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java index 9c28eb68..d51806c2 100644 --- a/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java +++ b/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java @@ -5,9 +5,10 @@ package de.dhbwstuttgart.strucTypes5.solve; import de.dhbwstuttgart.strucTypes5.algo.Type; import de.dhbwstuttgart.strucTypes5.constraints.*; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVar; -import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; +//import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarInterface; import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarRefType; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.typeinference.constraints.Constraint; @@ -78,8 +79,8 @@ public class Rules { for (ConstraintAbstract cs : constraints) { if (cs instanceof ConstraintShouldEqual) { ConstraintShouldEqual csse = (ConstraintShouldEqual) cs; - TypeVarAbstract theta = csse.getT1(); - TypeVarAbstract typeVar = csse.getT2(); + RefTypeOrTPHOrWildcardOrGeneric theta = csse.getT1(); + RefTypeOrTPHOrWildcardOrGeneric typeVar = csse.getT2(); if (theta instanceof TypeVarRefType && typeVar instanceof TypeVar) { csse.setT1(typeVar); csse.setT2(theta); @@ -100,8 +101,8 @@ public class Rules { public void subst(List constraints) { for (ConstraintAbstract cs : constraints) { if (cs instanceof ConstraintShouldEqual) { - TypeVarAbstract t1 = ((ConstraintShouldEqual) cs).getT1(); - TypeVarAbstract t2 = ((ConstraintShouldEqual) cs).getT2(); + RefTypeOrTPHOrWildcardOrGeneric t1 = ((ConstraintShouldEqual) cs).getT1(); + RefTypeOrTPHOrWildcardOrGeneric t2 = ((ConstraintShouldEqual) cs).getT2(); if (t1 instanceof TypeVar) { if (t2 instanceof TypeVarRefType || t2 instanceof TypeVarInterface) { @@ -132,7 +133,7 @@ public class Rules { - public void replaceAll(List constraints , TypeVarAbstract alt , TypeVarAbstract neu ) { + public void replaceAll(List constraints , RefTypeOrTPHOrWildcardOrGeneric alt , RefTypeOrTPHOrWildcardOrGeneric neu ) { System.out.println(String.format("Replace All: %s -> %s" , alt , neu )); for (ConstraintAbstract cs : constraints) { @@ -243,10 +244,10 @@ public class Rules { ConstraintSubType css = (ConstraintSubType) cs; if (css.getSubtype() instanceof TypeVarRefType && css.getSuperType() instanceof TypeVar) { - List reflect = reflectNext(constraints, css.getSubtype(), (TypeVar) css.getSuperType()); + List reflect = reflectNext(constraints, css.getSubtype(), (TypeVar) css.getSuperType()); if (reflect != null) { System.out.println("Reflect für " + reflect + css.getSubtype()); - for (TypeVarAbstract tv : reflect) { + for (RefTypeOrTPHOrWildcardOrGeneric tv : reflect) { substitutions.add(new ConstraintSubstitution(tv , css.getSubtype())); // Todo Unsauber wg constraints.remove(cs); @@ -259,20 +260,20 @@ public class Rules { } } - public List reflectNext(List constraints , TypeVarAbstract startValue ,TypeVar nextPoint) { + public List reflectNext(List constraints , RefTypeOrTPHOrWildcardOrGeneric startValue ,TypeVar nextPoint) { ConstraintSubType next = next(nextPoint,constraints); if (next != null) { if (next.getSuperType().equals(startValue)) { - List result = new ArrayList<>(); + List result = new ArrayList<>(); result.add(next.getSubtype()); constraints.remove(next); // ?? Sauber? return result; } else if (next.getSuperType() instanceof TypeVar ) { - List result = reflectNext(constraints,startValue,(TypeVar) next.getSuperType()); + List result = reflectNext(constraints,startValue,(TypeVar) next.getSuperType()); if (result != null) { result.add(next.getSubtype()); constraints.remove(next); // ? Sauber @@ -321,8 +322,8 @@ public class Rules { // Erstelle neue Constraints for (int i = 0 ; i < if1.getGenerics().size() ; i++) { - TypeVarAbstract tnX = if1.getGenerics().get(i); - TypeVarAbstract tnY = if2.getGenerics().get(i); + RefTypeOrTPHOrWildcardOrGeneric tnX = if1.getGenerics().get(i); + RefTypeOrTPHOrWildcardOrGeneric tnY = if2.getGenerics().get(i); // Ergebnis an ConstraintList constraints.add(new ConstraintShouldEqual(tnX,tnY)); @@ -358,7 +359,7 @@ public class Rules { } - private ConstraintInterface sucheInterface( TypeVarAbstract tvSub , TypeVarAbstract tvSuper ) { + private ConstraintInterface sucheInterface( RefTypeOrTPHOrWildcardOrGeneric tvSub , RefTypeOrTPHOrWildcardOrGeneric tvSuper ) { for (ConstraintInterface cs : constraintInterfaces) { if ( cs.getSubType().equalsForUnify(tvSub) && cs.getSuperType().equalsForUnify(tvSuper) ) { @@ -408,7 +409,7 @@ public class Rules { } - public List adapt2Next(TypeVarAbstract start , TypeVarAbstract last , List constraints, List newConstraints) { + public List adapt2Next(RefTypeOrTPHOrWildcardOrGeneric start , RefTypeOrTPHOrWildcardOrGeneric last , List constraints, List newConstraints) { for (ConstraintAbstract cs : constraints) { @@ -433,8 +434,8 @@ public class Rules { TypeVarInterface iFGiven = (TypeVarInterface) constraintInterface.getSuperType(); TypeVarInterface iFthis = (TypeVarInterface) css.getSuperType(); - List iFGivenGenerics = iFGiven.getInterfaceForConstraint().getGenerics(); - List iFthisGenerics = iFthis.getInterfaceForConstraint().getGenerics(); + List iFGivenGenerics = iFGiven.getInterfaceForConstraint().getGenerics(); + List iFthisGenerics = iFthis.getInterfaceForConstraint().getGenerics(); if (iFGivenGenerics.size() == iFthisGenerics.size()) { for (int i = 0 ; i < iFGivenGenerics.size() ; i++ ) { diff --git a/src/de/dhbwstuttgart/strucTypes5/typeVars/MappingAltNeu.java b/src/de/dhbwstuttgart/strucTypes5/typeVars/MappingAltNeu.java index c9508908..ce4d34c7 100644 --- a/src/de/dhbwstuttgart/strucTypes5/typeVars/MappingAltNeu.java +++ b/src/de/dhbwstuttgart/strucTypes5/typeVars/MappingAltNeu.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.strucTypes5.typeVars; import de.dhbwstuttgart.strucTypes5.constraints.InterfaceForConstraint; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import java.util.ArrayList; import java.util.List; @@ -12,10 +13,10 @@ import java.util.List; public class MappingAltNeu { - List altList = new ArrayList<>(); - List neuList = new ArrayList<>(); + List altList = new ArrayList<>(); + List neuList = new ArrayList<>(); - public void addTypeVar(TypeVarAbstract alt, TypeVarAbstract neu) { + public void addTypeVar(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) { altList.add(alt); // Versuch bereits bekannte Typen mitzunehmen @@ -28,7 +29,7 @@ public class MappingAltNeu { } } - public TypeVarAbstract getNeu (TypeVarAbstract altTypeVar) { + public RefTypeOrTPHOrWildcardOrGeneric getNeu (RefTypeOrTPHOrWildcardOrGeneric altTypeVar) { // Wenn der Typ bereits bekannt ist gebe ihn zurück if (altTypeVar instanceof TypeVarRefType) { @@ -36,10 +37,10 @@ public class MappingAltNeu { } else if (altTypeVar instanceof TypeVarInterface) { TypeVarInterface strucType = (TypeVarInterface) altTypeVar; - TypeVarAbstract name = strucType.getInterfaceForConstraint().getStrucType(); - List neueGenerics = new ArrayList<>(); - List alteGenerics = strucType.getInterfaceForConstraint().getGenerics(); - for (TypeVarAbstract tv : alteGenerics) { + RefTypeOrTPHOrWildcardOrGeneric name = strucType.getInterfaceForConstraint().getStrucType(); + List neueGenerics = new ArrayList<>(); + List alteGenerics = strucType.getInterfaceForConstraint().getGenerics(); + for (RefTypeOrTPHOrWildcardOrGeneric tv : alteGenerics) { neueGenerics.add(this.getNeu(tv)); } diff --git a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVar.java b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVar.java index 2757ca54..f939dfc6 100644 --- a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVar.java +++ b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVar.java @@ -1,13 +1,18 @@ package de.dhbwstuttgart.strucTypes5.typeVars; +import org.antlr.v4.runtime.Token; + +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; + /** * Created by sebastian on 14.04.17. */ -public class TypeVar extends TypeVarAbstract { +public class TypeVar extends RefTypeOrTPHOrWildcardOrGeneric { private String id; public TypeVar(String id) { + super(); this.id = id; } diff --git a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarInterface.java b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarInterface.java index db282514..6f46a3e3 100644 --- a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarInterface.java +++ b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarInterface.java @@ -1,11 +1,12 @@ package de.dhbwstuttgart.strucTypes5.typeVars; import de.dhbwstuttgart.strucTypes5.constraints.InterfaceForConstraint; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 30.04.17. */ -public class TypeVarInterface extends TypeVarAbstract { +public class TypeVarInterface extends RefTypeOrTPHOrWildcardOrGeneric { private InterfaceForConstraint interfaceForConstraint; @@ -40,7 +41,7 @@ public class TypeVarInterface extends TypeVarAbstract { // Equal_for_Unify - public boolean equalsForUnify(TypeVarAbstract tv) { + public boolean equalsForUnify(RefTypeOrTPHOrWildcardOrGeneric tv) { if (tv instanceof TypeVarInterface) { String name = ((TypeVarInterface) tv).getInterfaceForConstraint().getStrucType().toString(); diff --git a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarRefType.java b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarRefType.java index b23e6db1..9c33780e 100644 --- a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarRefType.java +++ b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarRefType.java @@ -1,11 +1,12 @@ package de.dhbwstuttgart.strucTypes5.typeVars; import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 30.04.17. */ -public class TypeVarRefType extends TypeVarAbstract { +public class TypeVarRefType extends RefTypeOrTPHOrWildcardOrGeneric { private RefType refType; diff --git a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarStore.java b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarStore.java index 514e78a8..2a9d0a1f 100644 --- a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarStore.java +++ b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarStore.java @@ -14,11 +14,11 @@ import java.util.List; public class TypeVarStore { - private HashMap> map = new HashMap<>(); + private HashMap> map = new HashMap<>(); - public TypeVarAbstract storeTPH(RefTypeOrTPHOrWildcardOrGeneric tph) { + public RefTypeOrTPHOrWildcardOrGeneric storeTPH(RefTypeOrTPHOrWildcardOrGeneric tph) { if (getTypeVarByTPH(tph) == null) { TypeVar tvNeu = TypeVarFactory.makeTypeVar(); @@ -41,7 +41,7 @@ public class TypeVarStore { - public void addTuple(TypeVarAbstract tv, RefTypeOrTPHOrWildcardOrGeneric tph) { + public void addTuple(RefTypeOrTPHOrWildcardOrGeneric tv, RefTypeOrTPHOrWildcardOrGeneric tph) { // TypVar bereits vorhandne @@ -66,13 +66,13 @@ public class TypeVarStore { } - public List getTPHByTypeVar(TypeVarAbstract tv) { + public List getTPHByTypeVar(RefTypeOrTPHOrWildcardOrGeneric tv) { return map.get(tv); } - public TypeVarAbstract getTypeVarByTPH(RefTypeOrTPHOrWildcardOrGeneric tph) { + public RefTypeOrTPHOrWildcardOrGeneric getTypeVarByTPH(RefTypeOrTPHOrWildcardOrGeneric tph) { // TPH ist bereits einer TypVar zugeordnet - for (TypeVarAbstract typeVar : map.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric typeVar : map.keySet()) { if (map.get(typeVar).contains(tph)) { return typeVar; } @@ -88,7 +88,7 @@ public class TypeVarStore { public TypeVarStore freshVariables() { TypeVarStore typeVarStore = new TypeVarStore(); - for (TypeVarAbstract tvarOld : map.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric tvarOld : map.keySet()) { TypeVar tvNew = TypeVarFactory.makeTypeVar(); typeVarStore.map.put(tvNew,map.get(tvarOld)); } @@ -103,11 +103,11 @@ public class TypeVarStore { TypeVarStore typeVarStore = new TypeVarStore(); - for (TypeVarAbstract tvarOld : map.keySet()) { + for (RefTypeOrTPHOrWildcardOrGeneric tvarOld : map.keySet()) { // Wenn der Typ bereits bekannt ist, wird dieser nicht ersetzt. if (tvarOld instanceof TypeVarType) { - TypeVarAbstract tvNew = tvarOld; + RefTypeOrTPHOrWildcardOrGeneric tvNew = tvarOld; typeVarStore.map.put(tvNew,map.get(tvarOld)); mappingAltNeu.addTypeVar(tvarOld,tvNew); } @@ -123,7 +123,7 @@ public class TypeVarStore { - public boolean replaceTypeVar(TypeVarAbstract old, TypeVarAbstract neu) { + public boolean replaceTypeVar(RefTypeOrTPHOrWildcardOrGeneric old, RefTypeOrTPHOrWildcardOrGeneric neu) { if (map.containsKey(old)) { List tphList = map.get(old); @@ -137,7 +137,7 @@ public class TypeVarStore { } - public TypeVarAbstract isType(TypeVar testVar) { + public RefTypeOrTPHOrWildcardOrGeneric isType(TypeVar testVar) { List tphList = map.get(testVar); if (tphList == null) { @@ -160,7 +160,7 @@ public class TypeVarStore { @Override public String toString() { String res = "--- TypeVarStore ---\n"; - for (TypeVarAbstract tvar : map.keySet() ) { + for (RefTypeOrTPHOrWildcardOrGeneric tvar : map.keySet() ) { res = res + tvar.toString() + " : " + map.get(tvar).toString() + "\n"; } return String.format(res); diff --git a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarType.java b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarType.java index 32293331..07aecf81 100644 --- a/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarType.java +++ b/src/de/dhbwstuttgart/strucTypes5/typeVars/TypeVarType.java @@ -2,11 +2,12 @@ package de.dhbwstuttgart.strucTypes5.typeVars; import de.dhbwstuttgart.strucTypes4.syntaxtree.Class; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; /** * Created by sebastian on 14.04.17. */ -public class TypeVarType extends TypeVarAbstract { +public class TypeVarType extends RefTypeOrTPHOrWildcardOrGeneric { private Class typeClass; diff --git a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java index 58155562..5493406f 100644 --- a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java +++ b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java @@ -11,6 +11,10 @@ import org.antlr.v4.runtime.misc.Pair; public abstract class SyntaxTreeNode implements IItemWithOffset{ private final Token offset; + public SyntaxTreeNode() { + super(); + offset = null; + } public SyntaxTreeNode(Token offset){ this.offset = offset; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java b/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java index 79813f56..afb46568 100644 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java @@ -4,6 +4,9 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import org.antlr.v4.runtime.Token; public class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{ + public RefTypeOrTPHOrWildcardOrGeneric(){ + super(); + } public RefTypeOrTPHOrWildcardOrGeneric(Token offset) { super(offset); } diff --git a/test/strucTypes5/SolveTest.java b/test/strucTypes5/SolveTest.java index 72bf8902..d6de3508 100644 --- a/test/strucTypes5/SolveTest.java +++ b/test/strucTypes5/SolveTest.java @@ -64,14 +64,14 @@ public class SolveTest { // Generate Interfaces Give TypeVarRefType myInteger = (TypeVarRefType) getTypeVar(ti1.resultConstraints , "TVar_MyInteger"); - TypeVarAbstract v2 = getTypeVar(ti1.resultConstraints , "TVar_2"); - TypeVarAbstract v5 = getTypeVar(ti1.resultConstraints , "TVar_5"); + RefTypeOrTPHOrWildcardOrGeneric v2 = getTypeVar(ti1.resultConstraints , "TVar_2"); + RefTypeOrTPHOrWildcardOrGeneric v5 = getTypeVar(ti1.resultConstraints , "TVar_5"); System.out.println(myInteger.toString()); System.out.println(v2.toString()); System.out.println(v5.toString()); // Generiere Interface 1 - List generics = new ArrayList<>(); + List generics = new ArrayList<>(); generics.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); generics.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); InterfaceForConstraint if1 = new InterfaceForConstraint(v2, generics); @@ -81,7 +81,7 @@ public class SolveTest { // Generiere Interface 2 - List generics2 = new ArrayList<>(); + List generics2 = new ArrayList<>(); generics2.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); generics2.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); InterfaceForConstraint if2 = new InterfaceForConstraint(v5, generics); @@ -147,7 +147,7 @@ public class SolveTest { assertTrue("Tests durchlaufen", filenames.size() > 0); } - private TypeVarAbstract getTypeVar(List constraints , String name) { + private RefTypeOrTPHOrWildcardOrGeneric getTypeVar(List constraints , String name) { for (ConstraintAbstract cs : constraints) { if (cs instanceof ConstraintSubType) { ConstraintSubType css = (ConstraintSubType) cs; diff --git a/test/strucTypes5/SolveTestMyList.java b/test/strucTypes5/SolveTestMyList.java index 88dce33a..02737481 100644 --- a/test/strucTypes5/SolveTestMyList.java +++ b/test/strucTypes5/SolveTestMyList.java @@ -66,15 +66,15 @@ public class SolveTestMyList { TypeVarRefType myInteger = (TypeVarRefType) getTypeVar(ti1.resultConstraints , "TVar_MyInteger"); TypeVarRefType myList = (TypeVarRefType) getTypeVar(ti1.resultConstraints , "TVar_MyList"); - TypeVarAbstract v2 = getTypeVar(ti1.resultConstraints , "TVar_2"); - TypeVarAbstract v5 = getTypeVar(ti1.resultConstraints , "TVar_5"); + RefTypeOrTPHOrWildcardOrGeneric v2 = getTypeVar(ti1.resultConstraints , "TVar_2"); + RefTypeOrTPHOrWildcardOrGeneric v5 = getTypeVar(ti1.resultConstraints , "TVar_5"); System.out.println(myInteger.toString()); System.out.println(myList.toString()); System.out.println(v2.toString()); // System.out.println(v5.toString()); // Generiere Interface 1 - List generics = new ArrayList<>(); + List generics = new ArrayList<>(); generics.add(TypeVarFactory.makeTypeVar(myList.getRefType())); generics.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); generics.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); @@ -85,7 +85,7 @@ public class SolveTestMyList { // Generiere Interface 2 - List generics2 = new ArrayList<>(); + List generics2 = new ArrayList<>(); generics2.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); generics2.add(TypeVarFactory.makeTypeVar(myInteger.getRefType())); InterfaceForConstraint if2 = new InterfaceForConstraint(v5, generics); @@ -127,7 +127,7 @@ public class SolveTestMyList { assertTrue("Tests durchlaufen", filenames.size() > 0); } - private TypeVarAbstract getTypeVar(List constraints , String name) { + private RefTypeOrTPHOrWildcardOrGeneric getTypeVar(List constraints , String name) { for (ConstraintAbstract cs : constraints) { if (cs instanceof ConstraintSubType) { ConstraintSubType css = (ConstraintSubType) cs; diff --git a/test/strucTypes5/SolveTest_Dev.java b/test/strucTypes5/SolveTest_Dev.java index f11bc688..dc0fdba9 100644 --- a/test/strucTypes5/SolveTest_Dev.java +++ b/test/strucTypes5/SolveTest_Dev.java @@ -183,7 +183,7 @@ public class SolveTest_Dev { TypeVar t1 = TypeVarFactory.makeTypeVar(); // Erstelle Interface 1 - List genericsA = new ArrayList<>(); + List genericsA = new ArrayList<>(); TypeVar t2 = TypeVarFactory.makeTypeVar(); TypeVar t3 = TypeVarFactory.makeTypeVar(); genericsA.add(t3); @@ -192,7 +192,7 @@ public class SolveTest_Dev { // Erstelle Interface 2 - List genericsB = new ArrayList<>(); + List genericsB = new ArrayList<>(); TypeVarRefType refType1 = TypeVarFactory.makeTypeVar(myInteger); TypeVarRefType refType2 = TypeVarFactory.makeTypeVar(myInteger); genericsB.add(refType1); @@ -216,10 +216,10 @@ public class SolveTest_Dev { System.out.println("Adapt1 Test"); // gemeinsamer Typ - TypeVarAbstract t1 = TypeVarFactory.makeTypeVar(); + RefTypeOrTPHOrWildcardOrGeneric t1 = TypeVarFactory.makeTypeVar(); // implements Interface myInteger implements Interface - List generics = new ArrayList<>(); + List generics = new ArrayList<>(); generics.add(TypeVarFactory.makeTypeVar(myInteger)); generics.add(TypeVarFactory.makeTypeVar(myInteger)); InterfaceForConstraint if1 = new InterfaceForConstraint(t1, generics); @@ -228,7 +228,7 @@ public class SolveTest_Dev { interfaces.add(constraintInterface); // Erstelle zu testenden Constraint - List genericsA = new ArrayList<>(); + List genericsA = new ArrayList<>(); TypeVar t2 = TypeVarFactory.makeTypeVar(); TypeVar t3 = TypeVarFactory.makeTypeVar(); genericsA.add(t3); @@ -262,16 +262,16 @@ public class SolveTest_Dev { System.out.println("Adapt2 Test"); // gemeinsamer Typ - TypeVarAbstract t1 = TypeVarFactory.makeTypeVar(); + RefTypeOrTPHOrWildcardOrGeneric t1 = TypeVarFactory.makeTypeVar(); // extend - TypeVarAbstract text1 = TypeVarFactory.makeTypeVar(); - TypeVarAbstract text2 = TypeVarFactory.makeTypeVar(); + RefTypeOrTPHOrWildcardOrGeneric text1 = TypeVarFactory.makeTypeVar(); + RefTypeOrTPHOrWildcardOrGeneric text2 = TypeVarFactory.makeTypeVar(); ConstraintSubType csub = new ConstraintSubType(text1,text2); // implements Interface myInteger implements Interface - List generics = new ArrayList<>(); + List generics = new ArrayList<>(); generics.add(TypeVarFactory.makeTypeVar(myInteger)); generics.add(TypeVarFactory.makeTypeVar(myInteger)); InterfaceForConstraint if1 = new InterfaceForConstraint(t1, generics); @@ -280,7 +280,7 @@ public class SolveTest_Dev { interfaces.add(constraintInterface); // Erstelle zu testenden Constraint - List genericsA = new ArrayList<>(); + List genericsA = new ArrayList<>(); TypeVar t2 = TypeVarFactory.makeTypeVar(); TypeVar t3 = TypeVarFactory.makeTypeVar(); genericsA.add(t3);