/// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);
            var method = typeof(decimal) == Type
                ? MathFloorDecimalMethod
                : MathFloorDoubleMethod;

            return(ReductionExpressionGenerator.BuildConversionCall(method, UnaryParameter, Type));
        }
Exemple #2
0
 /// <inheritdoc/>
 public override Expression Reduce()
 {
     Contract.Ensures(Contract.Result <Expression>() != null);
     return(ReductionExpressionGenerator.BuildConversionCall(
                MathLogMethod,
                Type,
                LeftParameter,
                RightParameter));
 }
        /// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);

            // TODO: should there be an optimization option?
            var squareExpression = UnaryParameter as SquareExpression;

            if (squareExpression != null)
            {
                return(squareExpression.UnaryParameter);
            }

            return(ReductionExpressionGenerator.BuildConversionCall(MathSqrtMethod, UnaryParameter, Type));
        }
Exemple #4
0
        /// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);
            var method = typeof(Math).GetPublicStaticInvokableMethod("Abs", Type);

            if (null != method)
            {
                return(ReductionExpressionGenerator.BuildConversionCall(method, UnaryParameter, Type));
            }

            if (UnaryParameter.IsMemoryLocationOrConstant())
            {
                return(GenerateExpression(UnaryParameter));
            }

            return(new BlockExpressionBuilder()
                   .AddUsingMemoryLocationOrConstant(
                       local => new[] { GenerateExpression(local) }, UnaryParameter)
                   .GetExpression());
        }
Exemple #5
0
 /// <inheritdoc/>
 public override Expression Reduce()
 {
     Contract.Ensures(Contract.Result <Expression>() != null);
     return(ReductionExpressionGenerator.BuildConversionCall(MathSinMethod, UnaryParameter, Type));
 }