Ejemplo n.º 1
0
        void WriteMethod(string name, DmdMethodSignature sig, IList <DmdType> genericArguments, bool isMethod)
        {
            var flags = GetTypeFlags(true) | TypeFlags.FnPtrIsIntPtr;

            FormatTypeName(sig.ReturnType, flags);
            writer.Append(' ');
            writer.Append(name);
            if (genericArguments != null)
            {
                WriteMethodGenericArguments(genericArguments, flags);
            }
            if (isMethod || sig.GetParameterTypes().Count != 0 || sig.GetVarArgsParameterTypes().Count != 0)
            {
                if (!isMethod)
                {
                    writer.Append(' ');
                }
                writer.Append(isMethod ? '(' : '[');
                WriteParameters(sig.GetParameterTypes(), flags);
                if ((sig.Flags & DmdSignatureCallingConvention.Mask) == DmdSignatureCallingConvention.VarArg)
                {
                    if (sig.GetParameterTypes().Count > 0)
                    {
                        writer.Append(", ");
                    }
                    writer.Append("...");
                }
                writer.Append(isMethod ? ')' : ']');
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the hash code of a method signature
        /// </summary>
        /// <param name="a">Method signature</param>
        /// <returns></returns>
        public int GetHashCode(DmdMethodSignature a)
        {
            if ((object)a == null)
            {
                return(0);
            }
            int hc = (int)a.Flags;

            hc ^= a.GenericParameterCount;
            if (!DontCompareReturnType)
            {
                hc ^= GetHashCode(a.ReturnType);
            }
            hc ^= GetHashCode(a.GetParameterTypes());
            hc ^= GetHashCode(a.GetVarArgsParameterTypes());
            return(hc);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Compares two method signatures
        /// </summary>
        /// <param name="a">First method signature</param>
        /// <param name="b">Second method signature</param>
        /// <returns></returns>
        public bool Equals(DmdMethodSignature a, DmdMethodSignature b)
        {
            if ((object)a == b)
            {
                return(true);
            }
            if ((object)a == null || (object)b == null)
            {
                return(false);
            }

            return(a.Flags == b.Flags &&
                   a.GenericParameterCount == b.GenericParameterCount &&
                   (DontCompareReturnType || Equals(a.ReturnType, b.ReturnType)) &&
                   Equals(a.GetParameterTypes(), b.GetParameterTypes()) &&
                   Equals(a.GetVarArgsParameterTypes(), b.GetVarArgsParameterTypes()));
        }