diff --git a/source/m3_compile.c b/source/m3_compile.c index 8b68d6b..a867991 100644 --- a/source/m3_compile.c +++ b/source/m3_compile.c @@ -2601,6 +2601,8 @@ M3Result CompileLocals (IM3Compilation o) u32 numLocalBlocks; _ (ReadLEB_u32 (& numLocalBlocks, & o->wasm, o->wasmEnd)); + u32 numLocals = 0; + for (u32 l = 0; l < numLocalBlocks; ++l) { u32 varCount; @@ -2610,10 +2612,13 @@ _ (ReadLEB_u32 (& numLocalBlocks, & o->wasm, o->wasmEnd)); _ (ReadLEB_u32 (& varCount, & o->wasm, o->wasmEnd)); _ (ReadLEB_i7 (& waType, & o->wasm, o->wasmEnd)); _ (NormalizeType (& localType, waType)); - m3log (compile, "pushing locals. count: %d; type: %s", varCount, c_waTypes [localType]); + numLocals += varCount; m3log (compile, "pushing locals. count: %d; type: %s", varCount, c_waTypes [localType]); while (varCount--) _ (PushAllocatedSlot (o, localType)); } + + if (o->function) + o->function->numLocals = numLocals; _catch: return result; } diff --git a/source/m3_parse.c b/source/m3_parse.c index e507699..dcd0855 100644 --- a/source/m3_parse.c +++ b/source/m3_parse.c @@ -346,6 +346,7 @@ _ (ReadLEB_u32 (& size, & i_bytes, i_end)); if (i_bytes <= i_end) { + /* u32 numLocalBlocks; _ (ReadLEB_u32 (& numLocalBlocks, & ptr, i_end)); m3log (parse, " code size: %-4d", size); @@ -363,14 +364,15 @@ _ (NormalizeType (& normalType, wasmType)); numLocals += varCount; m3log (parse, " %2d locals; type: '%s'", varCount, c_waTypes [normalType]); } - + */ + IM3Function func = Module_GetFunction (io_module, f + io_module->numFuncImports); func->module = io_module; func->wasm = start; func->wasmEnd = i_bytes; //func->ownsWasmCode = io_module->hasWasmCodeCopy; - func->numLocals = numLocals; +// func->numLocals = numLocals; } else _throw (m3Err_wasmSectionOverrun); }