![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
A class that applies macros in a Node. More...
#include <Executor.hpp>
Public Member Functions | |
MacroExecutor (MacroProcessor *macroprocessor, unsigned debug=0) | |
Construct a new Macro Executor object. | |
virtual | ~MacroExecutor () |
Need a virtual destructor to correctly destory object. | |
virtual bool | applyMacro (Node &node)=0 |
Executes macros in the Node if the Executor can handle it. | |
virtual bool | canHandle (Node &node)=0 |
Checks if the executor can apply a macro on the passed Node. | |
Protected Member Functions | |
const Node * | findNearestMacro (const std::string &name) const |
Find the nearest macro matching a giving name. | |
void | registerMacro (Node &node) |
Registers macros based on their type. | |
bool | isTruthy (const Node &node) |
Check if a node can be evaluated to true. | |
Node | evaluate (Node &node, bool is_not_body) |
Evaluate only the macros. | |
void | unify (const std::unordered_map< std::string, Node > &, Node &, Node *) |
Applies the spread operator. | |
void | throwMacroProcessingError (const std::string &message, const Node &node) |
Throw a macro processing error. | |
bool | applyMacroProxy (Node &node) |
Execute a node, trying to emplace macros calls. | |
bool | isPredefined (const std::string &symbol) |
Check if a given symbol is a predefined macro. | |
Protected Attributes | |
unsigned int | m_debug |
MacroProcessor * | m_macroprocessor |
A class that applies macros in a Node.
Definition at line 27 of file Executor.hpp.
Ark::internal::MacroExecutor::MacroExecutor | ( | MacroProcessor * | macroprocessor, |
unsigned | debug = 0 |
||
) |
Construct a new Macro Executor object.
macroprocessor | |
debug |
Definition at line 7 of file Executor.cpp.
|
virtual |
Need a virtual destructor to correctly destory object.
Definition at line 12 of file Executor.cpp.
|
pure virtual |
Executes macros in the Node if the Executor can handle it.
node | the node that contains a macro |
Implemented in Ark::internal::ConditionalExecutor, Ark::internal::FunctionExecutor, and Ark::internal::SymbolExecutor.
|
protected |
Execute a node, trying to emplace macros calls.
Proxy function for MacroProcessor::applyMacro
node |
Definition at line 45 of file Executor.cpp.
References Ark::internal::MacroProcessor::applyMacro(), and m_macroprocessor.
Referenced by Ark::internal::FunctionExecutor::applyMacro().
|
pure virtual |
Checks if the executor can apply a macro on the passed Node.
node | the node that contains a macro |
Implemented in Ark::internal::ConditionalExecutor, Ark::internal::FunctionExecutor, and Ark::internal::SymbolExecutor.
Evaluate only the macros.
Proxy function for MacroProcessor::evaluate
node | |
is_not_body | true if the method is run on a non-body code (eg a condition of an if-macro) |
Definition at line 30 of file Executor.cpp.
References Ark::internal::MacroProcessor::evaluate(), and m_macroprocessor.
Referenced by Ark::internal::ConditionalExecutor::applyMacro(), and Ark::internal::FunctionExecutor::applyMacro().
|
protected |
Find the nearest macro matching a giving name.
Proxy function for MacroProcessor::findNearestMacro
name |
Definition at line 15 of file Executor.cpp.
References Ark::internal::MacroProcessor::findNearestMacro(), and m_macroprocessor.
Referenced by Ark::internal::FunctionExecutor::applyMacro(), and Ark::internal::SymbolExecutor::applyMacro().
|
protected |
Check if a given symbol is a predefined macro.
Proxy function for MacroProcessor::isPredefined
symbol |
Definition at line 50 of file Executor.cpp.
References Ark::internal::MacroProcessor::isPredefined(), and m_macroprocessor.
Referenced by Ark::internal::FunctionExecutor::applyMacro().
|
protected |
Check if a node can be evaluated to true.
Proxy function for MacroProcessor::isTruthy
node |
Definition at line 25 of file Executor.cpp.
References Ark::internal::MacroProcessor::isTruthy(), and m_macroprocessor.
Referenced by Ark::internal::ConditionalExecutor::applyMacro().
|
protected |
Registers macros based on their type.
Validate macros and register them by their name Proxy function for MacroProcessor::registerMacro
node | A node of type Macro |
Definition at line 20 of file Executor.cpp.
References m_macroprocessor, and Ark::internal::MacroProcessor::registerMacro().
Referenced by Ark::internal::ConditionalExecutor::applyMacro().
|
protected |
Throw a macro processing error.
Proxy function for MacroProcessor::throwMacroProcessingError
message | the error |
node | the node in which there is an error |
Definition at line 40 of file Executor.cpp.
References m_macroprocessor, and Ark::internal::MacroProcessor::throwMacroProcessingError().
Referenced by Ark::internal::FunctionExecutor::applyMacro().
|
protected |
Applies the spread operator.
Proxy function for MacroProcessor::unify
Definition at line 35 of file Executor.cpp.
Referenced by Ark::internal::FunctionExecutor::applyMacro().
|
protected |
Definition at line 61 of file Executor.hpp.
|
protected |
Definition at line 62 of file Executor.hpp.
Referenced by applyMacroProxy(), evaluate(), findNearestMacro(), isPredefined(), isTruthy(), Ark::internal::ConditionalExecutor::MacroExecutor(), registerMacro(), and throwMacroProcessingError().