Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }