예제 #1
0
        private bool VerifyArithmetic(ContextNode context)
        {
            var parser = context.Parser;

            ResolveLiteralOperands(context);

            if (left.ExpressionReturnType.IsNumericType() && right.ExpressionReturnType.IsNumericType())
            {
                bool comparable = false;
                if (left.IsAssignableTo(right))
                {
                    type       = right.ExpressionReturnType;
                    comparable = true;
                }
                else if (right.IsAssignableTo(left))
                {
                    type       = left.ExpressionReturnType;
                    comparable = true;
                }

                if (comparable && BinaryOperatorType == BinaryOperatorNodeType.Modulus)
                {
                    comparable = left.ExpressionReturnType.IsIntegerType() && right.ExpressionReturnType.IsIntegerType();
                }

                return(comparable);
            }

            if (BinaryOperatorType == BinaryOperatorNodeType.Addition)
            {
                type = parser.String;
                return(left.ExpressionReturnType.IsStringType() || right.ExpressionReturnType.IsStringType());
            }

            return(false);
        }