diff --git a/src/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java b/src/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java index c4de888d..23c444e0 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java +++ b/src/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java @@ -16,6 +16,9 @@ public interface IRuleSet { public Optional> reduce1(MPair pair); public Optional> reduce2(MPair pair); + /* + * Missing Rules + */ public Optional reduceWildcardLow(MPair pair); public Optional reduceWildcardLowRight(MPair pair); public Optional reduceWildcardUp(MPair pair); @@ -24,6 +27,13 @@ public interface IRuleSet { public Optional reduceWildcardUpLow(MPair pair); public Optional reduceWildcardLeft(MPair pair); + /* + * FunN Rules + */ + public Optional> reduceFunN(MPair pair); + public Optional> greaterFunN(MPair pair); + public Optional> smallerFunN(MPair pair); + public boolean erase1(MPair pair); public boolean erase2(MPair pair); public boolean erase3(MPair pair); diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index 5a3d5341..b5a0fe1e 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -1,13 +1,37 @@ package de.dhbwstuttgart.typeinference.unify.model; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Random; import java.util.Set; import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; public final class PlaceholderType extends Type{ + protected static final HashSet EXISTING_PLACEHOLDERS = new HashSet(); + protected static String nextName = "gen_"; + public PlaceholderType(String name) { super(name); + EXISTING_PLACEHOLDERS.add(name); + } + + public static PlaceholderType freshPlaceholder() { + String name = nextName + randomChar(); + + while(EXISTING_PLACEHOLDERS.contains(name)); + nextName += randomChar(); + + return new PlaceholderType(name); + } + + /** + * Returns random char between 'a' and 'z' + * @return + */ + private static char randomChar() { + return (char) (new Random().nextInt(22) + 97); } @Override diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/TypeParams.java b/src/de/dhbwstuttgart/typeinference/unify/model/TypeParams.java index 966a561b..a7393508 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/TypeParams.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/TypeParams.java @@ -5,7 +5,7 @@ import java.util.Iterator; public final class TypeParams implements Iterable{ private final Type[] typeParams; - + public TypeParams(Type... types) { typeParams = types; } diff --git a/src/de/dhbwstuttgart/typeinference/unifynew/RuleSet.java b/src/de/dhbwstuttgart/typeinference/unifynew/RuleSet.java index 52239af4..4232a692 100644 --- a/src/de/dhbwstuttgart/typeinference/unifynew/RuleSet.java +++ b/src/de/dhbwstuttgart/typeinference/unifynew/RuleSet.java @@ -657,4 +657,22 @@ public class RuleSet implements IRuleSet{ return Optional.empty(); } + + @Override + public Optional> reduceFunN(MPair pair) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Optional> greaterFunN(MPair pair) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Optional> smallerFunN(MPair pair) { + // TODO Auto-generated method stub + return null; + } }