class ConcreteType.ConcreteNoneType {
@Override public String toString() { return "()"; }
}
class ConcreteType.ConcreteFunctionType {
/**
* Informally, a function is represented by
* {@code function (params): returnType} where the {@code params} is a comma
* separated list of types, the first one being a special
* {@code this:T} if the function expects a known type for {@code this}.
*/
@Override public String toString() {
StringBuilder b = new StringBuilder(32);
b.append("function (");
boolean hasKnownTypeOfThis = !getThisSlot().getType().isNone();
if (hasKnownTypeOfThis) {
b.append("this:");
b.append(getThisSlot().getType().toString());
}
Node n = getFirstParameter();
if (hasKnownTypeOfThis && n != null) {
b.append(", ");
}
for (int i = 0; n != null; ++i, n = n.getNext()) {
String paramName = n.getString();
StaticSlot<ConcreteType> var = getScope().getOwnSlot(paramName);
b.append(var.getType());
getParameterSlot(i).getType();
if (n.getNext() != null) {
b.append(", ");
}
}
b.append(")");
if (getReturnSlot().getType() != null) {
b.append(": ");
b.append(getReturnSlot().getType().toString());
}
return b.toString();
}
}
class ConcreteType.ConcreteInstanceType {
@Override public String toString() { return instanceType.toString(); }
}
class ConcreteType.ConcreteUnionType {
@Override public String toString() {
List<String> names = Lists.newArrayList();
for (ConcreteType type : alternatives) {
names.add(type.toString());
}
Collections.sort(names);
return "(" + Joiner.on(",").join(names) + ")";
}
}
class ConcreteType.ConcreteAll {
@Override public String toString() { return "*"; }
}
class ConcreteType.ConcreteUniqueType {
@Override public String toString() { return "Unique$" + id; }
}
|