Пример #1
0
 private static ImmutableDictionary<SpecialType, QualifiedTypeSignature> GetTypeSignatures()
 {
     var systemNamespace = new QualifiedTypeSignature(null, "System");
     var builder = ImmutableDictionary.CreateBuilder<SpecialType, QualifiedTypeSignature>();
     builder.Add(SpecialType.System_Void, new QualifiedTypeSignature(systemNamespace, "Void"));
     builder.Add(SpecialType.System_Boolean, new QualifiedTypeSignature(systemNamespace, "Boolean"));
     builder.Add(SpecialType.System_Char, new QualifiedTypeSignature(systemNamespace, "Char"));
     builder.Add(SpecialType.System_SByte, new QualifiedTypeSignature(systemNamespace, "SByte"));
     builder.Add(SpecialType.System_Byte, new QualifiedTypeSignature(systemNamespace, "Byte"));
     builder.Add(SpecialType.System_Int16, new QualifiedTypeSignature(systemNamespace, "Int16"));
     builder.Add(SpecialType.System_UInt16, new QualifiedTypeSignature(systemNamespace, "UInt16"));
     builder.Add(SpecialType.System_Int32, new QualifiedTypeSignature(systemNamespace, "Int32"));
     builder.Add(SpecialType.System_UInt32, new QualifiedTypeSignature(systemNamespace, "UInt32"));
     builder.Add(SpecialType.System_Int64, new QualifiedTypeSignature(systemNamespace, "Int64"));
     builder.Add(SpecialType.System_UInt64, new QualifiedTypeSignature(systemNamespace, "UInt64"));
     builder.Add(SpecialType.System_Single, new QualifiedTypeSignature(systemNamespace, "Single"));
     builder.Add(SpecialType.System_Double, new QualifiedTypeSignature(systemNamespace, "Double"));
     builder.Add(SpecialType.System_String, new QualifiedTypeSignature(systemNamespace, "String"));
     builder.Add(SpecialType.System_Object, new QualifiedTypeSignature(systemNamespace, "Object"));
     builder.Add(SpecialType.System_Decimal, new QualifiedTypeSignature(systemNamespace, "Decimal"));
     builder.Add(SpecialType.System_IntPtr, new QualifiedTypeSignature(systemNamespace, "IntPtr"));
     builder.Add(SpecialType.System_UIntPtr, new QualifiedTypeSignature(systemNamespace, "UIntPtr"));
     builder.Add(SpecialType.System_TypedReference, new QualifiedTypeSignature(systemNamespace, "TypedReference"));
     builder.Add(SpecialType.System_Nullable_T, new QualifiedTypeSignature(systemNamespace, "Nullable"));
     return builder.ToImmutable();
 }
Пример #2
0
        private static ImmutableDictionary <SpecialType, QualifiedTypeSignature> GetTypeSignatures()
        {
            var systemNamespace = new QualifiedTypeSignature(null, "System");
            var builder         = ImmutableDictionary.CreateBuilder <SpecialType, QualifiedTypeSignature>();

            builder.Add(SpecialType.System_Void, new QualifiedTypeSignature(systemNamespace, "Void"));
            builder.Add(SpecialType.System_Boolean, new QualifiedTypeSignature(systemNamespace, "Boolean"));
            builder.Add(SpecialType.System_Char, new QualifiedTypeSignature(systemNamespace, "Char"));
            builder.Add(SpecialType.System_SByte, new QualifiedTypeSignature(systemNamespace, "SByte"));
            builder.Add(SpecialType.System_Byte, new QualifiedTypeSignature(systemNamespace, "Byte"));
            builder.Add(SpecialType.System_Int16, new QualifiedTypeSignature(systemNamespace, "Int16"));
            builder.Add(SpecialType.System_UInt16, new QualifiedTypeSignature(systemNamespace, "UInt16"));
            builder.Add(SpecialType.System_Int32, new QualifiedTypeSignature(systemNamespace, "Int32"));
            builder.Add(SpecialType.System_UInt32, new QualifiedTypeSignature(systemNamespace, "UInt32"));
            builder.Add(SpecialType.System_Int64, new QualifiedTypeSignature(systemNamespace, "Int64"));
            builder.Add(SpecialType.System_UInt64, new QualifiedTypeSignature(systemNamespace, "UInt64"));
            builder.Add(SpecialType.System_Single, new QualifiedTypeSignature(systemNamespace, "Single"));
            builder.Add(SpecialType.System_Double, new QualifiedTypeSignature(systemNamespace, "Double"));
            builder.Add(SpecialType.System_String, new QualifiedTypeSignature(systemNamespace, "String"));
            builder.Add(SpecialType.System_Object, new QualifiedTypeSignature(systemNamespace, "Object"));
            builder.Add(SpecialType.System_Decimal, new QualifiedTypeSignature(systemNamespace, "Decimal"));
            builder.Add(SpecialType.System_IntPtr, new QualifiedTypeSignature(systemNamespace, "IntPtr"));
            builder.Add(SpecialType.System_UIntPtr, new QualifiedTypeSignature(systemNamespace, "UIntPtr"));
            builder.Add(SpecialType.System_TypedReference, new QualifiedTypeSignature(systemNamespace, "TypedReference"));
            builder.Add(SpecialType.System_Nullable_T, new QualifiedTypeSignature(systemNamespace, "Nullable"));
            return(builder.ToImmutable());
        }
Пример #3
0
 internal GenericTypeSignature(QualifiedTypeSignature qualifiedName, ImmutableArray <TypeSignature> typeArguments)
 {
     Debug.Assert(qualifiedName != null);
     Debug.Assert(!typeArguments.IsDefault);
     QualifiedName = qualifiedName;
     TypeArguments = typeArguments;
 }
Пример #4
0
 internal GenericTypeSignature(QualifiedTypeSignature qualifiedName, ImmutableArray<TypeSignature> typeArguments)
 {
     Debug.Assert(qualifiedName != null);
     Debug.Assert(!typeArguments.IsDefault);
     QualifiedName = qualifiedName;
     TypeArguments = typeArguments;
 }
Пример #5
0
        private QualifiedTypeSignature GetNamespace(StringHandle namespaceHandle)
        {
            var namespaceName = _reader.GetString(namespaceHandle);

            if (string.IsNullOrEmpty(namespaceName))
            {
                return(null);
            }
            QualifiedTypeSignature signature = null;
            var parts = namespaceName.Split('.');

            foreach (var part in parts)
            {
                signature = new QualifiedTypeSignature(signature, part);
            }
            return(signature);
        }
Пример #6
0
        private static TypeSignature CreateTypeSignature(
            TypeSignature qualifier,
            string typeName,
            ImmutableArray <TypeSignature> typeArguments,
            ref int typeArgumentOffset)
        {
            int arity;

            typeName = RemoveAritySeparatorIfAny(typeName, out arity);
            var qualifiedName = new QualifiedTypeSignature(qualifier, typeName);

            if (arity == 0)
            {
                return(qualifiedName);
            }
            typeArguments       = ImmutableArray.Create(typeArguments, typeArgumentOffset, arity);
            typeArgumentOffset += arity;
            return(new GenericTypeSignature(qualifiedName, typeArguments));
        }
Пример #7
0
 private TypeSignature ParseTypeName()
 {
     TypeSignature signature = null;
     while (true)
     {
         switch (CurrentToken.Kind)
         {
             case TokenKind.Identifier:
                 {
                     var token = EatToken();
                     var name = token.Text;
                     signature = new QualifiedTypeSignature(signature, name);
                 }
                 break;
             case TokenKind.Keyword:
                 if (signature == null)
                 {
                     // Expand special type keywords (object, int, etc.) to qualified names.
                     // This is only done for the first identifier in a qualified name.
                     var specialType = GetSpecialType(CurrentToken.KeywordKind);
                     if (specialType != SpecialType.None)
                     {
                         EatToken();
                         signature = specialType.GetTypeSignature();
                         Debug.Assert(signature != null);
                     }
                     if (signature != null)
                     {
                         break;
                     }
                 }
                 throw InvalidSignature();
             default:
                 throw InvalidSignature();
         }
         if (CurrentToken.Kind == TokenKind.LessThan)
         {
             var typeArguments = ParseTypeArguments();
             signature = new GenericTypeSignature((QualifiedTypeSignature)signature, typeArguments);
         }
         if (CurrentToken.Kind != TokenKind.Dot)
         {
             return signature;
         }
         EatToken();
     }
 }
Пример #8
0
 private static TypeSignature CreateTypeSignature(
     TypeSignature qualifier,
     string typeName,
     ImmutableArray<TypeSignature> typeArguments,
     ref int typeArgumentOffset)
 {
     int arity;
     typeName = RemoveAritySeparatorIfAny(typeName, out arity);
     var qualifiedName = new QualifiedTypeSignature(qualifier, typeName);
     if (arity == 0)
     {
         return qualifiedName;
     }
     typeArguments = ImmutableArray.Create(typeArguments, typeArgumentOffset, arity);
     typeArgumentOffset += arity;
     return new GenericTypeSignature(qualifiedName, typeArguments);
 }
Пример #9
0
 private QualifiedTypeSignature GetNamespace(StringHandle namespaceHandle)
 {
     var namespaceName = _reader.GetString(namespaceHandle);
     if (string.IsNullOrEmpty(namespaceName))
     {
         return null;
     }
     QualifiedTypeSignature signature = null;
     var parts = namespaceName.Split('.');
     foreach (var part in parts)
     {
         signature = new QualifiedTypeSignature(signature, part);
     }
     return signature;
 }