// Work around
Object ob = rt;
@SuppressWarnings("unchecked")
TypicalTypes.ConstructedT ct = (TypicalTypes.ConstructedT)ob;
String str = (String)ct.getTuple().get2();
Node baseNode = toTypeNode(getBase(rt), objectToWild);
if ("list".equals(str)) {
return GNode.create("Type",
GNode.create("InstantiatedType",
GNode.create("TypeInstantiation",
"Pair",
GNode.create("TypeArguments", baseNode))),
null);
} else if ("var".equals(str)) {
return baseNode;
} else {
return makeTypeNode(str, objectToWild);
}
}
// Type name
if (rt.isTypeName()) {
return makeTypeNode((String)rt.getTuple().get1(), objectToWild);
}
// Record type
if (rt.isRecordT()) {
Pair<Object> p = rt.getTuple().get1();
Object head = p.head();
@SuppressWarnings("unchecked")
TypicalTypes.raw_type field = unwrapRawType(head);
if(field.isFieldT()){
final String recName = (String)field.getTuple().get1();
return makeTypeNode(recName, objectToWild);
} else {
return toTypeNode(field, objectToWild);
}
}
// Tuple type
if (rt.isTupleT()) {
//Workaround to fix incompatible type bug on Mac OS
Object o1 = rt;
@SuppressWarnings("unchecked")
TypicalTypes.TupleT tt = (TypicalTypes.TupleT)o1;
//End workaround
List<Object> members = new ArrayList<Object>();
@SuppressWarnings("unchecked")
Pair<?> tl = tt.getTuple().get1();
for (Iterator<?> iter = tl.iterator(); iter.hasNext(); ) {
members.add(iter.next());
}
// Make type arguments
Node typeArgs = GNode.create("TypeArguments");
for (Object ob : members) typeArgs.add(toTypeNode(ob, objectToWild));
// Return the tuple type
return GNode.create("Type",
GNode.create("InstantiatedType",
GNode.create("TypeInstantiation", "Tuple", null),
GNode.create("TypeInstantiation", "T" + members.size(),
typeArgs)),
null);
}
if (rt.isPairOfType()) {
return toTypeNode(rt.getTuple().get1(), objectToWild);
}
// Function type
if (rt.isFunctionT()) {
inFunctionType = true;
List<Object> paramTypes = new ArrayList<Object>();
Pair<?> params = cast(rt.getTuple().get1());
for (Iterator<?> iter = params.iterator(); iter.hasNext();) {
paramTypes.add(iter.next());
}
Node retTypeNode;
Object retType = rt.getTuple().get2();
if (retType instanceof TypicalTypes.type) {
TypicalTypes.type retT = (TypicalTypes.type)retType;
if (null == retT.type) {
retTypeNode = makeTypeNode("Void", false) ;
} else {
retTypeNode = toTypeNode(retT, objectToWild);
}
} else {
if (null == retType) {
retTypeNode = makeTypeNode("Void", false) ;
} else {
retTypeNode = toTypeNode(retType, objectToWild);
}
}
// Make type arguments
Node typeArgs = GNode.create("TypeArguments");
typeArgs.add(retTypeNode);
for (Object ob : paramTypes) typeArgs.add(toTypeNode(ob, objectToWild));
inFunctionType = false;
// Return the function type
return GNode.create("Type",
GNode.create("InstantiatedType",
GNode.create("TypeInstantiation", "Function", null),