fc smaller greater tests

This commit is contained in:
Florian Steurer 2015-11-07 13:57:54 +01:00
parent b93f1dd376
commit 6b709f0198
5 changed files with 33 additions and 9 deletions

View File

@ -29,7 +29,5 @@ public interface IFiniteClosure {
public boolean isInSmArg(Type smArgT, Type t);
public Set<Type> smaller(String typeName);
public Type getType(String typeName);
}

View File

@ -36,6 +36,7 @@ public class FiniteClosure implements IFiniteClosure {
// Add edges to build the transitive closure
parentNode.getPredecessors().stream().forEach(x -> x.AddDescendant(childNode));
childNode.getDescendants().stream().forEach(x -> x.AddPredecessor(parentNode));
}
}
@ -48,8 +49,7 @@ public class FiniteClosure implements IFiniteClosure {
return smaller(type.getName());
}
@Override
public Set<Type> smaller(String typeName) {
private Set<Type> smaller(String typeName) {
if(!inheritanceGraph.containsKey(typeName))
return new HashSet<>();
@ -70,20 +70,34 @@ public class FiniteClosure implements IFiniteClosure {
*/
@Override
public Set<Type> greater(Type type) {
if(!inheritanceGraph.containsKey(type.getName()))
return greater(type.typeName);
}
private Set<Type> greater(String typeName) {
if(!inheritanceGraph.containsKey(typeName))
return new HashSet<>();
return inheritanceGraph.get(type.getName()).getContentOfPredecessors();
return inheritanceGraph.get(typeName).getContentOfPredecessors();
}
@Override
public Set<Type> grArg(Type type) {
throw new NotImplementedException();
return grArg(type.getName());
}
private Set<Type> grArg(String typeName) {
// TODO Auto-generated method stub
return null;
}
@Override
public Set<Type> smArg(Type type) {
throw new NotImplementedException();
return smArg(type.getName());
}
private Set<Type> smArg(String typeName) {
// TODO Auto-generated method stub
return null;
}
@Override

View File

@ -49,4 +49,9 @@ public class Node<T> {
public Set<T> getContentOfPredecessors() {
return predecessors.stream().map(x -> x.getContent()).collect(Collectors.toSet());
}
@Override
public String toString() {
return "Node(" + content.toString() + ")";
}
}

View File

@ -1,5 +1,8 @@
package de.dhbwstuttgart.typinference.unify.model;
public class PlaceholderType extends Type{
public PlaceholderType(String name) {
typeName = name;
}
}

View File

@ -7,6 +7,10 @@ public abstract class Type {
protected String typeName = "";
protected TypeParams typeParams;
public Type() {
typeParams = new TypeParams();
}
public String getName() {
return typeName;
}