コード例 #1
0
        public static CilType From(TypeReference fromType)
        {
            if (!_Types.TryGetValue(fromType, out var converted))
            {
                converted = GetCachedPrimitive(fromType);
                if (converted != null)
                {
                    return(converted);
                }

                CilMain.Where.Push($"type '{fromType.FullName}'");

                converted = new CilType();
                converted.Import(fromType);

                if ((converted.Flags & DONT_CACHE) == 0)
                {
                    // do not cache GenericInstanceMethod objects,
                    // as each instance stands for a single use of the generic type
                    _Types.Add(fromType, converted);
                }

                CilMain.Where.Pop();
            }
            return(converted);
        }