freshPlaceholder Method // funN rules (not implemented yet)

This commit is contained in:
Florian Steurer 2016-03-23 10:59:41 +01:00
parent 88726ccb70
commit 11bcf5735a
4 changed files with 53 additions and 1 deletions

View File

@ -16,6 +16,9 @@ public interface IRuleSet {
public Optional<Set<MPair>> reduce1(MPair pair);
public Optional<Set<MPair>> reduce2(MPair pair);
/*
* Missing Rules
*/
public Optional<MPair> reduceWildcardLow(MPair pair);
public Optional<MPair> reduceWildcardLowRight(MPair pair);
public Optional<MPair> reduceWildcardUp(MPair pair);
@ -24,6 +27,13 @@ public interface IRuleSet {
public Optional<MPair> reduceWildcardUpLow(MPair pair);
public Optional<MPair> reduceWildcardLeft(MPair pair);
/*
* FunN Rules
*/
public Optional<Set<MPair>> reduceFunN(MPair pair);
public Optional<Set<MPair>> greaterFunN(MPair pair);
public Optional<Set<MPair>> smallerFunN(MPair pair);
public boolean erase1(MPair pair);
public boolean erase2(MPair pair);
public boolean erase3(MPair pair);

View File

@ -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<String> EXISTING_PLACEHOLDERS = new HashSet<String>();
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

View File

@ -5,7 +5,7 @@ import java.util.Iterator;
public final class TypeParams implements Iterable<Type>{
private final Type[] typeParams;
public TypeParams(Type... types) {
typeParams = types;
}

View File

@ -657,4 +657,22 @@ public class RuleSet implements IRuleSet{
return Optional.empty();
}
@Override
public Optional<Set<MPair>> reduceFunN(MPair pair) {
// TODO Auto-generated method stub
return null;
}
@Override
public Optional<Set<MPair>> greaterFunN(MPair pair) {
// TODO Auto-generated method stub
return null;
}
@Override
public Optional<Set<MPair>> smallerFunN(MPair pair) {
// TODO Auto-generated method stub
return null;
}
}