From 668cc37097ccd0adb2f78266270f43fdcd780c89 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Tue, 10 Sep 2024 10:02:26 +0800 Subject: [PATCH] Catch-handle expression AST source file implementation. --- .../ast/expression/CatchHandleExpression.hpp | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 include/ast/expression/CatchHandleExpression.hpp diff --git a/include/ast/expression/CatchHandleExpression.hpp b/include/ast/expression/CatchHandleExpression.hpp new file mode 100644 index 0000000..4f5b1c9 --- /dev/null +++ b/include/ast/expression/CatchHandleExpression.hpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 - Nathanne Isip + * This file is part of Zhivo. + * + * Zhivo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * Zhivo is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Zhivo. If not, see . + */ + +#ifndef ZHIVO_AST_EXPR_CATCH_HANDLE_HPP +#define ZHIVO_AST_EXPR_CATCH_HANDLE_HPP + +#include +#include +#include + +#include +#include + +class CatchHandleExpression : public ASTNode { +private: + std::unique_ptr catchBlock; + std::unique_ptr handleBlock; + std::unique_ptr handler; + std::unique_ptr finalBlock; + +public: + explicit CatchHandleExpression( + std::unique_ptr _address, + std::unique_ptr _catchBlock, + std::unique_ptr _handleBlock, + std::unique_ptr _handler, + std::unique_ptr _finalBlock + ) : catchBlock(std::move(_catchBlock)), + handleBlock(std::move(_handleBlock)), + handler(std::move(_handler)), + finalBlock(std::move(_finalBlock)) { + this->address = std::move(_address); + } + + [[nodiscard]] DynamicObject visit(SymbolTable& symbols) override; +}; + +#endif