mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 21:49:11 +02:00
[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:
parent
6a08f41442
commit
db6caf4496
@ -253,10 +253,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
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);
|
procedure NormalizeElems(m: TWasmModule);
|
||||||
var
|
var
|
||||||
i : integer;
|
i : integer;
|
||||||
e : TWasmElement;
|
e : TWasmElement;
|
||||||
|
j : integer;
|
||||||
l : TWasmInstrList;
|
l : TWasmInstrList;
|
||||||
begin
|
begin
|
||||||
//todo: resolve offsets
|
//todo: resolve offsets
|
||||||
@ -265,6 +268,9 @@ begin
|
|||||||
l := e.AddOffset;
|
l := e.AddOffset;
|
||||||
if (l.Count=0) then l.AddInstr(INST_i32_const).operand1.s32:=0;
|
if (l.Count=0) then l.AddInstr(INST_i32_const).operand1.s32:=0;
|
||||||
NormalizeInst( m, nil, l);
|
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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -283,7 +289,6 @@ begin
|
|||||||
fnIdx := 0;
|
fnIdx := 0;
|
||||||
NormalizeGlobals(m);
|
NormalizeGlobals(m);
|
||||||
NormalizeTable(m);
|
NormalizeTable(m);
|
||||||
NormalizeElems(m);
|
|
||||||
NormalizeImport(m, fnIdx, memIdx, globIdx, tblIdx);
|
NormalizeImport(m, fnIdx, memIdx, globIdx, tblIdx);
|
||||||
NormalizeTableLimit(m);
|
NormalizeTableLimit(m);
|
||||||
|
|
||||||
@ -295,6 +300,7 @@ begin
|
|||||||
|
|
||||||
inc(fnIdx);
|
inc(fnIdx);
|
||||||
end;
|
end;
|
||||||
|
NormalizeElems(m);
|
||||||
|
|
||||||
for i:=0 to m.GlobalCount-1 do
|
for i:=0 to m.GlobalCount-1 do
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user