forked from JavaTX/JavaCompilerCore
AbstractTypVar durch RefTypeORTPHOrWildcardOrGeneric ersetzt
This commit is contained in:
parent
dfabf8ad71
commit
f48bb2ac0c
@ -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<String, TypeVarAbstract> assumptionsGlobal = new HashMap<>();
|
||||
Map<String, RefTypeOrTPHOrWildcardOrGeneric> assumptionsGlobal = new HashMap<>();
|
||||
List<Class> results = new ArrayList<>();
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> argsTypes;
|
||||
TypeVarAbstract returnType;
|
||||
List<TypeVarAbstract> argsBetaTypes;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> argsTypes;
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> argsBetaTypes;
|
||||
|
||||
public ConstraintMethod(TypeVarAbstract receiver, String methodName, List<TypeVarAbstract> argsTypes, TypeVarAbstract returnType, List<TypeVarAbstract> argsBetaTypes) {
|
||||
public ConstraintMethod(RefTypeOrTPHOrWildcardOrGeneric receiver, String methodName, List<RefTypeOrTPHOrWildcardOrGeneric> argsTypes, RefTypeOrTPHOrWildcardOrGeneric returnType, List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> getArgsTypes() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgsTypes() {
|
||||
return argsTypes;
|
||||
}
|
||||
|
||||
public void setArgsTypes(List<TypeVarAbstract> argsTypes) {
|
||||
public void setArgsTypes(List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> getArgsBetaTypes() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgsBetaTypes() {
|
||||
return argsBetaTypes;
|
||||
}
|
||||
|
||||
public void setArgsBetaTypes(List<TypeVarAbstract> argsBetaTypes) {
|
||||
public void setArgsBetaTypes(List<RefTypeOrTPHOrWildcardOrGeneric> argsBetaTypes) {
|
||||
this.argsBetaTypes = argsBetaTypes;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> generics;
|
||||
RefTypeOrTPHOrWildcardOrGeneric kleiner;
|
||||
RefTypeOrTPHOrWildcardOrGeneric strucType;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> generics;
|
||||
|
||||
public ConstraintSubTypeInterface(TypeVarAbstract kleiner, TypeVarAbstract strucType, List<TypeVarAbstract> generics) {
|
||||
public ConstraintSubTypeInterface(RefTypeOrTPHOrWildcardOrGeneric kleiner, RefTypeOrTPHOrWildcardOrGeneric strucType, List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.kleiner = kleiner;
|
||||
this.strucType = strucType;
|
||||
this.generics = generics;
|
||||
|
@ -25,7 +25,7 @@ public class Construct2 {
|
||||
List<Interface> interfaceList = new ArrayList<>();
|
||||
|
||||
// Sammeln der Constriants
|
||||
Map<TypeVarAbstract,List<ConstraintAbstract>> sortetConstr = sortiereConstraints(constraints);
|
||||
Map<RefTypeOrTPHOrWildcardOrGeneric,List<ConstraintAbstract>> 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<TypeVarAbstract,List<ConstraintAbstract>> sortiereConstraints(List<ConstraintAbstract> constraints) {
|
||||
private Map<RefTypeOrTPHOrWildcardOrGeneric,List<ConstraintAbstract>> sortiereConstraints(List<ConstraintAbstract> constraints) {
|
||||
|
||||
Map<TypeVarAbstract,List<ConstraintAbstract>> constraintMap = new ConcurrentHashMap<>();
|
||||
Map<RefTypeOrTPHOrWildcardOrGeneric,List<ConstraintAbstract>> 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<ConstraintAbstract> resultConstraints;
|
||||
|
||||
|
||||
public ConstructInterfaceForType2(List<ConstraintAbstract> constraints , TypeVarAbstract receiverAlt , TypeVarAbstract receiverNeu , MappingAltNeu altNeu) {
|
||||
public ConstructInterfaceForType2(List<ConstraintAbstract> constraints , RefTypeOrTPHOrWildcardOrGeneric receiverAlt , RefTypeOrTPHOrWildcardOrGeneric receiverNeu , MappingAltNeu altNeu) {
|
||||
|
||||
|
||||
resultConstraints = new ArrayList<>();
|
||||
|
||||
List<FieldInterface> fields = new ArrayList<>();
|
||||
List<MethodInterface> methods = new ArrayList<>();
|
||||
List<TypeVarAbstract> genericsInterface = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> neueArgsTV = new ArrayList<>();
|
||||
for (TypeVarAbstract tv : constraintMethod.getArgsTypes()) {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> neueArgsTV = new ArrayList<>();
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric tv : constraintMethod.getArgsTypes()) {
|
||||
neueArgsTV.add(TypeVarFactory.makeTypeVar());
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> altList = new ArrayList<>();
|
||||
List<TypeVarAbstract> neuList = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> altList = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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)) {
|
||||
|
@ -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<ConstraintAbstract> typeExpr(ExpressionAbstract exp, Map<String, TypeVarAbstract> ass , TypeVarAbstract rec , TypeVarAbstract returnType , TypeVarStore typeVarStore) {
|
||||
public static List<ConstraintAbstract> typeExpr(ExpressionAbstract exp, Map<String, RefTypeOrTPHOrWildcardOrGeneric> 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;
|
||||
}
|
||||
|
||||
|
@ -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<String,TypeVarAbstract> ass ) {
|
||||
public Class parseCode(String quellcode , Map<String,RefTypeOrTPHOrWildcardOrGeneric> 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<String,TypeVarAbstract> ass, Class aClass) {
|
||||
public TI (Map<String,RefTypeOrTPHOrWildcardOrGeneric> ass, Class aClass) {
|
||||
|
||||
Type type = new Type(ass,aClass);
|
||||
|
||||
@ -114,10 +114,10 @@ class Type {
|
||||
Class resultClassTyped;
|
||||
List<ConstraintAbstract> resultConstraintSet = new ArrayList<>();
|
||||
|
||||
public Type(Map<String,TypeVarAbstract> ass, Class aClass) {
|
||||
public Type(Map<String,RefTypeOrTPHOrWildcardOrGeneric> ass, Class aClass) {
|
||||
|
||||
// 1. Erstellen der Assumptions für die Klasse
|
||||
Map<String, TypeVarAbstract> fass_mass = aClass.makeAssumptions();
|
||||
Map<String, RefTypeOrTPHOrWildcardOrGeneric> 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<String,TypeVarAbstract> assMethod = method.makeAssumptions(aClass.typeVarStore);
|
||||
Map<String,RefTypeOrTPHOrWildcardOrGeneric> assMethod = method.makeAssumptions(aClass.typeVarStore);
|
||||
|
||||
assMethod.putAll(fass_mass);
|
||||
resultConstraintSet.addAll(method.typeExpr(assMethod , aClass.typeVarStore));
|
||||
|
@ -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<String,TypeVarAbstract> makeAssumptions() {
|
||||
public Map<String,RefTypeOrTPHOrWildcardOrGeneric> makeAssumptions() {
|
||||
|
||||
// Name bei Feldern feld, name bei methoden methode()
|
||||
Map<String, TypeVarAbstract> ass = new HashMap<>();
|
||||
Map<String, RefTypeOrTPHOrWildcardOrGeneric> 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;
|
||||
|
@ -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<ConstraintAbstract> typeExpr (Map<String, TypeVarAbstract> ass , TypeVarAbstract receiver , TypeVarAbstract returnType, TypeVarStore typeVarStore) {
|
||||
public List<ConstraintAbstract> typeExpr (Map<String, RefTypeOrTPHOrWildcardOrGeneric> ass , RefTypeOrTPHOrWildcardOrGeneric receiver , RefTypeOrTPHOrWildcardOrGeneric returnType, TypeVarStore typeVarStore) {
|
||||
List<ConstraintAbstract> constraints = new ArrayList<>();
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ public class ExprMCall extends ExpressionAbstract {
|
||||
|
||||
List<Argument> arguments = m.getArgs();
|
||||
|
||||
List<TypeVarAbstract> typeVars = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> types = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> types = new ArrayList<>();
|
||||
args.forEach(x -> types.add(typeVarStore.getTypeVarByTPH(x.getTypePlaceHolder())));
|
||||
|
||||
// Neue Liste mit neuen Beta - Argumenten erstellen
|
||||
List<TypeVarAbstract> betaTypes = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> betaTypes = new ArrayList<>();
|
||||
args.forEach(x -> betaTypes.add( typeVarStore.makeFreshTypeVar() ));
|
||||
|
||||
|
||||
|
@ -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<ConstraintAbstract> typeExpr(Map<String, TypeVarAbstract> ass, TypeVarStore typeVarStore) {
|
||||
public List<ConstraintAbstract> typeExpr(Map<String, RefTypeOrTPHOrWildcardOrGeneric> ass, TypeVarStore typeVarStore) {
|
||||
List<ConstraintAbstract> constriants = new ArrayList<>();
|
||||
|
||||
TypeVarAbstract tv = ass.get(name);
|
||||
RefTypeOrTPHOrWildcardOrGeneric tv = ass.get(name);
|
||||
typeVarStore.addTuple(tv,getTypePlaceHolder());
|
||||
return constriants;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<FieldInterface> fields;
|
||||
List<MethodInterface> methods;
|
||||
List<TypeVarAbstract> generics;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> generics;
|
||||
|
||||
|
||||
public Interface(TypeVarAbstract strucType, List<FieldInterface> fields, List<MethodInterface> methods, List<TypeVarAbstract> generics) {
|
||||
public Interface(RefTypeOrTPHOrWildcardOrGeneric strucType, List<FieldInterface> fields, List<MethodInterface> methods, List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.strucType = strucType;
|
||||
this.fields = fields;
|
||||
this.methods = methods;
|
||||
@ -40,11 +40,11 @@ public class Interface {
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public List<TypeVarAbstract> getGenerics() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getGenerics() {
|
||||
return generics;
|
||||
}
|
||||
|
||||
public void setGenerics(List<TypeVarAbstract> generics) {
|
||||
public void setGenerics(List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
|
@ -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<String, TypeVarAbstract> makeAssumptions(TypeVarStore typeVarStore) {
|
||||
Map<String, TypeVarAbstract> assLokal = new HashMap<>();
|
||||
public Map<String, RefTypeOrTPHOrWildcardOrGeneric> makeAssumptions(TypeVarStore typeVarStore) {
|
||||
Map<String, RefTypeOrTPHOrWildcardOrGeneric> 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<ConstraintAbstract> typeExpr(Map<String,TypeVarAbstract> ass, TypeVarStore typeVarStore) {
|
||||
public List<ConstraintAbstract> typeExpr(Map<String,RefTypeOrTPHOrWildcardOrGeneric> ass, TypeVarStore typeVarStore) {
|
||||
return TypeExpr.typeExpr(expression,ass,null , null , typeVarStore);
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> argsTypes;
|
||||
RefTypeOrTPHOrWildcardOrGeneric rtType;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> argsTypes;
|
||||
|
||||
|
||||
public MethodInterface(String name, TypeVarAbstract rtType, List<TypeVarAbstract> argsTypes) {
|
||||
public MethodInterface(String name, RefTypeOrTPHOrWildcardOrGeneric rtType, List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> getArgsTypes() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgsTypes() {
|
||||
return argsTypes;
|
||||
}
|
||||
|
||||
public void setArgsTypes(List<TypeVarAbstract> argsTypes) {
|
||||
public void setArgsTypes(List<RefTypeOrTPHOrWildcardOrGeneric> argsTypes) {
|
||||
this.argsTypes = argsTypes;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package de.dhbwstuttgart.strucTypes4.typeVars;
|
||||
/**
|
||||
* Created by sebastian on 14.04.17.
|
||||
*/
|
||||
public abstract class TypeVarAbstract {
|
||||
public abstract class RefTypeOrTPHOrWildcardOrGeneric {
|
||||
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -14,11 +14,11 @@ import java.util.List;
|
||||
public class TypeVarStore {
|
||||
|
||||
|
||||
private HashMap<TypeVarAbstract, List<TPH>> map = new HashMap<>();
|
||||
private HashMap<RefTypeOrTPHOrWildcardOrGeneric, List<TPH>> 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<TPH> 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<TPH> getTPHByTypeVar(TypeVarAbstract tv) {
|
||||
public List<TPH> 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<TPH> 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);
|
||||
|
@ -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;
|
||||
|
@ -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<FieldInterface> fields = new ArrayList<>();
|
||||
List<MethodInterface> methods = new ArrayList<>();
|
||||
List<TypeVarAbstract> generics = new ArrayList<>();
|
||||
List<TypeVarAbstract> genericsForConstraint = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> args = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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);
|
||||
|
@ -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<TypeVarAbstract> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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);
|
||||
|
@ -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<ConstraintAbstract> result = new ArrayList<>();
|
||||
return result;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<ConstraintAbstract> constraints;
|
||||
private List<Interface> generatedinterfaces;
|
||||
private List<TypeVarAbstract> genericsForClass;
|
||||
private List<RefTypeOrTPHOrWildcardOrGeneric> genericsForClass;
|
||||
|
||||
public AssumptionClass() {
|
||||
|
||||
}
|
||||
|
||||
public AssumptionClass(ClassOrInterface cl, TypeVarStore typeVarStore, AssumptionMap assumptionMap, List<ConstraintAbstract> constraints, List<Interface> generatedinterfaces, List<TypeVarAbstract> genericsForClass) {
|
||||
public AssumptionClass(ClassOrInterface cl, TypeVarStore typeVarStore, AssumptionMap assumptionMap, List<ConstraintAbstract> constraints, List<Interface> generatedinterfaces, List<RefTypeOrTPHOrWildcardOrGeneric> genericsForClass) {
|
||||
this.cl = cl;
|
||||
this.typeVarStore = typeVarStore;
|
||||
this.assumptionMap = assumptionMap;
|
||||
@ -77,11 +78,11 @@ public class AssumptionClass extends AssumptionAbstract {
|
||||
this.generatedinterfaces = generatedinterfaces;
|
||||
}
|
||||
|
||||
public List<TypeVarAbstract> getGenericsForClass() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getGenericsForClass() {
|
||||
return genericsForClass;
|
||||
}
|
||||
|
||||
public void setGenericsForClass(List<TypeVarAbstract> genericsForClass) {
|
||||
public void setGenericsForClass(List<RefTypeOrTPHOrWildcardOrGeneric> genericsForClass) {
|
||||
this.genericsForClass = genericsForClass;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> genericsneu = new ArrayList<>();
|
||||
for (TypeVarAbstract tv : oldAssClass.getGenericsForClass()) {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> genericsneu = new ArrayList<>();
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric tv : oldAssClass.getGenericsForClass()) {
|
||||
if (tv instanceof TypeVar) {
|
||||
TypeVar genericNeu = (TypeVar) mappingAltNeu.getNeu(tv);
|
||||
genericsneu.add(genericNeu);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> generics;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric strucType;
|
||||
private List<RefTypeOrTPHOrWildcardOrGeneric> generics;
|
||||
|
||||
|
||||
public InterfaceForConstraint(TypeVarAbstract strucType, List<TypeVarAbstract> generics) {
|
||||
public InterfaceForConstraint(RefTypeOrTPHOrWildcardOrGeneric strucType, List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.strucType = strucType;
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
|
||||
public boolean replaceTypeVarAbstract(TypeVarAbstract alt, TypeVarAbstract neu) {
|
||||
public boolean replaceTypeVarAbstract(RefTypeOrTPHOrWildcardOrGeneric alt, RefTypeOrTPHOrWildcardOrGeneric neu) {
|
||||
|
||||
List<TypeVarAbstract> genericsneu = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> getGenerics() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getGenerics() {
|
||||
return generics;
|
||||
}
|
||||
|
||||
public void setGenerics(List<TypeVarAbstract> generics) {
|
||||
public void setGenerics(List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<FieldInterface> fields;
|
||||
List<MethodInterface> methods;
|
||||
List<TypeVarAbstract> generics;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> generics;
|
||||
|
||||
|
||||
public Interface(TypeVarAbstract strucType, List<FieldInterface> fields, List<MethodInterface> methods, List<TypeVarAbstract> generics) {
|
||||
public Interface(RefTypeOrTPHOrWildcardOrGeneric strucType, List<FieldInterface> fields, List<MethodInterface> methods, List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.strucType = strucType;
|
||||
this.fields = fields;
|
||||
this.methods = methods;
|
||||
@ -42,11 +43,11 @@ public class Interface {
|
||||
this.methods = methods;
|
||||
}
|
||||
|
||||
public List<TypeVarAbstract> getGenerics() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getGenerics() {
|
||||
return generics;
|
||||
}
|
||||
|
||||
public void setGenerics(List<TypeVarAbstract> generics) {
|
||||
public void setGenerics(List<RefTypeOrTPHOrWildcardOrGeneric> generics) {
|
||||
this.generics = generics;
|
||||
}
|
||||
|
||||
|
@ -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<TypeVarAbstract> argsTypes;
|
||||
RefTypeOrTPHOrWildcardOrGeneric rtType;
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> argsTypes;
|
||||
|
||||
|
||||
public MethodInterface(String name, TypeVarAbstract rtType, List<TypeVarAbstract> argsTypes) {
|
||||
public MethodInterface(String name, RefTypeOrTPHOrWildcardOrGeneric rtType, List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> getArgsTypes() {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> getArgsTypes() {
|
||||
return argsTypes;
|
||||
}
|
||||
|
||||
public void setArgsTypes(List<TypeVarAbstract> argsTypes) {
|
||||
public void setArgsTypes(List<RefTypeOrTPHOrWildcardOrGeneric> argsTypes) {
|
||||
this.argsTypes = argsTypes;
|
||||
}
|
||||
|
||||
|
@ -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<ConstraintAbstract> 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<ConstraintAbstract> constraints , TypeVarAbstract alt , TypeVarAbstract neu ) {
|
||||
public void replaceAll(List<ConstraintAbstract> 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<TypeVarAbstract> reflect = reflectNext(constraints, css.getSubtype(), (TypeVar) css.getSuperType());
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> reflectNext(List<ConstraintAbstract> constraints , TypeVarAbstract startValue ,TypeVar nextPoint) {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> reflectNext(List<ConstraintAbstract> constraints , RefTypeOrTPHOrWildcardOrGeneric startValue ,TypeVar nextPoint) {
|
||||
|
||||
ConstraintSubType next = next(nextPoint,constraints);
|
||||
|
||||
if (next != null) {
|
||||
|
||||
if (next.getSuperType().equals(startValue)) {
|
||||
List<TypeVarAbstract> result = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> result = new ArrayList<>();
|
||||
result.add(next.getSubtype());
|
||||
constraints.remove(next); // ?? Sauber?
|
||||
return result;
|
||||
}
|
||||
else if (next.getSuperType() instanceof TypeVar ) {
|
||||
List<TypeVarAbstract> result = reflectNext(constraints,startValue,(TypeVar) next.getSuperType());
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<ConstraintAbstract> adapt2Next(TypeVarAbstract start , TypeVarAbstract last , List<ConstraintAbstract> constraints, List<ConstraintAbstract> newConstraints) {
|
||||
public List<ConstraintAbstract> adapt2Next(RefTypeOrTPHOrWildcardOrGeneric start , RefTypeOrTPHOrWildcardOrGeneric last , List<ConstraintAbstract> constraints, List<ConstraintAbstract> newConstraints) {
|
||||
|
||||
for (ConstraintAbstract cs : constraints) {
|
||||
|
||||
@ -433,8 +434,8 @@ public class Rules {
|
||||
TypeVarInterface iFGiven = (TypeVarInterface) constraintInterface.getSuperType();
|
||||
TypeVarInterface iFthis = (TypeVarInterface) css.getSuperType();
|
||||
|
||||
List<TypeVarAbstract> iFGivenGenerics = iFGiven.getInterfaceForConstraint().getGenerics();
|
||||
List<TypeVarAbstract> iFthisGenerics = iFthis.getInterfaceForConstraint().getGenerics();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> iFGivenGenerics = iFGiven.getInterfaceForConstraint().getGenerics();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> iFthisGenerics = iFthis.getInterfaceForConstraint().getGenerics();
|
||||
|
||||
if (iFGivenGenerics.size() == iFthisGenerics.size()) {
|
||||
for (int i = 0 ; i < iFGivenGenerics.size() ; i++ ) {
|
||||
|
@ -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<TypeVarAbstract> altList = new ArrayList<>();
|
||||
List<TypeVarAbstract> neuList = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> altList = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> neueGenerics = new ArrayList<>();
|
||||
List<TypeVarAbstract> alteGenerics = strucType.getInterfaceForConstraint().getGenerics();
|
||||
for (TypeVarAbstract tv : alteGenerics) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric name = strucType.getInterfaceForConstraint().getStrucType();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> neueGenerics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> alteGenerics = strucType.getInterfaceForConstraint().getGenerics();
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric tv : alteGenerics) {
|
||||
neueGenerics.add(this.getNeu(tv));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -14,11 +14,11 @@ import java.util.List;
|
||||
public class TypeVarStore {
|
||||
|
||||
|
||||
private HashMap<TypeVarAbstract, List<RefTypeOrTPHOrWildcardOrGeneric>> map = new HashMap<>();
|
||||
private HashMap<RefTypeOrTPHOrWildcardOrGeneric, List<RefTypeOrTPHOrWildcardOrGeneric>> 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<RefTypeOrTPHOrWildcardOrGeneric> getTPHByTypeVar(TypeVarAbstract tv) {
|
||||
public List<RefTypeOrTPHOrWildcardOrGeneric> 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<RefTypeOrTPHOrWildcardOrGeneric> tphList = map.get(old);
|
||||
@ -137,7 +137,7 @@ public class TypeVarStore {
|
||||
}
|
||||
|
||||
|
||||
public TypeVarAbstract isType(TypeVar testVar) {
|
||||
public RefTypeOrTPHOrWildcardOrGeneric isType(TypeVar testVar) {
|
||||
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<TypeVarAbstract> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> generics2 = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<ConstraintAbstract> constraints , String name) {
|
||||
private RefTypeOrTPHOrWildcardOrGeneric getTypeVar(List<ConstraintAbstract> constraints , String name) {
|
||||
for (ConstraintAbstract cs : constraints) {
|
||||
if (cs instanceof ConstraintSubType) {
|
||||
ConstraintSubType css = (ConstraintSubType) cs;
|
||||
|
@ -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<TypeVarAbstract> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> generics2 = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<ConstraintAbstract> constraints , String name) {
|
||||
private RefTypeOrTPHOrWildcardOrGeneric getTypeVar(List<ConstraintAbstract> constraints , String name) {
|
||||
for (ConstraintAbstract cs : constraints) {
|
||||
if (cs instanceof ConstraintSubType) {
|
||||
ConstraintSubType css = (ConstraintSubType) cs;
|
||||
|
@ -183,7 +183,7 @@ public class SolveTest_Dev {
|
||||
TypeVar t1 = TypeVarFactory.makeTypeVar();
|
||||
|
||||
// Erstelle Interface 1
|
||||
List<TypeVarAbstract> genericsA = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> genericsB = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> genericsA = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> 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<TypeVarAbstract> genericsA = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> genericsA = new ArrayList<>();
|
||||
TypeVar t2 = TypeVarFactory.makeTypeVar();
|
||||
TypeVar t3 = TypeVarFactory.makeTypeVar();
|
||||
genericsA.add(t3);
|
||||
|
Loading…
Reference in New Issue
Block a user