Exemple #1
0
        public override int GetHashCode()
        {
            if (mHashCodeCache != null)
            {
                return(mHashCodeCache.Value);
            }

            int res;

            if (this.IsTemporaryVar)
            {
                // 5th bit from the top set
                res = (int)this.TemporaryVarOrMVarIndex + 1;
            }
            else if (this.IsTemporaryMVar)
            {
                // Allow support for up to 256 generic type parameters before
                // hash collisions occur.
                res = (int)((this.TemporaryVarOrMVarIndex + 1) << 8);
            }
            else if (IsPointerType)
            {
                // 3rd bit from the top set
                res = PointerType.GetHashCode() | unchecked ((int)0x20000000);
            }
            else if (IsArrayType)
            {
                // 2nd bit from the top set
                res = ArrayType.GetHashCode() | unchecked ((int)0x40000000);
            }
            else
            {
                // The OR at the end is to ensure that this hash code can never conflict with
                // any of the above.
                // Top bit set
                res = Namespace.GetHashCode() ^ Name.GetHashCode() ^ GenericParameters.GetHashCode() | unchecked ((int)0x80000000);
            }

            mHashCodeCache = res;
            return(mHashCodeCache.Value);
        }