[PATCH 179/188] normalizing elements after normalizing functions

From 3b77d251ecf0d52ded887dc2fed593b2ae70db5a Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Wed, 8 Apr 2020 12:11:46 -0400

git-svn-id: branches/wasm@46175 -
This commit is contained in:
nickysn 2020-08-03 13:02:09 +00:00
parent 6a08f41442
commit db6caf4496

View File

@ -253,10 +253,13 @@ begin
end;
end;
// For each element on the module, funcId is replaced with the proper IdNum
// it should only be called after all functions have their IDs resolved
procedure NormalizeElems(m: TWasmModule);
var
i : integer;
e : TWasmElement;
j : integer;
l : TWasmInstrList;
begin
//todo: resolve offsets
@ -265,6 +268,9 @@ begin
l := e.AddOffset;
if (l.Count=0) then l.AddInstr(INST_i32_const).operand1.s32:=0;
NormalizeInst( m, nil, l);
for j := 0 to e.funcCount-1 do
if e.funcs[j].idNum<0 then
e.funcs[j].idNum := FindFunc(m, e.funcs[j].id);
end;
end;
@ -283,7 +289,6 @@ begin
fnIdx := 0;
NormalizeGlobals(m);
NormalizeTable(m);
NormalizeElems(m);
NormalizeImport(m, fnIdx, memIdx, globIdx, tblIdx);
NormalizeTableLimit(m);
@ -295,6 +300,7 @@ begin
inc(fnIdx);
end;
NormalizeElems(m);
for i:=0 to m.GlobalCount-1 do
begin