freshPlaceholder Method // funN rules (not implemented yet)
This commit is contained in:
parent
88726ccb70
commit
11bcf5735a
@ -16,6 +16,9 @@ public interface IRuleSet {
|
|||||||
public Optional<Set<MPair>> reduce1(MPair pair);
|
public Optional<Set<MPair>> reduce1(MPair pair);
|
||||||
public Optional<Set<MPair>> reduce2(MPair pair);
|
public Optional<Set<MPair>> reduce2(MPair pair);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Missing Rules
|
||||||
|
*/
|
||||||
public Optional<MPair> reduceWildcardLow(MPair pair);
|
public Optional<MPair> reduceWildcardLow(MPair pair);
|
||||||
public Optional<MPair> reduceWildcardLowRight(MPair pair);
|
public Optional<MPair> reduceWildcardLowRight(MPair pair);
|
||||||
public Optional<MPair> reduceWildcardUp(MPair pair);
|
public Optional<MPair> reduceWildcardUp(MPair pair);
|
||||||
@ -24,6 +27,13 @@ public interface IRuleSet {
|
|||||||
public Optional<MPair> reduceWildcardUpLow(MPair pair);
|
public Optional<MPair> reduceWildcardUpLow(MPair pair);
|
||||||
public Optional<MPair> reduceWildcardLeft(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 erase1(MPair pair);
|
||||||
public boolean erase2(MPair pair);
|
public boolean erase2(MPair pair);
|
||||||
public boolean erase3(MPair pair);
|
public boolean erase3(MPair pair);
|
||||||
|
@ -1,13 +1,37 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify.model;
|
package de.dhbwstuttgart.typeinference.unify.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
|
|
||||||
public final class PlaceholderType extends Type{
|
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) {
|
public PlaceholderType(String name) {
|
||||||
super(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
|
@Override
|
||||||
|
@ -5,7 +5,7 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
public final class TypeParams implements Iterable<Type>{
|
public final class TypeParams implements Iterable<Type>{
|
||||||
private final Type[] typeParams;
|
private final Type[] typeParams;
|
||||||
|
|
||||||
public TypeParams(Type... types) {
|
public TypeParams(Type... types) {
|
||||||
typeParams = types;
|
typeParams = types;
|
||||||
}
|
}
|
||||||
|
@ -657,4 +657,22 @@ public class RuleSet implements IRuleSet{
|
|||||||
|
|
||||||
return Optional.empty();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user