global parse fix

extensions
Steven Massey 5 years ago
parent 9540e82ae1
commit 8fdd67698f

@ -242,10 +242,6 @@ M3Result InitGlobals (IM3Module io_module)
{
M3Global * g = & io_module->globals [i]; m3log (runtime, "initializing global: %d", i);
// global fp types are coerced to double
if (g->type == c_m3Type_f32)
g->type = c_m3Type_f64;
if (g->initExpr)
{
bytes_t start = g->initExpr;
@ -253,7 +249,7 @@ M3Result InitGlobals (IM3Module io_module)
if (not result)
{
// io_module->globalMemory [i] = initValue;
// io_module->globalMemory [i] = initValue;
}
else break;
}

@ -170,14 +170,14 @@ _ (ParseType_Memory (& io_module->memoryInfo, & i_bytes, i_end));
case c_externalKind_global:
{
i8 waType;
u8 type, mut;
u8 type, mutable;
_ (ReadLEB_i7 (& waType, & i_bytes, i_end));
_ (NormalizeType (& type, waType));
_ (ReadLEB_u7 (& mut, & i_bytes, i_end)); m3log (parse, " global: %s mutable=%d", c_waTypes [type], (u32) mut);
_ (ReadLEB_u7 (& mutable, & i_bytes, i_end)); m3log (parse, " global: %s mutable=%d", c_waTypes [type], (u32) mutable);
IM3Global global;
_ (Module_AddGlobal (io_module, & global, type, mut, true /* isImport */));
_ (Module_AddGlobal (io_module, & global, type, mutable, true /* isImport */));
global->import = import;
import = clearImport;
}
@ -402,13 +402,14 @@ _ (ReadLEB_u32 (& numGlobals, & i_bytes, i_end));
for (u32 i = 0; i < numGlobals; ++i)
{
i8 waType;
u8 type;
u8 type, mutable;
_ (ReadLEB_i7 (& waType, & i_bytes, i_end));
_ (NormalizeType (& type, waType)); m3log (parse, " - add global: [%d] %s", i, c_waTypes [type]);
_ (NormalizeType (& type, waType));
_ (ReadLEB_u7 (& mutable, & i_bytes, i_end)); m3log (parse, " - add global: [%d] %s mutable: %d", i, c_waTypes [type], (u32) mutable);
IM3Global global;
_ (Module_AddGlobal (io_module, & global, type, false /* mutable */, false /* isImport */));
_ (Module_AddGlobal (io_module, & global, type, mutable, false /* isImport */));
global->initExpr = i_bytes;
_ (Parse_InitExpr (io_module, & i_bytes, i_end));

Loading…
Cancel
Save