當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeReference.ContainsGenericParameter方法代碼示例

本文整理匯總了C#中Mono.Cecil.TypeReference.ContainsGenericParameter方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeReference.ContainsGenericParameter方法的具體用法?C# TypeReference.ContainsGenericParameter怎麽用?C# TypeReference.ContainsGenericParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.TypeReference的用法示例。


在下文中一共展示了TypeReference.ContainsGenericParameter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildType

        /// <summary>
        /// Internal helper to actually builds the type.
        /// </summary>
        /// <param name="typeReference">The type definition.</param>
        /// <returns></returns>
        private Type BuildType(TypeReference typeReference)
        {
            if (typeReference.ContainsGenericParameter())
                return null;

            TypeRef dataType;
            StackValueType stackType;
            var valueType = TypeRef.Empty;

            switch (typeReference.MetadataType)
            {
                case MetadataType.Pointer:
                {
                    var type = GetType(((PointerType)typeReference).ElementType);
                    // Special case: void*
                    if (LLVM.VoidTypeInContext(context) == type.DataType)
                        dataType = intPtrType;
                    else
                        dataType = LLVM.PointerType(type.DataType, 0);
                    stackType = StackValueType.NativeInt;
                    break;
                }
                case MetadataType.ByReference:
                {
                    var type = GetType(((ByReferenceType)typeReference).ElementType);
                    dataType = LLVM.PointerType(type.DefaultType, 0);
                    stackType = StackValueType.Reference;
                    break;
                }
                case MetadataType.RequiredModifier:
                    // TODO: Add support for this feature
                    return GetType(((RequiredModifierType)typeReference).ElementType);
                case MetadataType.Void:
                    dataType = LLVM.VoidTypeInContext(context);
                    stackType = StackValueType.Unknown;
                    break;
                case MetadataType.Boolean:
                    dataType = LLVM.Int8TypeInContext(context);
                    stackType = StackValueType.Int32;
                    break;
                case MetadataType.Single:
                    dataType = LLVM.FloatTypeInContext(context);
                    stackType = StackValueType.Float;
                    break;
                case MetadataType.Double:
                    dataType = LLVM.DoubleTypeInContext(context);
                    stackType = StackValueType.Float;
                    break;
                case MetadataType.Char:
                    dataType = CharUsesUTF8
                        ? LLVM.Int8TypeInContext(context)
                        : LLVM.Int16TypeInContext(context);
                    stackType = StackValueType.Int32;
                    break;
                case MetadataType.Byte:
                case MetadataType.SByte:
                    dataType = LLVM.Int8TypeInContext(context);
                    stackType = StackValueType.Int32;
                    break;
                case MetadataType.Int16:
                case MetadataType.UInt16:
                    dataType = LLVM.Int16TypeInContext(context);
                    stackType = StackValueType.Int32;
                    break;
                case MetadataType.Int32:
                case MetadataType.UInt32:
                    dataType = int32Type;
                    stackType = StackValueType.Int32;
                    break;
                case MetadataType.Int64:
                case MetadataType.UInt64:
                    dataType = int64Type;
                    stackType = StackValueType.Int64;
                    break;
                case MetadataType.UIntPtr:
                case MetadataType.IntPtr:
                    dataType = intPtrType;
                    stackType = StackValueType.NativeInt;
                    break;
                case MetadataType.Array:
                case MetadataType.String:
                case MetadataType.TypedByReference:
                case MetadataType.GenericInstance:
                case MetadataType.ValueType:
                case MetadataType.Class:
                case MetadataType.Object:
                {
                    // When resolved, void becomes a real type
                    if (typeReference.FullName == typeof(void).FullName)
                    {
                        goto case MetadataType.Void;
                    }

                    var typeDefinition = GetMethodTypeDefinition(typeReference);
                    if (typeDefinition.IsValueType && typeDefinition.IsEnum)
//.........這裏部分代碼省略.........
開發者ID:frje,項目名稱:SharpLang,代碼行數:101,代碼來源:Compiler.Type.cs


注:本文中的Mono.Cecil.TypeReference.ContainsGenericParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。