예제 #1
0
        public int GetHashCode(SizeOfPrototype obj)
        {
            var hash = EnumerableComparer.EmptyHash;

            hash = EnumerableComparer.FoldIntoHashCode(hash, obj.MeasuredType.GetHashCode());
            hash = EnumerableComparer.FoldIntoHashCode(hash, obj.ResultType.GetHashCode());
            return(hash);
        }
예제 #2
0
        public int GetHashCode(LoadPrototype obj)
        {
            var hash = EnumerableComparer.EmptyHash;

            hash = EnumerableComparer.FoldIntoHashCode(hash, obj.ResultType.GetHashCode());
            hash = EnumerableComparer.FoldIntoHashCode(hash, obj.IsVolatile);
            hash = EnumerableComparer.FoldIntoHashCode(hash, obj.Alignment);
            return(hash);
        }
예제 #3
0
        public int GetHashCode(ClrModifierType obj)
        {
            var hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.ElementType);
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.ModifierType);
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.IsRequired);
            return(hashCode);
        }
예제 #4
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            var hashCode = EnumerableComparer.HashEnumerable(Arguments);

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                Target.GetHashCode());
            return(hashCode);
        }
예제 #5
0
        public int GetHashCode(NewDelegatePrototype obj)
        {
            int hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.ResultType);
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.Callee);
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.HasThisArgument);
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.Lookup);
            return(hashCode);
        }
예제 #6
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            var hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, Name);
            foreach (var kvPair in Annotations.OrderBy(pair => pair.Key))
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, kvPair.Key);
                hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, kvPair.Value);
            }
            return(hashCode);
        }
예제 #7
0
        /// <summary>
        /// Computes the hash code for a particular switch flow.
        /// </summary>
        /// <param name="obj">The switch flow to compute a hash code for.</param>
        /// <returns>A hash code.</returns>
        public int GetHashCode(SwitchFlow obj)
        {
            int hashCode = EnumerableComparer.HashUnorderedSet(obj.Cases);

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                obj.DefaultBranch.GetHashCode());
            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                obj.SwitchValue.GetHashCode());
            return(hashCode);
        }
예제 #8
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            int hashCode = EnumerableComparer.EmptyHash;
            int argCount = Arguments.Count;

            for (int i = 0; i < argCount; i++)
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, Arguments[i]);
            }
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, Prototype);
            return(hashCode);
        }
        public int GetHashCode(IndirectCallPrototype obj)
        {
            int hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.ResultType);
            var paramTypes     = obj.ParameterTypes;
            var paramTypeCount = paramTypes.Count;

            for (int i = 0; i < paramTypeCount; i++)
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, paramTypes[i]);
            }
            return(hashCode);
        }
예제 #10
0
        public int GetHashCode(InstructionPattern obj)
        {
            int hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                obj.PrototypeKind.GetHashCode());

            var numbering = new Dictionary <Symbol, int>();

            foreach (var arg in obj.PrototypeArgs)
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(
                    hashCode,
                    HashArg(arg, numbering));
            }

            return(hashCode);
        }
예제 #11
0
        /// <summary>
        /// Computes a hash code for an instruction.
        /// </summary>
        /// <param name="obj">The instruction to hash.</param>
        /// <returns>A hash code.</returns>
        public int GetHashCode(Instruction obj)
        {
            // Compute a hash code for the instruction based on its
            // prototype and the value numbers of its arguments.
            // TODO: this implementation of GetHashCode will always produce
            // a collision for non-copyable instructions (e.g., calls).
            // Is there something we can do about this?

            int hashCode = EnumerableComparer.EmptyHash;
            int argCount = obj.Arguments.Count;

            for (int i = 0; i < argCount; i++)
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(
                    hashCode,
                    numbering.GetNumber(obj.Arguments[i]));
            }
            hashCode = EnumerableComparer.FoldIntoHashCode(hashCode, obj.Prototype);
            return(hashCode);
        }
예제 #12
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            int hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                Name.GetHashCode());

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                PropertyType.GetHashCode());

            foreach (var type in IndexerParameterTypes)
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(
                    hashCode,
                    type.GetHashCode());
            }
            return(hashCode);
        }
예제 #13
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            int hashCode = EnumerableComparer.EmptyHash;

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                Name.GetHashCode());

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                GenericParameterCount);

            hashCode = EnumerableComparer.FoldIntoHashCode(
                hashCode,
                ReturnType.GetHashCode());

            foreach (var type in ParameterTypes)
            {
                hashCode = EnumerableComparer.FoldIntoHashCode(
                    hashCode,
                    type.GetHashCode());
            }
            return(hashCode);
        }
예제 #14
0
        private static int HashArg(LNode argument, Dictionary <Symbol, int> numbering)
        {
            if (argument.IsLiteral)
            {
                return(argument.Value.GetHashCode());
            }
            else if (argument.IsId && argument.HasSpecialName)
            {
                return(argument.Name.GetHashCode());
            }
            else if (argument.IsCall)
            {
                int hashCode = EnumerableComparer.EmptyHash;
                hashCode = EnumerableComparer.FoldIntoHashCode(
                    hashCode,
                    argument.Name.GetHashCode());

                foreach (var arg in argument.Args)
                {
                    hashCode = EnumerableComparer.FoldIntoHashCode(
                        hashCode,
                        HashArg(arg, numbering));
                }
                return(hashCode);
            }
            else
            {
                int number;
                if (!numbering.TryGetValue(argument.Name, out number))
                {
                    number = numbering.Count;
                    numbering[argument.Name] = number;
                }
                return(number);
            }
        }
예제 #15
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            int hashCode = EnumerableComparer.HashUnorderedSet(Values);

            return(EnumerableComparer.FoldIntoHashCode(hashCode, Branch.GetHashCode()));
        }