示例#1
0
        public override Query VisitAbsExpression(CalcParser.AbsExpressionContext context)
        {
            Query q = Visit(context.expression());

            ResultType type = ResultType.Undefined;

            if (q.ExpectedResult == ResultType.Number)
            {
                type = ResultType.Number;
            }

            return(new Query($"ABS({q})", type));
        }
示例#2
0
        public override Argument VisitAbsExpression(CalcParser.AbsExpressionContext context)
        {
            Argument arg = Visit(context.expression());

            if (arg.IsNull)
            {
                return(Argument.Null);
            }

            if (arg.IsDouble)
            {
                return(new Argument(Math.Abs(arg.ToDouble())));
            }

            throw ArgumentCastException.Create("double", arg);
        }