110 |
context->createScanner(is); |
context->createScanner(is); |
111 |
|
|
112 |
InstrScript_parse(context); |
InstrScript_parse(context); |
113 |
std::cout << "Allocating " << context->globalIntVarCount * sizeof(int) << " bytes of global int VM memory.\n"; |
dmsg(2,("Allocating %d bytes of global int VM memory.\n", context->globalIntVarCount * sizeof(int))); |
114 |
std::cout << "Allocating " << context->globalStrVarCount << " of global VM string variables.\n"; |
dmsg(2,("Allocating %d of global VM string variables.\n", context->globalStrVarCount)); |
115 |
if (!context->globalIntMemory) |
if (!context->globalIntMemory) |
116 |
context->globalIntMemory = new ArrayList<int>(); |
context->globalIntMemory = new ArrayList<int>(); |
117 |
if (!context->globalStrMemory) |
if (!context->globalStrMemory) |
152 |
_requiredMaxStackSizeFor(&*parserCtx->handlers); |
_requiredMaxStackSizeFor(&*parserCtx->handlers); |
153 |
} |
} |
154 |
execCtx->stack.resize(parserCtx->requiredMaxStackSize); |
execCtx->stack.resize(parserCtx->requiredMaxStackSize); |
155 |
std::cout << "Created VM exec context with " |
dmsg(2,("Created VM exec context with %d bytes VM stack size.\n", |
156 |
<< parserCtx->requiredMaxStackSize * sizeof(ExecContext::StackFrame) |
parserCtx->requiredMaxStackSize * sizeof(ExecContext::StackFrame))); |
|
<< " bytes VM stack size.\n"; |
|
157 |
//printf("execCtx=0x%lx\n", (uint64_t)execCtx); |
//printf("execCtx=0x%lx\n", (uint64_t)execCtx); |
158 |
const int polySize = parserCtx->polyphonicIntVarCount; |
const int polySize = parserCtx->polyphonicIntVarCount; |
159 |
execCtx->polyphonicIntMemory.resize(polySize); |
execCtx->polyphonicIntMemory.resize(polySize); |
160 |
memset(&execCtx->polyphonicIntMemory[0], 0, polySize * sizeof(int)); |
memset(&execCtx->polyphonicIntMemory[0], 0, polySize * sizeof(int)); |
161 |
|
|
162 |
std::cout << "Allocated " << polySize * sizeof(int) |
dmsg(2,("Allocated %d bytes polyphonic memory.\n", polySize * sizeof(int))); |
|
<< " bytes polyphonic memory.\n"; |
|
163 |
return execCtx; |
return execCtx; |
164 |
} |
} |
165 |
|
|
198 |
return VMExecStatus_t(VM_EXEC_NOT_RUNNING | VM_EXEC_ERROR); |
return VMExecStatus_t(VM_EXEC_NOT_RUNNING | VM_EXEC_ERROR); |
199 |
} |
} |
200 |
|
|
201 |
|
// a ParserContext object is always tied to exactly one ScriptVM object |
202 |
|
assert(m_parserContext->functionProvider == this); |
203 |
|
|
204 |
ExecContext* ctx = dynamic_cast<ExecContext*>(execContex); |
ExecContext* ctx = dynamic_cast<ExecContext*>(execContex); |
205 |
if (!ctx) { |
if (!ctx) { |
206 |
std::cerr << "Invalid VM exec context.\n"; |
std::cerr << "Invalid VM exec context.\n"; |