Пример #1
0
        internal UnaryExpression GenUnaryExpression(IScope scope, int maxDepth)
        {
            UnaryExpression ue = new UnaryExpression();
            UnaryOperator   op = _options.UnaryOperators.ChooseRandom(_rand);

            ue.Operator = op;
            Expression expr = GenExpression(scope, maxDepth);

            if (op.Has(OperatorRequirement.NumericOnly) && !expr.IsNumeric)
            {
                expr = new NumericExpression(scope, expr, GenNumericLiteral());
            }
            if (op.Has(OperatorRequirement.RhsNonnegative))
            {
                expr = new NonNegativeExpression(scope, expr);
            }
            if (op.Has(OperatorRequirement.RhsNonzero))
            {
                expr = new NonZeroExpression(scope, expr);
            }
            if (op.Has(OperatorRequirement.LimitedPrecision))
            {
                scope.Require(GlobalFunction.PREC);
            }
            ue.Value = expr;
            return(ue);
        }