22 |
class ParserContext; |
class ParserContext; |
23 |
class ExecContext; |
class ExecContext; |
24 |
|
|
25 |
|
/** @brief Core virtual machine for real-time instrument scripts. |
26 |
|
* |
27 |
|
* This is the core of the virtual machine, used for running real-time |
28 |
|
* instrument scripts. The core encompasses the instrument script parser, |
29 |
|
* generalized virtual machine and very generic built-in script functions. |
30 |
|
* Thus this class only provides functionalities which are yet independent |
31 |
|
* of the actual purpose the virtual machine is going to be used for. |
32 |
|
* |
33 |
|
* The actual use case specific functionalites (i.e. MIDI processing) is |
34 |
|
* then implemented by VM classes which are derived from this generalized |
35 |
|
* ScriptVM class. |
36 |
|
* |
37 |
|
* This class is re-entrant safe, but not thread safe. So you can share one |
38 |
|
* instance of this class between multiple (native) threads, but you @b must |
39 |
|
* @b not execute methods of the same class instance simultaniously from |
40 |
|
* different (native) threads. If you want to execute scripts simultaniously |
41 |
|
* multi threaded, then create a separate ScriptVM instance for each |
42 |
|
* (native) thread. Also note that one VMParserContext instance is tied to |
43 |
|
* exactly one ScriptVM instance. So you @b must @b not create a |
44 |
|
* VMParserContext with one ScriptVM instance and run it with a different |
45 |
|
* ScriptVM instance! |
46 |
|
*/ |
47 |
class ScriptVM : public VMFunctionProvider { |
class ScriptVM : public VMFunctionProvider { |
48 |
public: |
public: |
49 |
ScriptVM(); |
ScriptVM(); |
53 |
void dumpParsedScript(VMParserContext* context); |
void dumpParsedScript(VMParserContext* context); |
54 |
VMExecContext* createExecContext(VMParserContext* parserContext); |
VMExecContext* createExecContext(VMParserContext* parserContext); |
55 |
VMExecStatus_t exec(VMParserContext* parserContext, VMExecContext* execContex, VMEventHandler* handler); |
VMExecStatus_t exec(VMParserContext* parserContext, VMExecContext* execContex, VMEventHandler* handler); |
56 |
VMFunction* functionByName(const String& name); |
VMFunction* functionByName(const String& name) OVERRIDE; |
57 |
|
std::map<String,VMIntRelPtr*> builtInIntVariables() OVERRIDE; |
58 |
|
std::map<String,VMInt8Array*> builtInIntArrayVariables() OVERRIDE; |
59 |
|
std::map<String,int> builtInConstIntVariables() OVERRIDE; |
60 |
|
|
61 |
VMParserContext* currentVMParserContext(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) |
VMParserContext* currentVMParserContext(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) |
62 |
VMExecContext* currentVMExecContext(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) |
VMExecContext* currentVMExecContext(); //TODO: should be protected (only usable during exec() calls, intended only for VMFunctions) |
63 |
protected: |
protected: |
|
|
|
64 |
ParserContext* m_parserContext; |
ParserContext* m_parserContext; |
65 |
CoreVMFunction_message fnMessage; |
CoreVMFunction_message fnMessage; |
66 |
CoreVMFunction_exit fnExit; |
CoreVMFunction_exit fnExit; |