예제 #1
0
        public bool Visit(Unary_Expression expression)
        {
            bool   result       = expression.Internal.Accept <bool>(this);
            QSType operatorType = expression.GetType(this._typeMem);
            QSType internalType = expression.GetInternalType(this._typeMem);

            if (!operatorType.IsCompatible(internalType))
            {
                // type of unary is not compatible with it's expression
                result = false;
                this._errorList.Add(new UnaryOperatorTypeMismatch(internalType, expression.GetOperator(), expression.Line));
            }
            return(result);
        }
예제 #2
0
        public bool Visit(Binary_Expression expression)
        {
            bool result = true;

            result &= expression.Left.Accept <bool>(this);
            result &= expression.Right.Accept <bool>(this);
            QSType exprType  = expression.GetType(this._typeMem);
            QSType leftType  = expression.GetLeftType(this._typeMem);
            QSType rightType = expression.GetRightType(this._typeMem);

            if (!leftType.IsCompatible(rightType))
            {
                this._errorList.Add(new OperatorTypeMismatch(leftType, rightType, expression.GetOperator(),
                                                             expression.Line));
                result = false;
            }

            if (!leftType.IsCompatible(exprType))
            {
                this._errorList.Add(new TypeMismatchError(leftType, rightType, expression.Line));
                result = false;
            }
            return(result);
        }