Пример #1
0
        public override void Visit(ReturnAST returnStatement)
        {
            if (_returnType.ToString() == Enum.GetName(typeof(Keyword), Keyword.VOID).ToLower() &&
                returnStatement.ReturnExpr != null)
            {
                throw new Exception("Return statement must not be followed by expression because the function has no return type");
            }

            var returnExprType = _exprTypeVisitor.GetAstNodeType(_currentFileName,
                                                                 _currentScopeId, _currentNodePosition,
                                                                 returnStatement.ReturnExpr);

            var subsetOfRetType = _returnType.GetType().IsAssignableFrom(returnExprType.GetType());

            if (!IsSameTypeOrNullPtr(_returnType, returnExprType) && !subsetOfRetType)
            {
                throw new Exception(string.Format("Return type must be of type '{0}', found type '{1}'",
                                                  _returnType, returnExprType.ToString()));
            }
        }
Пример #2
0
 public override void Visit(ReturnAST returnStatement)
 {
 }
Пример #3
0
 public virtual void Visit(ReturnAST returnStatement)
 {
 }