[PATCH 153/188] update normalizing elements

From 2e32be10ce985ebd1d3f5eb9fcc4cb4ee34077f6 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Thu, 26 Mar 2020 16:50:48 -0400

git-svn-id: branches/wasm@46149 -
This commit is contained in:
nickysn 2020-08-03 13:01:45 +00:00
parent 1cd222ef30
commit be37f0577e
2 changed files with 10 additions and 1 deletions

View File

@ -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;
end;
@ -211,6 +218,7 @@ var
begin
fnIdx := 0;
NormalizeTable(m);
NormalizeElems(m);
NormalizeImport(m, fnIdx);
for i:=0 to m.FuncCount-1 do begin

View File

@ -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);
begin