ArkScript
A small, fast, functional and scripting language for video games
Executor.cpp
Go to the documentation of this file.
2
4
5namespace Ark::internal
6{
7 MacroExecutor::MacroExecutor(MacroProcessor* processor, unsigned debug) :
8 m_debug(debug),
9 m_processor(processor)
10 {}
11
12 const Node* MacroExecutor::findNearestMacro(const std::string& name) const
13 {
14 return m_processor->findNearestMacro(name);
15 }
16
17 void MacroExecutor::applyMacroProxy(Node& node, unsigned depth)
18 {
19 m_processor->applyMacro(node, depth);
20 }
21
23 {
25 }
26
27 bool MacroExecutor::isTruthy(const Node& node) const
28 {
29 return m_processor->isTruthy(node);
30 }
31
32 Node MacroExecutor::evaluate(Node& node, const unsigned depth, const bool is_not_body) const
33 {
34 return m_processor->evaluate(node, depth, is_not_body);
35 }
36
37 void MacroExecutor::throwMacroProcessingError(const std::string& message, const Node& node)
38 {
40 }
41}
The base class for all MacroExecutors.
Handles the macros and their expansion in ArkScript source code.
void applyMacroProxy(Node &node, unsigned depth)
Apply a macro on a given node.
Definition Executor.cpp:17
MacroExecutor(MacroProcessor *processor, unsigned debug=0)
Construct a new Macro Executor object.
Definition Executor.cpp:7
static void throwMacroProcessingError(const std::string &message, const Node &node)
Throw a macro processing error.
Definition Executor.cpp:37
MacroProcessor * m_processor
This is a non-owned pointer.
Definition Executor.hpp:64
Node evaluate(Node &node, unsigned depth, bool is_not_body) const
Evaluate only the macros.
Definition Executor.cpp:32
bool isTruthy(const Node &node) const
Check if a node can be evaluated to true.
Definition Executor.cpp:27
void handleMacroNode(Node &node) const
Registers macros based on their type, expand conditional macros.
Definition Executor.cpp:22
const Node * findNearestMacro(const std::string &name) const
Find the nearest macro matching a giving name.
Definition Executor.cpp:12
The class handling the macros definitions and calls, given an AST.
Definition Processor.hpp:32
Node evaluate(Node &node, unsigned depth, bool is_not_body=false)
Evaluate only the macros.
bool applyMacro(Node &node, unsigned depth)
Apply a macro on a given node.
const Node * findNearestMacro(const std::string &name) const
Find the nearest macro matching a given name.
static bool isTruthy(const Node &node)
Check if a node can be evaluated to true.
static void throwMacroProcessingError(const std::string &message, const Node &node)
Throw a macro processing error.
void handleMacroNode(Node &node)
Registers macros based on their type, expand conditional macros.
Definition Processor.cpp:50
A node of an Abstract Syntax Tree for ArkScript.
Definition Node.hpp:31