예제 #1
0
        public static TypeInfo GetTypeInfo(TypeSpec type, IMemberContext context)
        {
            if (!type.IsStruct)
            {
                return(simple_type);
            }

            TypeInfo info;

            if (type_hash.TryGetValue(type, out info))
            {
                return(info);
            }

            var struct_info = StructInfo.GetStructInfo(type, context);

            if (struct_info != null)
            {
                info = new TypeInfo(struct_info, 0);
            }
            else
            {
                info = simple_type;
            }

            type_hash.Add(type, info);
            return(info);
        }
예제 #2
0
        public static TypeInfo GetTypeInfo(TypeSpec type, IMemberContext context)
        {
            if (!type.IsStruct)
            {
                return(simple_type);
            }

            TypeInfo info;
            Dictionary <TypeSpec, TypeInfo> type_hash;

            if (type.BuiltinType > 0)
            {
                // Don't cache built-in types, they are null in most cases except for
                // corlib compilation when we need to distinguish between declaration
                // and referencing
                type_hash = null;
            }
            else
            {
                type_hash = context.Module.TypeInfoCache;
                if (type_hash.TryGetValue(type, out info))
                {
                    return(info);
                }
            }

            var struct_info = StructInfo.GetStructInfo(type, context);

            if (struct_info != null)
            {
                info = new TypeInfo(struct_info, 0);
            }
            else
            {
                info = simple_type;
            }

            if (type_hash != null)
            {
                type_hash.Add(type, info);
            }

            return(info);
        }