コード例 #1
0
        internal string GetFullName(NamespaceDefinitionHandle handle)
        {
            Debug.Assert(!handle.HasFullName); // we should not hit the cache in this case.
            NamespaceData data = GetNamespaceData(handle);

            return(data.FullName);
        }
コード例 #2
0
        /// <summary>
        /// Two distinct namespace handles represent the same namespace if their full names are the same. This
        /// method merges builders corresponding to such namespace handles.
        /// </summary>
        private void PopulateNamespaceTable()
        {
            lock (_namespaceTableAndListLock)
            {
                if (_namespaceTable != null)
                {
                    return;
                }

                var namespaceBuilderTable = new Dictionary <NamespaceDefinitionHandle, NamespaceDataBuilder>();

                // Make sure to add entry for root namespace. The root namespace is special in that even
                // though it might not have types of its own it always has an equivalent representation
                // as a nil handle and we don't want to handle it below as dot-terminated synthetic namespace.
                // We use NamespaceDefinitionHandle.FromIndexOfFullName(0) instead of default(NamespaceDefinitionHandle) so
                // that we never hand back a handle to the user that doesn't have a typeid as that prevents
                // round-trip conversion to Handle and back. (We may discover other handle aliases for the
                // root namespace (any nil/empty string will do), but we need this one to always be there.
                NamespaceDefinitionHandle rootNamespace = NamespaceDefinitionHandle.FromIndexOfFullName(0);
                namespaceBuilderTable.Add(
                    rootNamespace,
                    new NamespaceDataBuilder(
                        rootNamespace,
                        rootNamespace.GetFullName(),
                        String.Empty));

                PopulateTableWithTypeDefinitions(namespaceBuilderTable);
                PopulateTableWithExportedTypes(namespaceBuilderTable);

                Dictionary <string, NamespaceDataBuilder> stringTable;
                MergeDuplicateNamespaces(namespaceBuilderTable, out stringTable);

                List <NamespaceDataBuilder> syntheticNamespaces;
                ResolveParentChildRelationships(stringTable, out syntheticNamespaces);

                var namespaceTable = new Dictionary <NamespaceDefinitionHandle, NamespaceData>();

                foreach (var group in namespaceBuilderTable)
                {
                    // Freeze() caches the result, so any many-to-one relationships
                    // between keys and values will be preserved and efficiently handled.
                    namespaceTable.Add(group.Key, group.Value.Freeze());
                }

                if (syntheticNamespaces != null)
                {
                    foreach (var syntheticNamespace in syntheticNamespaces)
                    {
                        namespaceTable.Add(syntheticNamespace.Handle, syntheticNamespace.Freeze());
                    }
                }

                _namespaceTable = namespaceTable;
                _rootNamespace  = namespaceTable[rootNamespace];
            }
        }
コード例 #3
0
            /// <summary>
            /// Returns a NamespaceData that represents this NamespaceDataBuilder instance. After calling
            /// this method, it is an error to use any methods or fields except Freeze() on the target
            /// NamespaceDataBuilder.
            /// </summary>
            public NamespaceData Freeze()
            {
                // It is not an error to call this function multiple times. We cache the result
                // because it's immutable.
                if (_frozen == null)
                {
                    var namespaces = Namespaces.ToImmutable();
                    Namespaces = null;

                    var typeDefinitions = TypeDefinitions.ToImmutable();
                    TypeDefinitions = null;

                    var exportedTypes = ExportedTypes.ToImmutable();
                    ExportedTypes = null;

                    _frozen = new NamespaceData(Name, FullName, Parent, namespaces, typeDefinitions, exportedTypes);
                }

                return(_frozen);
            }
コード例 #4
0
 internal NamespaceDefinition(NamespaceData data)
 {
     Debug.Assert(data != null);
     _data = data;
 }
コード例 #5
0
ファイル: NamespaceCache.cs プロジェクト: johnhhm/corefx
            /// <summary>
            /// Returns a NamespaceData that represents this NamespaceDataBuilder instance. After calling
            /// this method, it is an error to use any methods or fields except Freeze() on the target 
            /// NamespaceDataBuilder.
            /// </summary>
            public NamespaceData Freeze()
            {
                // It is not an error to call this function multiple times. We cache the result
                // because it's immutable.
                if (_frozen == null)
                {
                    var namespaces = Namespaces.ToImmutable();
                    Namespaces = null;

                    var typeDefinitions = TypeDefinitions.ToImmutable();
                    TypeDefinitions = null;

                    var exportedTypes = ExportedTypes.ToImmutable();
                    ExportedTypes = null;

                    _frozen = new NamespaceData(Name, FullName, Parent, namespaces, typeDefinitions, exportedTypes);
                }

                return _frozen;
            }
コード例 #6
0
ファイル: NamespaceCache.cs プロジェクト: johnhhm/corefx
        /// <summary>
        /// Two distinct namespace handles represent the same namespace if their full names are the same. This
        /// method merges builders corresponding to such namespace handles.
        /// </summary>
        private void PopulateNamespaceTable()
        {
            lock (_namespaceTableAndListLock)
            {
                if (_namespaceTable != null)
                {
                    return;
                }

                var namespaceBuilderTable = new Dictionary<NamespaceDefinitionHandle, NamespaceDataBuilder>();

                // Make sure to add entry for root namespace. The root namespace is special in that even
                // though it might not have types of its own it always has an equivalent representation
                // as a nil handle and we don't want to handle it below as dot-terminated synthetic namespace.
                // We use NamespaceDefinitionHandle.FromIndexOfFullName(0) instead of default(NamespaceDefinitionHandle) so
                // that we never hand back a handle to the user that doesn't have a typeid as that prevents
                // round-trip conversion to Handle and back. (We may discover other handle aliases for the
                // root namespace (any nil/empty string will do), but we need this one to always be there.
                NamespaceDefinitionHandle rootNamespace = NamespaceDefinitionHandle.FromFullNameOffset(0);
                namespaceBuilderTable.Add(
                    rootNamespace,
                    new NamespaceDataBuilder(
                        rootNamespace,
                        rootNamespace.GetFullName(),
                        String.Empty));

                PopulateTableWithTypeDefinitions(namespaceBuilderTable);
                PopulateTableWithExportedTypes(namespaceBuilderTable);

                Dictionary<string, NamespaceDataBuilder> stringTable;
                MergeDuplicateNamespaces(namespaceBuilderTable, out stringTable);

                List<NamespaceDataBuilder> syntheticNamespaces;
                ResolveParentChildRelationships(stringTable, out syntheticNamespaces);

                var namespaceTable = new Dictionary<NamespaceDefinitionHandle, NamespaceData>();

                foreach (var group in namespaceBuilderTable)
                {
                    // Freeze() caches the result, so any many-to-one relationships
                    // between keys and values will be preserved and efficiently handled.
                    namespaceTable.Add(group.Key, group.Value.Freeze());
                }

                if (syntheticNamespaces != null)
                {
                    foreach (var syntheticNamespace in syntheticNamespaces)
                    {
                        namespaceTable.Add(syntheticNamespace.Handle, syntheticNamespace.Freeze());
                    }
                }

                _namespaceTable = namespaceTable;
                _rootNamespace = namespaceTable[rootNamespace];
            }
        }
コード例 #7
0
 internal NamespaceDefinition(NamespaceData data)
 {
     DebugCorlib.Assert(data != null);
     this.data = data;
 }