예제 #1
0
        /// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);
            if (UnaryParameter.IsMemoryLocationOrConstant())
            {
                return(CreateExpression(UnaryParameter));
            }

            return(new BlockExpressionBuilder().AddUsingMemoryLocationOrConstant(
                       x => new[] { CreateExpression(x) },
                       UnaryParameter
                       ).GetExpression());
        }
예제 #2
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());
        }
예제 #3
0
        /// <inheritdoc/>
        public override Expression Reduce()
        {
            Contract.Ensures(Contract.Result <Expression>() != null);
            var squareRootExpression = UnaryParameter as SquareRootExpression;

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

            if (UnaryParameter.IsMemoryLocationOrConstant())
            {
                return(ReductionExpressionGenerator.GenerateOrThrow("MULTIPLY", UnaryParameter, UnaryParameter));
            }

            return(new BlockExpressionBuilder().AddUsingMemoryLocationOrConstant(
                       local => new[] { ReductionExpressionGenerator.GenerateOrThrow("MULTIPLY", local, local) },
                       UnaryParameter
                       ).GetExpression());
        }