Add m3_RunStart(module). Closes #202

extensions
Volodymyr Shymanskyy 3 years ago
parent 5dd8f46d2a
commit 11f813d7ed

@ -647,11 +647,11 @@ _ (ReadLEB_u32 (& functionIndex, & bytes, end));
_catch: return result;
}
M3Result InitStartFunc (IM3Module io_module)
M3Result m3_RunStart (IM3Module io_module)
{
M3Result result = m3Err_none;
if (io_module->startFunction >= 0)
if (io_module and io_module->startFunction >= 0)
{
IM3Function function = & io_module->functions [io_module->startFunction];
@ -750,7 +750,7 @@ M3Result m3_FindFunction (IM3Function * o_function, IM3Runtime i_runtime, cons
// Check if start function needs to be called
if (function and function->module->startFunction) {
result = InitStartFunc (function->module);
result = m3_RunStart (function->module);
if (result)
return result;
}

@ -190,6 +190,9 @@ d_m3ErrorConst (trapStackOverflow, "[trap] stack overflow")
M3Result m3_LoadModule (IM3Runtime io_runtime, IM3Module io_module);
// LoadModule transfers ownership of a module to the runtime. Do not free modules once successfully imported into the runtime
// Calling m3_RunStart is optional
M3Result m3_RunStart (IM3Module i_module);
typedef const void * (* M3RawCall) (IM3Runtime runtime, IM3ImportContext _ctx, uint64_t * _sp, void * _mem);
M3Result m3_LinkRawFunction (IM3Module io_module,

Loading…
Cancel
Save