diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index 533a6173..cf7fa7ec 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -9,6 +9,7 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.syntaxtree.NullSyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType; import de.dhbwstuttgart.syntaxtree.type.FunN; +import de.dhbwstuttgart.syntaxtree.type.FunVoidN; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.ObjectType; import de.dhbwstuttgart.syntaxtree.type.RefType; @@ -108,7 +109,7 @@ public class UnifyTypeFactory { params.add(UnifyTypeFactory.convert(pT)); } } - ret = FunNType.getFunNType(new TypeParams(params)); + ret = FunNType.getFunNType(t.getName().toString(), new TypeParams(params)); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index 220517e2..dceb09f9 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -215,16 +215,6 @@ public class LambdaExpression extends Expr{ return ret; } - /* - private List crawlVariables(SyntaxTreeNode inStatements){ - List ret = new ArrayList<>(); - for(SyntaxTreeNode child : inStatements.getChildren()){ - ret.addAll(crawlVariables(child)); - } - return ret; - } - */ - @Override public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) { DHBWConstantPoolGen cp = cg.getConstantPool(); diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FunN.java b/src/de/dhbwstuttgart/syntaxtree/type/FunN.java index 6b3613b9..5d290d79 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FunN.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FunN.java @@ -17,6 +17,7 @@ import de.dhbwstuttgart.syntaxtree.factory.NameGenerator; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.DebugException; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; /** @@ -157,7 +158,7 @@ public class FunN extends RefType { } public FunNInterface getCorrespondingInterface(){ - return null; + throw new NotImplementedException(); } /* diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java b/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java index 6ee24f83..6a67264c 100644 --- a/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java @@ -1,12 +1,16 @@ package de.dhbwstuttgart.syntaxtree.type; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; + import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.ParameterList; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; @@ -29,7 +33,7 @@ public class FunVoidN extends FunN { * @param T * @return */ - public FunVoidN(Menge T) { + public FunVoidN(List T) { super(T.size()); this.setR(new Void(this, -1)); this.setT(T); @@ -56,5 +60,17 @@ public class FunVoidN extends FunN { if(T!=null)t.addAll(T); this.set_ParaList(t); } - + + @Override + public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){ + //FunN Typen müssen nicht geprüft werden. Sie werden schließlich nur von unserem Typinferenzalgorithmus erstellt: + List paraList = new ArrayList<>(); + if(this.T != null && this.T.size() > 0)for(Type t : this.T){ + Type toAdd = t.TYPE(ass, parent); + //if(toAdd == null)throw new TypeinferenceException("Typ "+toAdd+" ist in den Assumptions nicht vorhanden",this); + paraList.add(toAdd); + } + FunVoidN ret = new FunVoidN(paraList); + return ret; + } } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java index cf2c86ae..9a97456a 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java @@ -13,8 +13,8 @@ public class FunNType extends UnifyType { /** * Creates a FunN-Type with the specified TypeParameters. */ - protected FunNType(TypeParams p) { - super("Fun"+(p.size()-1), p); + protected FunNType(String name, TypeParams p) { + super(name, p); } /** @@ -23,13 +23,13 @@ public class FunNType extends UnifyType { * @return A FunNType. * @throws IllegalArgumentException is thrown when there are to few type parameters or there are wildcard-types. */ - public static FunNType getFunNType(TypeParams tp) throws IllegalArgumentException { + public static FunNType getFunNType(String name, TypeParams tp) throws IllegalArgumentException { if(tp.size() == 0) throw new IllegalArgumentException("FunNTypes need at least one type parameter"); for(UnifyType t : tp) if(t instanceof WildcardType) throw new IllegalArgumentException("Invalid TypeParams for a FunNType: " + tp); - return new FunNType(tp); + return new FunNType(name,tp); } /** @@ -43,7 +43,7 @@ public class FunNType extends UnifyType { public UnifyType setTypeParams(TypeParams newTp) { if(newTp.hashCode() == typeParams.hashCode() && newTp.equals(typeParams)) return this; - return getFunNType(newTp); + return getFunNType(this.getName(), newTp); } @Override @@ -64,7 +64,7 @@ public class FunNType extends UnifyType { if(newParams.hashCode() == typeParams.hashCode() && newParams.equals(typeParams)) return this; - return new FunNType(newParams); + return new FunNType(this.getName(), newParams); } @Override diff --git a/test/plugindevelopment/TypeInsertTests/FunVoid.java b/test/plugindevelopment/TypeInsertTests/FunVoid.java index 017b6b9f..687a5919 100644 --- a/test/plugindevelopment/TypeInsertTests/FunVoid.java +++ b/test/plugindevelopment/TypeInsertTests/FunVoid.java @@ -12,7 +12,7 @@ public class FunVoid { @Test public void run(){ Menge mustContain = new Menge(); - //mustContain.add("TestIfStmt var"); + mustContain.add("FunVoid"); MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); ArrayList l = new ArrayList(); }