当前位置: 首页>>代码示例>>C#>>正文


C# DefType.GetOrCreateTypeBuilderState方法代码示例

本文整理汇总了C#中Internal.TypeSystem.DefType.GetOrCreateTypeBuilderState方法的典型用法代码示例。如果您正苦于以下问题:C# DefType.GetOrCreateTypeBuilderState方法的具体用法?C# DefType.GetOrCreateTypeBuilderState怎么用?C# DefType.GetOrCreateTypeBuilderState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Internal.TypeSystem.DefType的用法示例。


在下文中一共展示了DefType.GetOrCreateTypeBuilderState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeContainsGCPointers

        public unsafe override bool ComputeContainsGCPointers(DefType type)
        {
            if (type.IsTemplateCanonical())
            {
                return type.ComputeTemplate().RuntimeTypeHandle.ToEETypePtr()->HasGCPointers;
            }
            else
            {
                if (type.RetrieveRuntimeTypeHandleIfPossible())
                {
                    return type.RuntimeTypeHandle.ToEETypePtr()->HasGCPointers;
                }

                return type.GetOrCreateTypeBuilderState().InstanceGCLayout != null;
            }
        }
开发者ID:nattress,项目名称:corert,代码行数:16,代码来源:NativeLayoutFieldAlgorithm.cs

示例2: TryComputeHasInstantiationDeterminedSize

        internal bool TryComputeHasInstantiationDeterminedSize(DefType type, out bool hasInstantiationDeterminedSize)
        {
            Debug.Assert(type.HasInstantiation);

            NativeLayoutInfoLoadContext loadContextUniversal;
            NativeParser parser = type.GetOrCreateTypeBuilderState().GetParserForUniversalNativeLayoutInfo(out loadContextUniversal);
            if (parser.IsNull)
            {
                hasInstantiationDeterminedSize = false;
#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
                // TODO, Add logic which uses type loader to identify which types are affected by loading the 
                // universal generic type, and checking its size. At this time, the type loader cannot correctly
                // compute sizes of generic types that are instantiated over UniversalCanon
                Environment.FailFast("Unable to determine if a generic has an instantiation determined size.");
#endif
                return false;
            }

            int? flags = (int?)parser.GetUnsignedForBagElementKind(BagElementKind.TypeFlags);

            hasInstantiationDeterminedSize = flags.HasValue ?
                (((NativeFormat.TypeFlags)flags) & NativeFormat.TypeFlags.HasInstantiationDeterminedSize) != 0 :
                false;

            return true;
        }
开发者ID:nattress,项目名称:corert,代码行数:26,代码来源:TypeLoaderEnvironment.cs

示例3: EnsureFieldLayoutLoadedForNonUniversalType

        private static void EnsureFieldLayoutLoadedForNonUniversalType(DefType type)
        {
            Debug.Assert(type.HasInstantiation);
            Debug.Assert(!type.ComputeTemplate().IsCanonicalSubtype(CanonicalFormKind.Universal));

            if (type.NativeLayoutFields != null)
                return;

            // Look up the universal template for this type.  Only the universal template has field layout
            // information, so we have to use it to parse the field layout.
            NativeLayoutInfoLoadContext universalLayoutLoadContext;
            NativeParser typeInfoParser = type.GetOrCreateTypeBuilderState().GetParserForUniversalNativeLayoutInfo(out universalLayoutLoadContext);

            if (typeInfoParser.IsNull)
                throw new TypeBuilder.MissingTemplateException();

            // Now parse that layout into the NativeLayoutFields array.
            NativeParser fieldLayoutParser = typeInfoParser.GetParserForBagElementKind(BagElementKind.FieldLayout);
            type.NativeLayoutFields = ParseFieldLayout(type, universalLayoutLoadContext, fieldLayoutParser);
        }
开发者ID:nattress,项目名称:corert,代码行数:20,代码来源:NativeLayoutFieldAlgorithm.cs

示例4: EnsureFieldLayoutLoadedForGenericType

        internal static void EnsureFieldLayoutLoadedForGenericType(DefType type)
        {
            if (type.NativeLayoutFields != null)
                return;

            if (!type.IsTemplateUniversal())
            {
                // We can hit this case where the template of type in question is not a universal canonical type.
                // Example:
                //  BaseType<T> { ... }
                //  DerivedType<T, U> : BaseType<T> { ... }
                // and an instantiation like DerivedType<string, int>. In that case, BaseType<string> will have a non-universal
                // template type, and requires special handling to compute its size and field layout.
                EnsureFieldLayoutLoadedForNonUniversalType(type);
            }
            else
            {
                TypeBuilderState state = type.GetOrCreateTypeBuilderState();
                NativeParser typeInfoParser = state.GetParserForNativeLayoutInfo();
                NativeParser fieldLayoutParser = typeInfoParser.GetParserForBagElementKind(BagElementKind.FieldLayout);
                EnsureFieldLayoutLoadedForUniversalType(type, state.NativeLayoutInfo.LoadContext, fieldLayoutParser);
            }
        }
开发者ID:nattress,项目名称:corert,代码行数:23,代码来源:NativeLayoutFieldAlgorithm.cs


注:本文中的Internal.TypeSystem.DefType.GetOrCreateTypeBuilderState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。