Example #1
0
        /// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);
            var method = typeof(Math).GetPublicStaticInvokableMethod("Max", LeftParameter.Type, RightParameter.Type);

            if (null != method)
            {
                return(method.BuildCallExpression(LeftParameter, RightParameter));
            }

            if (LeftParameter.IsMemoryLocationOrConstant() && RightParameter.IsMemoryLocationOrConstant())
            {
                return(GenerateExpression(LeftParameter, RightParameter));
            }

            return(new BlockExpressionBuilder()
                   .AddUsingMemoryLocationsOrConstants(
                       args => new[] { GenerateExpression(args[0], args[1]) },
                       LeftParameter, RightParameter
                       )
                   .GetExpression());
        }
Example #2
0
        /// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);
            var gen = ReductionExpressionGenerator;

            if (
                (typeof(float) == LeftParameter.Type && typeof(float) == RightParameter.Type) ||
                (typeof(double) == LeftParameter.Type && typeof(double) == RightParameter.Type)
                )
            {
                return(gen.BuildConversionCall(MathAtan2DoubleMethod, LeftParameter.Type, LeftParameter, RightParameter));
            }

            if (LeftParameter.IsMemoryLocationOrConstant() && RightParameter.IsMemoryLocationOrConstant())
            {
                return(GenerateAtan2Expressions(LeftParameter, RightParameter));
            }

            return(new BlockExpressionBuilder().AddUsingMemoryLocationsOrConstants(
                       args => new[] { GenerateAtan2Expressions(args[0], args[1]) },
                       LeftParameter, RightParameter
                       ).GetExpression());
        }