From d03e20df90ee3b6cded18e3463af89b32ef063ee Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Fri, 29 Apr 2016 15:23:42 +0200 Subject: [PATCH] FunN Typen konvertieren. FunVoidN Typen werden nicht mehr benutzt --- src/de/dhbwstuttgart/core/MyCompiler.java | 10 +++++----- src/de/dhbwstuttgart/syntaxtree/type/FunN.java | 5 ++++- .../dhbwstuttgart/typeinference/FunNInterface.java | 12 +++++++++--- .../typeinference/unify/model/FunNType.java | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/de/dhbwstuttgart/core/MyCompiler.java b/src/de/dhbwstuttgart/core/MyCompiler.java index c9159648..9a194a03 100755 --- a/src/de/dhbwstuttgart/core/MyCompiler.java +++ b/src/de/dhbwstuttgart/core/MyCompiler.java @@ -159,11 +159,11 @@ public class MyCompiler implements MyCompilerAPI{ FunNInterface funN = new FunNInterface(i); ret.add(funN.getPublicFieldAssumptions()); } - for(int i = 0; i<6; i++){ - FunVoidNInterface funN = new FunVoidNInterface(i); - ret.add(funN.getPublicFieldAssumptions()); - } - + //Keine FunVoidInterfaces in den Assumptions. + //for(int i = 0; i<6; i++){ + // FunVoidNInterface funN = new FunVoidNInterface(i); + // ret.add(funN.getPublicFieldAssumptions()); + //} return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FunN.java b/src/de/dhbwstuttgart/syntaxtree/type/FunN.java index b2d27792..0e23a2a2 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FunN.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FunN.java @@ -15,6 +15,7 @@ import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.DebugException; +import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; /** * @see Spezifikation "Complete Typeinference in Java 8" von Martin Plümicke @@ -143,7 +144,9 @@ public class FunN extends RefType { //FunN Typen müssen nicht geprüft werden. Sie werden schließlich nur von unserem Typinferenzalgorithmus erstellt: List paraList = new ArrayList<>(); for(Type t : this.T){ - paraList.add(t.TYPE(ass, parent)); + Type toAdd = t.TYPE(ass, parent); + //if(toAdd == null)throw new TypeinferenceException("Typ "+toAdd+" ist in den Assumptions nicht vorhanden",this); + paraList.add(toAdd); } FunN ret = new FunN(this.R.TYPE(ass, parent),paraList); return ret; diff --git a/src/de/dhbwstuttgart/typeinference/FunNInterface.java b/src/de/dhbwstuttgart/typeinference/FunNInterface.java index 5a8e7280..877e0632 100644 --- a/src/de/dhbwstuttgart/typeinference/FunNInterface.java +++ b/src/de/dhbwstuttgart/typeinference/FunNInterface.java @@ -2,6 +2,8 @@ package de.dhbwstuttgart.typeinference; import de.dhbwstuttgart.typeinference.Menge; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import de.dhbwstuttgart.parser.JavaClassName; @@ -85,9 +87,13 @@ public class FunNInterface extends Class{ @Override public RefType getType() { List paraList = this.get_ParaList(); - Type R = paraList.get(0); - paraList.remove(0); - return new FunN(R, paraList); + Iterator paraIter = paraList.iterator(); + Type R = paraIter.next(); + List paraListNew = new ArrayList<>(); + while(paraIter.hasNext()){ + paraListNew.add(paraIter.next()); + } + return new FunN(R, paraListNew); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java index b7e5c60e..cf2c86ae 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java @@ -14,7 +14,7 @@ public class FunNType extends UnifyType { * Creates a FunN-Type with the specified TypeParameters. */ protected FunNType(TypeParams p) { - super("FuN", p); + super("Fun"+(p.size()-1), p); } /**