|
@@ -51,6 +51,7 @@ type
|
|
|
|
|
|
procedure WriteImportSect;
|
|
procedure WriteImportSect;
|
|
procedure WriteFuncTypeSect;
|
|
procedure WriteFuncTypeSect;
|
|
|
|
+ procedure WriteTableSect;
|
|
procedure WriteFuncSect;
|
|
procedure WriteFuncSect;
|
|
procedure WriteExportSect;
|
|
procedure WriteExportSect;
|
|
procedure WriteCodeSect;
|
|
procedure WriteCodeSect;
|
|
@@ -84,8 +85,23 @@ type
|
|
// returns the list of local arrays
|
|
// returns the list of local arrays
|
|
procedure GetLocalInfo(func: TWasmFunc; out loc: TLocalInfoArray);
|
|
procedure GetLocalInfo(func: TWasmFunc; out loc: TLocalInfoArray);
|
|
|
|
|
|
|
|
+procedure WriteLimit(dst: TStream; amin, amax: LongWord);
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
|
|
+procedure WriteLimit(dst: TStream; amin, amax: LongWord);
|
|
|
|
+begin
|
|
|
|
+ if not Assigned(dst) then Exit;
|
|
|
|
+ if amax>0 then begin
|
|
|
|
+ dst.WriteByte(1);
|
|
|
|
+ WriteU32(dst, amin);
|
|
|
|
+ WriteU32(dst, amax);
|
|
|
|
+ end else begin
|
|
|
|
+ dst.WriteByte(0);
|
|
|
|
+ WriteU32(dst, amin);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure GetLocalInfo(func: TWasmFunc; out loc: TLocalInfoArray);
|
|
procedure GetLocalInfo(func: TWasmFunc; out loc: TLocalInfoArray);
|
|
var
|
|
var
|
|
i : integer;
|
|
i : integer;
|
|
@@ -231,6 +247,12 @@ begin
|
|
inc(writeSec);
|
|
inc(writeSec);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ // 04 tables section
|
|
|
|
+ if m.TableCount>0 then begin
|
|
|
|
+ WriteTableSect;
|
|
|
|
+ inc(writeSec);
|
|
|
|
+ end;
|
|
|
|
+
|
|
// 07 export section
|
|
// 07 export section
|
|
if m.ExportCount>0 then begin
|
|
if m.ExportCount>0 then begin
|
|
WriteExportSect;
|
|
WriteExportSect;
|
|
@@ -299,6 +321,22 @@ begin
|
|
SectionEnd(sc);
|
|
SectionEnd(sc);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TBinWriter.WriteTableSect;
|
|
|
|
+var
|
|
|
|
+ sc : TSectionRec;
|
|
|
|
+ i : integer;
|
|
|
|
+ t : TWasmTable;
|
|
|
|
+begin
|
|
|
|
+ SectionBegin(SECT_TABLE, sc);
|
|
|
|
+ WriteU32(dst, module.TableCount);
|
|
|
|
+ for i:=0 to module.TableCount-1 do begin
|
|
|
|
+ t:=module.GetTable(i);
|
|
|
|
+ dst.WriteByte(t.elemsType);
|
|
|
|
+ WriteLimit(dst, t.min, t.max);
|
|
|
|
+ end;
|
|
|
|
+ SectionEnd(sc);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TBinWriter.WriteFuncSect;
|
|
procedure TBinWriter.WriteFuncSect;
|
|
var
|
|
var
|
|
sc : TSectionRec;
|
|
sc : TSectionRec;
|