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


C# TypeDesc.IsCanonicalSubtype方法代码示例

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


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

示例1: EETypeNode

 public EETypeNode(TypeDesc type)
 {
     Debug.Assert(!type.IsCanonicalSubtype(CanonicalFormKind.Specific));
     Debug.Assert(!type.IsRuntimeDeterminedSubtype);
     _type = type;
     _optionalFieldsNode = new EETypeOptionalFieldsNode(this);
 }
开发者ID:hoyMS,项目名称:corert,代码行数:7,代码来源:EETypeNode.cs

示例2: EETypeNode

        public EETypeNode(NodeFactory factory, TypeDesc type)
        {
            Debug.Assert(!type.IsCanonicalSubtype(CanonicalFormKind.Specific));
            Debug.Assert(!type.IsRuntimeDeterminedSubtype);
            _type = type;
            _optionalFieldsNode = new EETypeOptionalFieldsNode(this);

            // Note: The fact that you can't create invalid EETypeNode is used from many places that grab
            // an EETypeNode from the factory with the sole purpose of making sure the validation has run
            // and that the result of the positive validation is "cached" (by the presence of an EETypeNode).
            CheckCanGenerateEEType(factory, type);
        }
开发者ID:justinvp,项目名称:corert,代码行数:12,代码来源:EETypeNode.cs

示例3: GetInstanceGCLayout

        // Get the GC layout of a type. Handles pre-created, universal template, and non-universal template cases
        // Only to be used for getting the instance layout of non-valuetypes.
        /// <summary>
        /// Get the GC layout of a type. Handles pre-created, universal template, and non-universal template cases
        /// Only to be used for getting the instance layout of non-valuetypes that are used as base types
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private unsafe TypeBuilder.GCLayout GetInstanceGCLayout(TypeDesc type)
        {
            Debug.Assert(!type.IsCanonicalSubtype(CanonicalFormKind.Any));
            Debug.Assert(!type.IsValueType);

            if (type.RetrieveRuntimeTypeHandleIfPossible())
            {
                return new TypeBuilder.GCLayout(type.RuntimeTypeHandle);
            }

            if (type.IsTemplateCanonical())
            {
                var templateType = type.ComputeTemplate();
                bool success = templateType.RetrieveRuntimeTypeHandleIfPossible();
                Debug.Assert(success && !templateType.RuntimeTypeHandle.IsNull());

                return new TypeBuilder.GCLayout(templateType.RuntimeTypeHandle);
            }
            else
            {
                TypeBuilderState state = type.GetOrCreateTypeBuilderState();
                if (state.InstanceGCLayout == null)
                    return TypeBuilder.GCLayout.None;
                else
                    return new TypeBuilder.GCLayout(state.InstanceGCLayout, true);
            }
        }
开发者ID:justinvp,项目名称:corert,代码行数:35,代码来源:TypeBuilderState.cs

示例4: getClassAttribsInternal

        private uint getClassAttribsInternal(TypeDesc type)
        {
            // TODO: Support for verification (CORINFO_FLG_GENERIC_TYPE_VARIABLE)

            CorInfoFlag result = (CorInfoFlag)0;

            // The array flag is used to identify the faked-up methods on
            // array types, i.e. .ctor, Get, Set and Address
            if (type.IsArray)
                result |= CorInfoFlag.CORINFO_FLG_ARRAY;

            if (type.IsInterface)
                result |= CorInfoFlag.CORINFO_FLG_INTERFACE;

            if (type.IsArray || type.IsString)
                result |= CorInfoFlag.CORINFO_FLG_VAROBJSIZE;

            if (type.IsValueType)
            {
                result |= CorInfoFlag.CORINFO_FLG_VALUECLASS;

                // TODO
                // if (type.IsUnsafeValueType)
                //    result |= CorInfoFlag.CORINFO_FLG_UNSAFE_VALUECLASS;
            }

            if (type.IsCanonicalSubtype(CanonicalFormKind.Any))
                result |= CorInfoFlag.CORINFO_FLG_SHAREDINST;

            if (type.HasVariance)
                result |= CorInfoFlag.CORINFO_FLG_VARIANCE;

            if (type.IsDelegate)
                result |= CorInfoFlag.CORINFO_FLG_DELEGATE;

            var metadataType = type as MetadataType;
            if (metadataType != null)
            {
                if (metadataType.ContainsGCPointers)
                    result |= CorInfoFlag.CORINFO_FLG_CONTAINS_GC_PTR;

                if (metadataType.IsBeforeFieldInit)
                    result |= CorInfoFlag.CORINFO_FLG_BEFOREFIELDINIT;

                if (metadataType.IsSealed)
                    result |= CorInfoFlag.CORINFO_FLG_FINAL;
            }

            return (uint)result;
        }
开发者ID:hoyMS,项目名称:corert,代码行数:50,代码来源:CorInfoImpl.cs

示例5: EETypeNode

 public EETypeNode(TypeDesc type)
 {
     Debug.Assert(!type.IsCanonicalSubtype(CanonicalFormKind.Specific));
     Debug.Assert(!type.IsRuntimeDeterminedSubtype);
     _type = type;
 }
开发者ID:krytarowski,项目名称:corert,代码行数:6,代码来源:EETypeNode.cs

示例6: TypeGenericDictionaryNode

        public TypeGenericDictionaryNode(TypeDesc owningType)
        {
            Debug.Assert(!owningType.IsCanonicalSubtype(CanonicalFormKind.Any));
            Debug.Assert(!owningType.IsRuntimeDeterminedSubtype);
            Debug.Assert(owningType.HasInstantiation);

            _owningType = owningType;
        }
开发者ID:stephentoub,项目名称:corert,代码行数:8,代码来源:GenericDictionaryNode.cs

示例7: ConvertToCanon

        public static TypeDesc ConvertToCanon(TypeDesc typeToConvert, ref CanonicalFormKind kind)
        {
            TypeSystemContext context = typeToConvert.Context;
            if (kind == CanonicalFormKind.Universal)
            {
                return context.UniversalCanonType;
            }
            else if (kind == CanonicalFormKind.Specific)
            {
                if (typeToConvert == context.UniversalCanonType)
                {
                    kind = CanonicalFormKind.Universal;
                    return context.UniversalCanonType;
                }
                else if (typeToConvert.IsSignatureVariable)
                {
                    return typeToConvert;
                }
                else if (typeToConvert.IsDefType)
                {
                    if (!typeToConvert.IsValueType)
                    {
                        return context.CanonType;
                    }
                    else if (typeToConvert.HasInstantiation)
                    {
                        TypeDesc canonicalType = typeToConvert.ConvertToCanonForm(CanonicalFormKind.Specific);

                        // This is a generic struct type. If the generic struct is instantiated over universal canon,
                        // the entire struct becomes universally canonical.
                        if (canonicalType.IsCanonicalSubtype(CanonicalFormKind.Universal))
                        {
                            kind = CanonicalFormKind.Universal;
                            return context.UniversalCanonType;
                        }

                        return canonicalType;
                    }
                    else if (typeToConvert.IsRuntimeDeterminedType)
                    {
                        // For non-universal canon cases, RuntimeDeterminedType's passed into this function are either
                        // reference types (which are turned into normal Canon), or instantiated types (which are handled 
                        // by the above case.). But for UniversalCanon, we can have non-instantiated universal canon
                        // which will reach this case.

                        // We should only ever reach this for T__UniversalCanon.
                        Debug.Assert(((RuntimeDeterminedType)typeToConvert).CanonicalType == context.UniversalCanonType);

                        kind = CanonicalFormKind.Universal;
                        return context.UniversalCanonType;
                    }
                    else
                    {
                        return typeToConvert;
                    }
                }
                else if (typeToConvert.IsArray)
                {
                    return context.CanonType;
                }
                else
                {
                    if (typeToConvert.IsCanonicalSubtype(CanonicalFormKind.Universal))
                    {
                        kind = CanonicalFormKind.Universal;
                        return context.UniversalCanonType;
                    }

                    return typeToConvert.ConvertToCanonForm(CanonicalFormKind.Specific);
                }
            }
            else
            {
                Debug.Assert(false);
                return null;
            }
        }
开发者ID:nattress,项目名称:corert,代码行数:77,代码来源:RuntimeDeterminedCanonicalizationAlgorithm.cs

示例8: GetFieldSizeAlignment

        internal void GetFieldSizeAlignment(TypeDesc fieldType, out int size, out int alignment)
        {
            Debug.Assert(!fieldType.IsCanonicalSubtype(CanonicalFormKind.Any));

            // All reference and array types are pointer-sized
            if (!fieldType.IsValueType)
            {
                size = IntPtr.Size;
                alignment = IntPtr.Size;
                return;
            }

            // Is this a type that already exists? If so, get its size from the EEType directly
            if (fieldType.RetrieveRuntimeTypeHandleIfPossible())
            {
                unsafe
                {
                    EEType* eeType = fieldType.RuntimeTypeHandle.ToEETypePtr();
                    size = (int)eeType->ValueTypeSize;
                    alignment = eeType->FieldAlignmentRequirement;
                    return;
                }
            }

            // The type of the field must be a generic valuetype that is dynamically being constructed
            Debug.Assert(fieldType.IsValueType);
            DefType fieldDefType = (DefType)fieldType;

            TypeBuilderState state = fieldType.GetOrCreateTypeBuilderState();

            size = fieldDefType.InstanceFieldSize;
            alignment = fieldDefType.InstanceFieldAlignment;
        }
开发者ID:nattress,项目名称:corert,代码行数:33,代码来源:NativeLayoutFieldAlgorithm.cs


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