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