示例#1
0
        public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
        {
            GenericLookupSignature otherNode = (GenericLookupSignature)other;
            int result = ((int)_runtimeLookupKind).CompareTo((int)otherNode._runtimeLookupKind);

            if (result != 0)
            {
                return(result);
            }

            result = ((int)_fixupKind).CompareTo((int)otherNode._fixupKind);
            if (result != 0)
            {
                return(result);
            }

            if (_typeArgument != null || otherNode._typeArgument != null)
            {
                if (_typeArgument == null)
                {
                    return(-1);
                }
                if (otherNode._typeArgument == null)
                {
                    return(1);
                }

                result = comparer.Compare(_typeArgument, otherNode._typeArgument);
                if (result != 0)
                {
                    return(result);
                }
            }

            if (_fieldArgument != null || otherNode._fieldArgument != null)
            {
                if (_fieldArgument == null)
                {
                    return(-1);
                }
                if (otherNode._fieldArgument == null)
                {
                    return(1);
                }

                result = comparer.Compare(_fieldArgument, otherNode._fieldArgument);
                if (result != 0)
                {
                    return(result);
                }
            }

            if (_methodArgument != null || otherNode._methodArgument != null)
            {
                if (_methodArgument == null)
                {
                    return(-1);
                }
                if (otherNode._methodArgument == null)
                {
                    return(1);
                }

                result = _methodArgument.CompareTo(otherNode._methodArgument, comparer);
                if (result != 0)
                {
                    return(result);
                }
            }

            var contextAsMethod      = _methodContext.Context as MethodDesc;
            var otherContextAsMethod = otherNode._methodContext.Context as MethodDesc;

            if (contextAsMethod != null || otherContextAsMethod != null)
            {
                if (contextAsMethod == null)
                {
                    return(-1);
                }
                if (otherContextAsMethod == null)
                {
                    return(1);
                }

                return(comparer.Compare(contextAsMethod, otherContextAsMethod));
            }
            else
            {
                return(comparer.Compare(_methodContext.ContextType, otherNode._methodContext.ContextType));
            }
        }
        public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
        {
            GenericLookupSignature otherNode = (GenericLookupSignature)other;
            int result = _runtimeLookupKind.CompareTo(otherNode._runtimeLookupKind);

            if (result != 0)
            {
                return(result);
            }

            result = _fixupKind.CompareTo(otherNode._fixupKind);
            if (result != 0)
            {
                return(result);
            }

            if (_typeArgument != null || otherNode._typeArgument != null)
            {
                if (_typeArgument == null)
                {
                    return(-1);
                }
                if (otherNode._typeArgument == null)
                {
                    return(1);
                }

                result = comparer.Compare(_typeArgument, otherNode._typeArgument);
                if (result != 0)
                {
                    return(result);
                }
            }

            if (_fieldArgument != null || otherNode._fieldArgument != null)
            {
                if (_fieldArgument == null)
                {
                    return(-1);
                }
                if (otherNode._fieldArgument == null)
                {
                    return(1);
                }

                result = comparer.Compare(_fieldArgument, otherNode._fieldArgument);
                if (result != 0)
                {
                    return(result);
                }
            }

            if (_methodArgument != null || otherNode._methodArgument != null)
            {
                if (_methodArgument == null)
                {
                    return(-1);
                }
                if (otherNode._methodArgument == null)
                {
                    return(1);
                }

                result = _methodArgument.CompareTo(otherNode._methodArgument, comparer);
                if (result != 0)
                {
                    return(result);
                }
            }

            result = comparer.Compare(_methodContext.ContextMethod, otherNode._methodContext.ContextMethod);
            if (result != 0)
            {
                return(result);
            }

            return(_signatureContext.CompareTo(otherNode._signatureContext, comparer));
        }