Пример #1
0
        /// <summary>
        /// Try to compare the lhs and rhs. Throws and exception if comparison returns null. Returns -1/0/+1 otherwise.
        /// </summary>
        public static int Compare(ComparisonStorage /*!*/ comparisonStorage, object lhs, object rhs)
        {
            var compare = comparisonStorage.CompareSite;

            var result = compare.Target(compare, lhs, rhs);

            if (result != null)
            {
                return(Protocols.ConvertCompareResult(comparisonStorage, result));
            }
            else
            {
                throw RubyExceptions.MakeComparisonError(comparisonStorage.Context, lhs, rhs);
            }
        }
Пример #2
0
        /// <summary>
        /// Try to compare the lhs and rhs. Throws and exception if comparison returns null. Returns -1/0/+1 otherwise.
        /// </summary>
        public static int Compare(
            BinaryOpStorage /*!*/ comparisonStorage,
            BinaryOpStorage /*!*/ lessThanStorage,
            BinaryOpStorage /*!*/ greaterThanStorage,
            object lhs, object rhs)
        {
            var compare = comparisonStorage.GetCallSite("<=>");

            var result = compare.Target(compare, lhs, rhs);

            if (result != null)
            {
                return(Protocols.ConvertCompareResult(lessThanStorage, greaterThanStorage, result));
            }
            else
            {
                throw RubyExceptions.MakeComparisonError(comparisonStorage.Context, lhs, rhs);
            }
        }