From 88726ccb7059078f3e1b972ef50e41339a883c98 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Wed, 23 Mar 2016 09:45:36 +0100 Subject: [PATCH] added funN --- .../unify/interfaces/IFiniteClosure.java | 4 +++ .../unify/model/FiniteClosure.java | 14 +++++++- .../typeinference/unify/model/FunNType.java | 34 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java diff --git a/src/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java b/src/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java index 3af29411..0bba681f 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java +++ b/src/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java @@ -4,6 +4,7 @@ import java.util.Optional; import java.util.Set; import de.dhbwstuttgart.typeinference.unify.model.ExtendsType; +import de.dhbwstuttgart.typeinference.unify.model.FunNType; import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType; import de.dhbwstuttgart.typeinference.unify.model.SimpleType; import de.dhbwstuttgart.typeinference.unify.model.SuperType; @@ -49,6 +50,9 @@ public interface IFiniteClosure { public Set grArg(PlaceholderType type); public Set smArg(PlaceholderType type); + public Set grArg(FunNType type); + public Set smArg(FunNType type); + public Optional getGenericType(String typeName); public Set getAllTypesByName(String typeName); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java b/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java index 64fb6862..27827dbe 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify; import de.dhbwstuttgart.typeinference.unify.model.MPair.PairOperator; @@ -193,6 +194,11 @@ public class FiniteClosure implements IFiniteClosure { return result; } + @Override + public Set grArg(FunNType type) { + throw new NotImplementedException(); + } + @Override public Set grArg(ExtendsType type) { if(!inheritanceGraph.containsKey(type.getExtendedType())) @@ -249,7 +255,13 @@ public class FiniteClosure implements IFiniteClosure { return result; } - + + @Override + public Set smArg(FunNType type) { + throw new NotImplementedException(); + } + + @Override public Set smArg(ExtendsType type) { if(!inheritanceGraph.containsKey(type.getExtendedType())) return new HashSet(); diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java new file mode 100644 index 00000000..a6068c84 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java @@ -0,0 +1,34 @@ +package de.dhbwstuttgart.typeinference.unify.model; + +import java.util.Set; + +import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; + +public class FunNType extends Type { + + public FunNType(TypeParams p) { + super("FuN", p); + } + + @Override + public Type setTypeParams(TypeParams newTp) { + return new FunNType(newTp); + } + + @Override + Set smArg(IFiniteClosure fc) { + return fc.smArg(this); + } + + @Override + Set grArg(IFiniteClosure fc) { + return fc.grArg(this); + } + + @Override + Type apply(Unifier unif) { + // TODO Auto-generated method stub + return null; + } + +}