TorqueScript
0.2
|
The interpreter class represents a high level instance of the TorqueScript interpreter. It is where execution control flow begins. More...
#include <interpreter.hpp>
Public Member Functions | |
Interpreter (const InterpreterConfiguration &config) | |
Constructs a new interpreter with the specified configuration. More... | |
CodeBlock * | compile (const std::string &input) |
Ask the interpreter to compile the input string and return the resulting CodeBlock. More... | |
void | evaluate (const std::string &input, std::shared_ptr< ExecutionState > state=nullptr) |
void | execute (const std::string &path, std::shared_ptr< ExecutionState > state=nullptr) |
std::shared_ptr< ExecutionState > | getExecutionState () |
std::shared_ptr< ConsoleObject > | initializeConsoleObjectTree (ObjectInstantiationDescriptor &descriptor) |
Initializes the tree of objects described by the provided descriptor. More... | |
template<typename classType > | |
void | registerConsoleObjectType () |
Global Variables | |
These functions handle getting and setting global variables within the context of an interpreter. | |
void | setGlobal (const std::size_t name, StoredValue value) |
void | setGlobal (const std::string &name, StoredValue value) |
StoredValue * | getGlobal (const std::string &name) |
Retrieves a global variable by string. More... | |
StoredValue * | getGlobal (const std::size_t name) |
Retrieves a global variable by string ID. More... | |
Functions | |
These functions handle management of functions registered in the interpreter. | |
void | addFunction (std::shared_ptr< Function > function) |
Registers a new function to the interpreter. More... | |
std::shared_ptr< Function > | getFunction (const std::string &space, const std::string &name) |
std::shared_ptr< Function > | getFunctionParent (Function *function) |
FunctionRegistry * | findFunctionRegistry (const std::string packageName) |
void | addFunctionRegistry (const std::string &packageName) |
void | activateFunctionRegistry (const std::string &packageName) |
void | deactivateFunctionRegistry (const std::string &packageName) |
void | removeFunctionRegistry (const std::string &packageName) |
Public Attributes | |
ConsoleObjectRegistry | mConsoleObjectRegistry |
The ConsoleObjectRegistry associated with this interpreter. It is used to store all ConsoleObject instances associated with the interpreter. | |
StringTable | mStringTable |
The string table associated with this interpreter. | |
const InterpreterConfiguration | mConfig |
The interpreter configuration. | |
The interpreter class represents a high level instance of the TorqueScript interpreter. It is where execution control flow begins.
TorqueScript::Interpreter::Interpreter | ( | const InterpreterConfiguration & | config | ) |
Constructs a new interpreter with the specified configuration.
config | The configuration to initialize a new interpreter with. |
void TorqueScript::Interpreter::addFunction | ( | std::shared_ptr< Function > | function | ) |
Registers a new function to the interpreter.
function | The function object to register to the interpreter. |
CodeBlock* TorqueScript::Interpreter::compile | ( | const std::string & | input | ) |
Ask the interpreter to compile the input string and return the resulting CodeBlock.
input | The string input containing the TorqueScript program. |
StoredValue* TorqueScript::Interpreter::getGlobal | ( | const std::size_t | name | ) |
Retrieves a global variable by string ID.
name | The string ID representing the global variable name to lookup. This should be preferred over the lookup by name as this version will be faster. |
StoredValue* TorqueScript::Interpreter::getGlobal | ( | const std::string & | name | ) |
Retrieves a global variable by string.
name | A string containining the name of the variable to retrieve, excluding the $ prefix. |
std::shared_ptr<ConsoleObject> TorqueScript::Interpreter::initializeConsoleObjectTree | ( | ObjectInstantiationDescriptor & | descriptor | ) |
Initializes the tree of objects described by the provided descriptor.
The tree described is walked and all objects along the tree will be initialized, unless any parent is invalid (Ie. bad typename, invalid parameters, etc) at which point that entire branch of the tree is invalidated and not instantiated.
descriptor | The descriptor describing the root of the tree to initialize. |