mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 16:09:17 +02:00
[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:
parent
518fb62535
commit
b828875a43
@ -53,6 +53,7 @@ type
|
|||||||
procedure WriteFuncTypeSect;
|
procedure WriteFuncTypeSect;
|
||||||
procedure WriteTableSect;
|
procedure WriteTableSect;
|
||||||
procedure WriteMemorySect;
|
procedure WriteMemorySect;
|
||||||
|
procedure WriteGlobalSect;
|
||||||
procedure WriteFuncSect;
|
procedure WriteFuncSect;
|
||||||
procedure WriteExportSect;
|
procedure WriteExportSect;
|
||||||
procedure WriteCodeSect;
|
procedure WriteCodeSect;
|
||||||
@ -261,6 +262,12 @@ begin
|
|||||||
inc(writeSec);
|
inc(writeSec);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// 06 globals section
|
||||||
|
if m.GlobalCount>0 then begin
|
||||||
|
WriteGlobalSect;
|
||||||
|
inc(writeSec);
|
||||||
|
end;
|
||||||
|
|
||||||
// 07 export section
|
// 07 export section
|
||||||
if m.ExportCount>0 then begin
|
if m.ExportCount>0 then begin
|
||||||
WriteExportSect;
|
WriteExportSect;
|
||||||
@ -368,6 +375,26 @@ begin
|
|||||||
SectionEnd(sc);
|
SectionEnd(sc);
|
||||||
end;
|
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;
|
procedure TBinWriter.WriteFuncSect;
|
||||||
var
|
var
|
||||||
sc : TSectionRec;
|
sc : TSectionRec;
|
||||||
|
Loading…
Reference in New Issue
Block a user