Пример #1
0
        private ValueExpression EvaluateUnaryExpression(IExpression expr)
        {
            UnaryExpression unaryExpr = (UnaryExpression)expr;
            ValueExpression valueExpr = Visit(unaryExpr.Operand);

            double result = _context.EvaluateUnary(unaryExpr.OperatorName, valueExpr.Value);

            return(new ValueExpression(result));
        }
Пример #2
0
        private IExpression EvaluateUnaryExpression(IExpression expr)
        {
            UnaryExpression unaryExpr   = (UnaryExpression)expr;
            IExpression     operandExpr = Visit(unaryExpr.Operand);

            if (operandExpr is ValueExpression valueExpr)
            {
                double result = _context.EvaluateUnary(unaryExpr.OperatorName, valueExpr.Value);
                return(new ValueExpression(result));
            }

            return(new UnaryExpression(unaryExpr.OperatorName, operandExpr));
        }