diff --git a/include/Ark/Compiler/Macros/Pipeline.hpp b/include/Ark/Compiler/Macros/Pipeline.hpp deleted file mode 100644 index c736235bc..000000000 --- a/include/Ark/Compiler/Macros/Pipeline.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @file Pipeline.hpp - * @author Ray John Alovera (rakista112@gmail.com), Alexandre Plateau (lexplt.dev@gmail.com) - * @brief The Chain of Responsibility class for running nodes through MacroExecutors - * @version 1.0 - * @date 2021-05-04 - * - * @copyright Copyright (c) 2021-2024 - * - */ - -#ifndef COMPILER_MACROS_PIPELINE_HPP -#define COMPILER_MACROS_PIPELINE_HPP - -#include -#include - -#include - -namespace Ark::internal -{ - class MacroProcessor; - - /** - * @brief The class that initializes the MacroExecutors - * - */ - class MacroExecutorPipeline - { - public: - MacroExecutorPipeline() = default; - - /** - * @brief Construct a new Macro Executor Pipeline object - * - * @param executors - */ - explicit MacroExecutorPipeline(const std::vector>& executors); - - /** - * @brief Passes node through all MacroExecutors sequentially - * - * @param node node on which to operate - * @param depth - * @return true if a macro was applied - * @return false - */ - bool applyMacro(Node& node, unsigned depth) const; - - private: - std::vector> m_executors; - }; -} - -#endif diff --git a/include/Ark/Compiler/Macros/Processor.hpp b/include/Ark/Compiler/Macros/Processor.hpp index 636ed0c52..2e537239d 100644 --- a/include/Ark/Compiler/Macros/Processor.hpp +++ b/include/Ark/Compiler/Macros/Processor.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -55,7 +55,7 @@ namespace Ark::internal unsigned m_debug; ///< The debug level Node m_ast; ///< The modified AST std::vector m_macros; ///< Handling macros in a scope fashion - MacroExecutorPipeline m_executor_pipeline; + std::vector> m_executors; std::vector m_predefined_macros; ///< Already existing macros, non-keywords, non-builtins std::unordered_map m_defined_functions; diff --git a/src/arkreactor/Compiler/Macros/Pipeline.cpp b/src/arkreactor/Compiler/Macros/Pipeline.cpp deleted file mode 100644 index 25582da7e..000000000 --- a/src/arkreactor/Compiler/Macros/Pipeline.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - -namespace Ark::internal -{ - MacroExecutorPipeline::MacroExecutorPipeline(const std::vector>& executors) : - m_executors(executors) - {} - - bool MacroExecutorPipeline::applyMacro(Node& node, unsigned depth) const - { - for (const std::shared_ptr& executor : m_executors) - { - if (executor->canHandle(node)) - { - if (executor->applyMacro(node, depth)) - return true; - } - } - return false; - } -} diff --git a/src/arkreactor/Compiler/Macros/Processor.cpp b/src/arkreactor/Compiler/Macros/Processor.cpp index cf01f93c6..2da476714 100644 --- a/src/arkreactor/Compiler/Macros/Processor.cpp +++ b/src/arkreactor/Compiler/Macros/Processor.cpp @@ -19,10 +19,9 @@ namespace Ark::internal m_debug(debug) { // create executors pipeline - m_executor_pipeline = MacroExecutorPipeline( - { std::make_shared(this), - std::make_shared(this), - std::make_shared(this) }); + m_executors = { { std::make_shared(this), + std::make_shared(this), + std::make_shared(this) } }; m_predefined_macros = { "symcat", @@ -205,7 +204,15 @@ namespace Ark::internal MaxMacroProcessingDepth), node); - return m_executor_pipeline.applyMacro(node, depth); + for (const auto& executor : m_executors) + { + if (executor->canHandle(node)) + { + if (executor->applyMacro(node, depth)) + return true; + } + } + return false; } void MacroProcessor::unify(const std::unordered_map& map, Node& target, Node* parent, const std::size_t index, const std::size_t unify_depth)