Пример #1
0
        public override bool CheckType(QLTypeErrors typeErrors)
        {
            if (!base.CheckType(typeErrors))
            {
                return(false);
            }

            if (!LeftExpression.GetResultType().IsCompatibleWith(new QInt()) ||
                !RightExpression.GetResultType().IsCompatibleWith(new QInt()))
            {
                typeErrors.ReportError(new QLTypeError(
                                           string.Format("Can only apply math on 2 integers! Left value: '{0}', right value '{1}'",
                                                         LeftExpression.GetResultType(), RightExpression.GetResultType()),
                                           LeftExpression.TokenInfo
                                           ));
                return(false);
            }

            return(true);
        }
Пример #2
0
        public override bool CheckType(QLTypeErrors typeErrors)
        {
            if (!base.CheckType(typeErrors))
            {
                return(false);
            }

            if (!(LeftExpression.GetResultType().IsCompatibleWith(new QBool())) ||
                !(RightExpression.GetResultType().IsCompatibleWith(new QBool())))
            {
                typeErrors.ReportError(new QLTypeError(
                                           string.Format("Left -or right expression is not a boolean. Left value: '{0}', right value: '{1}'",
                                                         LeftExpression.GetResultType(), RightExpression.GetResultType()),
                                           TokenInfo = TokenInfo
                                           ));

                return(false);
            }

            return(true);
        }