[PATCH 146/188] update writing globals section

From cabd10e07f9794a473b12411a1c527f423c6c5b6 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Wed, 25 Mar 2020 14:45:43 -0400

git-svn-id: branches/wasm@46142 -
This commit is contained in:
nickysn 2020-08-03 13:01:39 +00:00
parent 518fb62535
commit b828875a43

View File

@ -53,6 +53,7 @@ type
procedure WriteFuncTypeSect;
procedure WriteTableSect;
procedure WriteMemorySect;
procedure WriteGlobalSect;
procedure WriteFuncSect;
procedure WriteExportSect;
procedure WriteCodeSect;
@ -261,6 +262,12 @@ begin
inc(writeSec);
end;
// 06 globals section
if m.GlobalCount>0 then begin
WriteGlobalSect;
inc(writeSec);
end;
// 07 export section
if m.ExportCount>0 then begin
WriteExportSect;
@ -368,6 +375,26 @@ begin
SectionEnd(sc);
end;
procedure TBinWriter.WriteGlobalSect;
var
sc : TSectionRec;
i : integer;
g : TWasmGlobal;
begin
SectionBegin(SECT_GLOBAL, sc);
WriteU32(dst, module.GlobalCount);
for i:=0 to module.GlobalCount-1 do begin
g := module.GetGlobal(i);
dst.WriteByte(g.tp);
if g.isMutable then dst.WriteByte(1)
else dst.WriteByte(0);
WriteInstList(g.StartValue, sc.datapos);
end;
SectionEnd(sc);
end;
procedure TBinWriter.WriteFuncSect;
var
sc : TSectionRec;