|
|
|
@ -286,6 +286,10 @@ M3Result EvaluateExpression (IM3Module i_module, void * o_expressed, u8 i_type
|
|
|
|
|
pc_t m3code = GetPagePC (o->page);
|
|
|
|
|
result = CompileBlock (o, ftype, c_waOp_block);
|
|
|
|
|
|
|
|
|
|
if (not result && o->maxStackSlots >= runtime.numStackSlots) {
|
|
|
|
|
result = m3Err_trapStackOverflow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (not result)
|
|
|
|
|
{
|
|
|
|
|
m3ret_t r = Call (m3code, stack, NULL, d_m3OpDefaultArgs);
|
|
|
|
@ -542,28 +546,32 @@ M3Result m3_LoadModule (IM3Runtime io_runtime, IM3Module io_module)
|
|
|
|
|
{
|
|
|
|
|
M3Result result = m3Err_none;
|
|
|
|
|
|
|
|
|
|
if (not io_module->runtime)
|
|
|
|
|
{
|
|
|
|
|
io_module->runtime = io_runtime;
|
|
|
|
|
M3Memory * memory = & io_runtime->memory;
|
|
|
|
|
if (UNLIKELY(io_module->runtime)) {
|
|
|
|
|
return m3Err_moduleAlreadyLinked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ (InitMemory (io_runtime, io_module));
|
|
|
|
|
_ (InitGlobals (io_module));
|
|
|
|
|
_ (InitDataSegments (memory, io_module));
|
|
|
|
|
_ (InitElements (io_module));
|
|
|
|
|
io_module->runtime = io_runtime;
|
|
|
|
|
M3Memory * memory = & io_runtime->memory;
|
|
|
|
|
|
|
|
|
|
io_module->next = io_runtime->modules;
|
|
|
|
|
io_runtime->modules = io_module;
|
|
|
|
|
_ (InitMemory (io_runtime, io_module));
|
|
|
|
|
_ (InitGlobals (io_module));
|
|
|
|
|
_ (InitDataSegments (memory, io_module));
|
|
|
|
|
_ (InitElements (io_module));
|
|
|
|
|
|
|
|
|
|
// Start func might use imported functions, which are not liked here yet,
|
|
|
|
|
// so it will be called before a function call is attempted (in m3_FindFuSnction)
|
|
|
|
|
}
|
|
|
|
|
else result = m3Err_moduleAlreadyLinked;
|
|
|
|
|
// Start func might use imported functions, which are not liked here yet,
|
|
|
|
|
// so it will be called before a function call is attempted (in m3_FindFunction)
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
io_module->runtime = NULL;
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
Module_GenerateNames(io_module);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
_catch: return result;
|
|
|
|
|
io_module->next = io_runtime->modules;
|
|
|
|
|
io_runtime->modules = io_module;
|
|
|
|
|
return result; // ok
|
|
|
|
|
|
|
|
|
|
_catch:
|
|
|
|
|
io_module->runtime = NULL;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IM3Global m3_FindGlobal (IM3Module io_module,
|
|
|
|
|