Example #1
0
 private Container(GetTypeCoreCache owner, int[] buckets, Entry[] entries, int nextFreeEntry)
 {
     _buckets       = buckets;
     _entries       = entries;
     _nextFreeEntry = nextFreeEntry;
     _owner         = owner;
 }
Example #2
0
 public Container(GetTypeCoreCache owner)
 {
     // Note: This could be done by calling Resize()'s logic but we cannot safely do that as this code path is reached
     // during class construction time and Resize() pulls in enough stuff that we get cyclic cctor warnings from the build.
     _buckets = new int[_initialCapacity];
     for (int i = 0; i < _initialCapacity; i++)
     {
         _buckets[i] = -1;
     }
     _entries       = new Entry[_initialCapacity];
     _nextFreeEntry = 0;
     _owner         = owner;
 }
Example #3
0
        /// <summary>
        /// Helper routine for the more general Module.GetType() family of apis. Also used in typeRef resolution.
        ///
        /// Resolves top-level named types only. No nested types. No constructed types. The input name must not be escaped.
        ///
        /// If a type is not contained or forwarded from the module, this method returns null (does not throw.)
        /// This supports the "throwOnError: false" behavior of Module.GetType(string, bool).
        /// </summary>
        internal RoDefinitionType GetTypeCore(ReadOnlySpan <byte> ns, ReadOnlySpan <byte> name, bool ignoreCase, out Exception e)
        {
            if (ignoreCase)
            {
                throw new NotSupportedException(SR.NotSupported_CaseInsensitive);
            }

            int hashCode = GetTypeCoreCache.ComputeHashCode(name);

            if (!_getTypeCoreCache.TryGet(ns, name, hashCode, out RoDefinitionType type))
            {
                type = GetTypeCoreNoCache(ns, name, out e) ?? new RoExceptionType(ns, name, e);
                _getTypeCoreCache.GetOrAdd(ns, name, hashCode, type); // Type objects are unified independently of this cache so no need to check if we won the race to cache this Type
            }

            if (type is RoExceptionType exceptionType)
            {
                e = exceptionType.Exception;
                return(null);
            }

            e = null;
            return(type);
        }