ArkScript
A small, fast, functional and scripting language for video games
Function.hpp
Go to the documentation of this file.
1/**
2 * @file Function.hpp
3 * @author Ray John Alovera ([email protected]), Alexandre Plateau ([email protected])
4 * @brief Executor for List Macros
5 * @date 2021-05-04
6 *
7 * @copyright Copyright (c) 2021-2025
8 *
9 */
10
11#ifndef MACROS_EXECUTORS_LIST_HPP
12#define MACROS_EXECUTORS_LIST_HPP
13
16
17namespace Ark::internal
18{
19 /**
20 * @brief Handles function macros
21 *
22 */
23 class FunctionExecutor final : public MacroExecutor
24 {
25 public:
27
28 /**
29 *
30 * @param node
31 * @param depth depth of the macro processor evaluation
32 * @return true if the applying worked
33 */
34 bool applyMacro(Node& node, unsigned depth) override;
35
36 /**
37 *
38 * @param node
39 * @return true if the executor can handle the given node
40 */
41 [[nodiscard]] bool canHandle(Node& node) override;
42
43 [[nodiscard]] Node macroNode(Node& node) override;
44
45 private:
46 void unify(const std::unordered_map<std::string, Node>& map, Node& target, Node* parent, std::size_t index = 0, std::size_t unify_depth = 0);
47 };
48
49}
50
51#endif
The base class for all MacroExecutors.
AST node used by the parser, optimizer and compiler.
Handles function macros.
Definition Function.hpp:24
bool canHandle(Node &node) override
Definition Function.cpp:11
bool applyMacro(Node &node, unsigned depth) override
Definition Function.cpp:16
Node macroNode(Node &node) override
Returns the macro node that will be expanded.
Definition Function.cpp:90
void unify(const std::unordered_map< std::string, Node > &map, Node &target, Node *parent, std::size_t index=0, std::size_t unify_depth=0)
Definition Function.cpp:98
A class that applies macros in a Node.
Definition Executor.hpp:28
MacroExecutor(MacroProcessor *processor, unsigned debug=0)
Construct a new Macro Executor object.
Definition Executor.cpp:7
A node of an Abstract Syntax Tree for ArkScript.
Definition Node.hpp:30