[PATCH 184/188] update writing binary import section for entities

other than function update table normalization to hard-code the element type

From 545def919260e7d90ec3b948f242022378607079 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Thu, 9 Apr 2020 14:08:42 -0400

git-svn-id: branches/wasm@46180 -
This commit is contained in:
nickysn 2020-08-03 13:02:15 +00:00
parent 0e4e94dfe2
commit addfbaf889
2 changed files with 15 additions and 0 deletions

View File

@ -692,6 +692,8 @@ var
sc : TSectionRec;
i : integer;
im : TWasmImport;
const
isMutableFlag : array [boolean] of byte = (global_const, global_mut);
begin
SectionBegin(SECT_IMPORT, sc);
@ -704,6 +706,17 @@ begin
if Assigned(im.fn) then begin
dst.WriteByte(IMPDESC_FUNC);
WriteU32(dst, im.fn.functype.typeNum);
end else if Assigned(im.mem) then begin
dst.WriteByte(IMPDESC_MEM);
WriteLimit(dst, im.mem.min, im.mem.max)
end else if Assigned(im.table) then begin
dst.WriteByte(IMPDESC_TABLE);
dst.WriteByte(im.table.elemsType);
WriteLimit(dst, im.table.min, im.table.max);
end else if Assigned(im.glob) then begin
dst.WriteByte(IMPDESC_GLOBAL);
dst.WriteByte(im.glob.tp);
dst.WriteByte(isMutableFlag[im.glob.isMutable]);
end;
end;
SectionEnd(sc);

View File

@ -222,6 +222,8 @@ begin
de := m.AddElement;
de.tableId.idNum := t.id.idNum;
if t.elemsType = 0 then t.elemsType := ELEMTYPE_FUNC;
de.funcCount:=se.funcCount;
if se.funcCount>0 then begin
SetLength(de.funcs, de.funcCount);