Exemple #1
0
        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;
            }
        }