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

            return(ReductionExpressionGenerator.BuildConversionCall(method, UnaryParameter, Type));
        }
Example #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));
        }
Example #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());
        }
Example #5
0
 /// <inheritdoc/>
 public override Expression Reduce()
 {
     Contract.Ensures(Contract.Result <Expression>() != null);
     return(ReductionExpressionGenerator.BuildConversionCall(MathSinMethod, UnaryParameter, Type));
 }