Esempio n. 1
0
        /// <summary>
        /// Adds a new entry to the table. Thread safety: not thread safe. Expected to be called at the final
        /// object data emission phase from a single thread.
        /// </summary>
        public uint GetIndex(ISymbolNode symbol, int delta = 0)
        {
#if DEBUG
            if (_nodeFactory.MarkingComplete)
            {
                var node = symbol as ILCompiler.DependencyAnalysisFramework.DependencyNodeCore <NodeFactory>;
                if (node != null)
                {
                    Debug.Assert(node.Marked);
                }
            }
#endif

            SymbolAndDelta key = new SymbolAndDelta(symbol, delta);

            uint index;
            if (!_insertedSymbolsDictionary.TryGetValue(key, out index))
            {
                index = (uint)_insertedSymbols.Count;
                _insertedSymbolsDictionary[key] = index;
                _insertedSymbols.Add(key);
            }

            return(index);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a new entry to the table. Thread safety: not thread safe. Expected to be called at the final
        /// object data emission phase from a single thread.
        /// </summary>
        public uint GetIndex(ISymbolNode symbol, int delta = 0)
        {
            SymbolAndDelta key = new SymbolAndDelta(symbol, delta);

            uint index;

            if (!_insertedSymbolsDictionary.TryGetValue(key, out index))
            {
                index = (uint)_insertedSymbols.Count;
                _insertedSymbolsDictionary[key] = index;
                _insertedSymbols.Add(key);
            }

            return(index);
        }