ArkScript
A small, fast, functional and scripting language for video games
Pass.hpp
Go to the documentation of this file.
1/**
2 * @file Pass.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief Interface for a compiler pass (take in an AST, output an AST)
5 * @date 2024-07-21
6 *
7 * @copyright Copyright (c) 2024-2025
8 *
9 */
10#ifndef ARK_COMPILER_PASS_HPP
11#define ARK_COMPILER_PASS_HPP
12
13#include <Ark/Platform.hpp>
15#include <Ark/Logger.hpp>
16
17namespace Ark::internal
18{
19 /**
20 * @brief An interface to describe compiler passes
21 */
23 {
24 public:
25 /**
26 * @brief Construct a new Pass object
27 *
28 * @param name the pass name, used for logging
29 * @param debug_level debug level
30 */
31 Pass(std::string name, unsigned debug_level);
32
33 virtual ~Pass() = default;
34
35 /**
36 * @brief Start processing the given AST
37 * @param ast
38 */
39 virtual void process(const Node& ast) = 0;
40
41 /**
42 * @brief Output of the compiler pass
43 *
44 * @return const Node& the modified AST
45 */
46 [[nodiscard]] virtual const Node& ast() const noexcept = 0;
47
48 protected:
49 Logger m_logger;
50 };
51}
52
53#endif // ARK_COMPILER_PASS_HPP
Internal logger.
#define ARK_API
Definition Module.hpp:28
AST node used by the parser, optimizer and compiler.
ArkScript configuration macros.
A node of an Abstract Syntax Tree for ArkScript.
Definition Node.hpp:30
An interface to describe compiler passes.
Definition Pass.hpp:23
virtual const Node & ast() const noexcept=0
Output of the compiler pass.
virtual void process(const Node &ast)=0
Start processing the given AST.
virtual ~Pass()=default