private TypeClassification GetTypeClassification(TypeNode type)
{
// We see references on output parameters - they aren't interesting
while (type is Reference)
type = ((Reference)type).ElementType;
if (type == this.ZingPtrType)
return TypeClassification.Heap;
string typeName = GetTypeName(type);
for (int c = 0, nc = this.cZing.CompilationUnits.Count; c < nc; c++)
{
for (int t = 0, nTypes = ((Namespace)this.cZing.CompilationUnits[c].Nodes[0]).Types.Count; t < nTypes; t++)
{
TypeNode tn = ((Namespace)this.cZing.CompilationUnits[c].Nodes[0]).Types[t];
if (tn.Name.Name == typeName)
{
if (tn is Set)
return TypeClassification.Heap;
else if (tn is Chan)
return TypeClassification.Heap;
else if (tn is Struct)
return TypeClassification.Struct;
else if (tn is EnumNode)
return TypeClassification.Enum;
else if (tn is Range)
return TypeClassification.Simple;
else
return TypeClassification.Heap;
}
}
}
if (type.TypeCode == TypeCode.Object)
return TypeClassification.Heap;
else
return TypeClassification.Simple;
}