Example #1
0
        private static TypeMap GetTypeMap(Symbol member)
        {
            var typeParameters = member.GetMemberTypeParameters();

            return(typeParameters.IsEmpty ?
                   null :
                   new TypeMap(
                       typeParameters,
                       IndexedTypeParameterSymbol.Take(member.GetMemberArity()),
                       true));
        }
Example #2
0
        private static void GrowPool(int count)
        {
            var initialPool = s_parameterPool;

            while (count > initialPool.Length)
            {
                var newPoolSize = ((count + 0x0F) & ~0xF); // grow in increments of 16
                var newPool     = new TypeParameterSymbol[newPoolSize];

                Array.Copy(initialPool, newPool, initialPool.Length);

                for (int i = initialPool.Length; i < newPool.Length; i++)
                {
                    newPool[i] = new IndexedTypeParameterSymbol(i);
                }

                Interlocked.CompareExchange(ref s_parameterPool, newPool, initialPool);

                // repeat if race condition occurred and someone else resized the pool before us
                // and the new pool is still too small
                initialPool = s_parameterPool;
            }
        }