14 |
#include "../common/global_private.h" |
#include "../common/global_private.h" |
15 |
#include "tree.h" |
#include "tree.h" |
16 |
#include "CoreVMFunctions.h" |
#include "CoreVMFunctions.h" |
17 |
|
#include "CoreVMDynVars.h" |
18 |
#include "editor/NkspScanner.h" |
#include "editor/NkspScanner.h" |
19 |
|
|
20 |
#define DEBUG_SCRIPTVM_CORE 0 |
#define DEBUG_SCRIPTVM_CORE 0 |
99 |
m_fnAbs = new CoreVMFunction_abs; |
m_fnAbs = new CoreVMFunction_abs; |
100 |
m_fnRandom = new CoreVMFunction_random; |
m_fnRandom = new CoreVMFunction_random; |
101 |
m_fnNumElements = new CoreVMFunction_num_elements; |
m_fnNumElements = new CoreVMFunction_num_elements; |
102 |
|
m_varRealTimer = new CoreVMDynVar_NKSP_REAL_TIMER; |
103 |
|
m_varPerfTimer = new CoreVMDynVar_NKSP_PERF_TIMER; |
104 |
} |
} |
105 |
|
|
106 |
ScriptVM::~ScriptVM() { |
ScriptVM::~ScriptVM() { |
110 |
delete m_fnAbs; |
delete m_fnAbs; |
111 |
delete m_fnRandom; |
delete m_fnRandom; |
112 |
delete m_fnNumElements; |
delete m_fnNumElements; |
113 |
|
delete m_varRealTimer; |
114 |
|
delete m_varPerfTimer; |
115 |
} |
} |
116 |
|
|
117 |
VMParserContext* ScriptVM::loadScript(const String& s) { |
VMParserContext* ScriptVM::loadScript(const String& s) { |
126 |
context->registerBuiltInConstIntVariables( builtInConstIntVariables() ); |
context->registerBuiltInConstIntVariables( builtInConstIntVariables() ); |
127 |
context->registerBuiltInIntVariables( builtInIntVariables() ); |
context->registerBuiltInIntVariables( builtInIntVariables() ); |
128 |
context->registerBuiltInIntArrayVariables( builtInIntArrayVariables() ); |
context->registerBuiltInIntArrayVariables( builtInIntArrayVariables() ); |
129 |
|
context->registerBuiltInDynVariables( builtInDynamicVariables() ); |
130 |
|
|
131 |
context->createScanner(is); |
context->createScanner(is); |
132 |
|
|
220 |
return std::map<String,VMInt8Array*>(); |
return std::map<String,VMInt8Array*>(); |
221 |
} |
} |
222 |
|
|
223 |
|
std::map<String,VMDynVar*> ScriptVM::builtInDynamicVariables() { |
224 |
|
std::map<String,VMDynVar*> m; |
225 |
|
|
226 |
|
m["$NKSP_PERF_TIMER"] = m_varPerfTimer; |
227 |
|
m["$NKSP_REAL_TIMER"] = m_varRealTimer; |
228 |
|
m["$KSP_TIMER"] = m_varRealTimer; |
229 |
|
|
230 |
|
return m; |
231 |
|
} |
232 |
|
|
233 |
std::map<String,int> ScriptVM::builtInConstIntVariables() { |
std::map<String,int> ScriptVM::builtInConstIntVariables() { |
234 |
return std::map<String,int>(); |
return std::map<String,int>(); |
235 |
} |
} |