diff --git a/src/de/dhbwstuttgart/typeinference/unify/freshPlaceholder.java b/src/de/dhbwstuttgart/typeinference/unify/freshPlaceholder.java index 45ccb6bb..69870bd5 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/freshPlaceholder.java +++ b/src/de/dhbwstuttgart/typeinference/unify/freshPlaceholder.java @@ -1,47 +1,15 @@ package de.dhbwstuttgart.typeinference.unify; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; + import java.util.HashMap; -import java.util.stream.Collectors; -import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor; -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.ReferenceType; -import de.dhbwstuttgart.typeinference.unify.model.SuperType; -import de.dhbwstuttgart.typeinference.unify.model.TypeParams; -public class freshPlaceholder implements UnifyTypeVisitor { - public ReferenceType visit(ReferenceType refty, HashMap ht) { - return new ReferenceType(refty.getName(), - new TypeParams( - Arrays.stream(refty.getTypeParams().get()) - .map(x -> x.accept(this, ht)) - .collect(Collectors.toCollection(ArrayList::new)))); - } - +public class freshPlaceholder extends visitUnifyTypeVisitor> { + + @Override public PlaceholderType visit(PlaceholderType phty, HashMap ht) { return ht.get(phty); - } - - public FunNType visit(FunNType funnty, HashMap ht) { - return FunNType.getFunNType( - new TypeParams( - Arrays.stream(funnty.getTypeParams().get()) - .map(x -> x.accept(this, ht)) - .collect(Collectors.toCollection(ArrayList::new))) - ); - } - - public SuperType visit(SuperType suty, HashMap ht) { - return new SuperType(suty.getWildcardedType().accept(this, ht)); - } - - public ExtendsType visit(ExtendsType extty, HashMap ht) { - return new ExtendsType(extty.getWildcardedType().accept(this, ht)); - } + } } diff --git a/src/de/dhbwstuttgart/typeinference/unify/interfaces/UnifyTypeVisitor.java b/src/de/dhbwstuttgart/typeinference/unify/interfaces/UnifyTypeVisitor.java index bf435f9c..8d06b3e1 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/interfaces/UnifyTypeVisitor.java +++ b/src/de/dhbwstuttgart/typeinference/unify/interfaces/UnifyTypeVisitor.java @@ -8,16 +8,16 @@ import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType; import de.dhbwstuttgart.typeinference.unify.model.ReferenceType; import de.dhbwstuttgart.typeinference.unify.model.SuperType; -public interface UnifyTypeVisitor { +public interface UnifyTypeVisitor { - public ReferenceType visit(ReferenceType refty, HashMap ht); + public ReferenceType visit(ReferenceType refty, T ht); - public PlaceholderType visit(PlaceholderType phty, HashMap ht); + public PlaceholderType visit(PlaceholderType phty, T ht); - public FunNType visit(FunNType funnty, HashMap ht); + public FunNType visit(FunNType funnty, T ht); - public SuperType visit(SuperType suty, HashMap ht); + public SuperType visit(SuperType suty, T ht); - public ExtendsType visit(ExtendsType extty, HashMap ht); + public ExtendsType visit(ExtendsType extty, T ht); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java b/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java index a97977c5..a7ff3af8 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java @@ -13,7 +13,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor; */ public final class ExtendsType extends WildcardType { - public UnifyType accept(UnifyTypeVisitor visitor, HashMap ht) { + public UnifyType accept(UnifyTypeVisitor visitor, T ht) { return visitor.visit(this, ht); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java index dd96dedd..37ec79d5 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java @@ -12,7 +12,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor; */ public class FunNType extends UnifyType { - public UnifyType accept(UnifyTypeVisitor visitor, HashMap ht) { + public UnifyType accept(UnifyTypeVisitor visitor, T ht) { return visitor.visit(this, ht); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index d9fd6699..21e8a66b 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -65,7 +65,7 @@ public final class PlaceholderType extends UnifyType{ IsGenerated = isGenerated; } - public UnifyType accept(UnifyTypeVisitor visitor, HashMap ht) { + public UnifyType accept(UnifyTypeVisitor visitor, T ht) { return visitor.visit(this, ht); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java b/src/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java index 133a87ed..81f6c3b3 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java @@ -19,7 +19,7 @@ public final class ReferenceType extends UnifyType { private final int hashCode; - public UnifyType accept(UnifyTypeVisitor visitor, HashMap ht) { + public UnifyType accept(UnifyTypeVisitor visitor, T ht) { return visitor.visit(this, ht); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java b/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java index 0b98c159..53762f86 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java @@ -12,7 +12,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor; */ public final class SuperType extends WildcardType { - public UnifyType accept(UnifyTypeVisitor visitor, HashMap ht) { + public UnifyType accept(UnifyTypeVisitor visitor, T ht) { return visitor.visit(this, ht); } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java b/src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java index 16986d65..555083e8 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java @@ -37,7 +37,7 @@ public abstract class UnifyType { } - abstract public UnifyType accept(UnifyTypeVisitor visitor, HashMap ht); + abstract public UnifyType accept(UnifyTypeVisitor visitor, T ht); /** * Returns the name of the type.