/// <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()); }
/// <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()); }
/// <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()); }