From 2e32be10ce985ebd1d3f5eb9fcc4cb4ee34077f6 Mon Sep 17 00:00:00 2001 From: Dmitry Boyarintsev <[email protected]> Date: Thu, 26 Mar 2020 16:50:48 -0400 git-svn-id: branches/wasm@46149 -
@@ -196,8 +196,15 @@ end;
procedure NormalizeElems(m: TWasmModule);
var
i : integer;
+ e : TWasmElement;
+ l : TWasmInstrList;
begin
+ //todo: resolve offsets
for i:=0 to m.ElementCount-1 do begin
+ e := m.GetElement(i);
+ l := e.AddOffset;
+ if (l.Count=0) then l.AddInstr(INST_i32_const).operandText:='0';
+ NormalizeInst( m, nil, l);
end;
@@ -211,6 +218,7 @@ var
fnIdx := 0;
NormalizeTable(m);
+ NormalizeElems(m);
NormalizeImport(m, fnIdx);
for i:=0 to m.FuncCount-1 do begin
@@ -3,7 +3,8 @@ program wattest;
{$mode objfpc}{$H+}
uses
- SysUtils, Classes, watparser, watscanner, wasmmodule, wasmbinwriter;
+ SysUtils, Classes, watparser, watscanner, wasmmodule, wasmbinwriter,
+ wasmnormalize;
procedure Traverse(p: TWatScanner);