static bool AreSame (TypeSpecification a, TypeSpecification b) { if (!AreSame (a.ElementType, b.ElementType)) return false; if (a.IsGenericInstance) return AreSame ((GenericInstanceType) a, (GenericInstanceType) b); if (a.IsRequiredModifier || a.IsOptionalModifier) return AreSame ((IModifierType) a, (IModifierType) b); if (a.IsArray) return AreSame ((ArrayType) a, (ArrayType) b); return true; }
static void AppendTypeSpecification(TypeSpecification type, StringBuilder name) { if (type.ElementType.IsTypeSpecification()) { AppendTypeSpecification((TypeSpecification)type.ElementType, name); } switch (type.etype) { case ElementType.Ptr: name.Append('*'); break; case ElementType.ByRef: name.Append('&'); break; case ElementType.SzArray: case ElementType.Array: var array = (ArrayType)type; if (array.IsVector) { name.Append("[]"); } else { name.Append('['); for (int i = 1; i < array.Rank; i++) { name.Append(','); } name.Append(']'); } break; case ElementType.GenericInst: var instance = (GenericInstanceType)type; var arguments = instance.GenericArguments; name.Append('['); for (int i = 0; i < arguments.Count; i++) { if (i > 0) { name.Append(','); } var argument = arguments [i]; var requires_fqname = argument.Scope != argument.Module; if (requires_fqname) { name.Append('['); } AppendType(argument, name, true, false); if (requires_fqname) { name.Append(']'); } } name.Append(']'); break; default: return; } }