+ generate the import section in the wasm exe writer

This commit is contained in:
Nikolay Nikolov 2023-12-31 22:52:03 +02:00
parent 2c72b62a0e
commit d9a67bb16d

View File

@ -4049,16 +4049,36 @@ implementation
end;
function TWasmExeOutput.writeData: boolean;
procedure WriteImportSection;
var
imports_count: SizeInt;
i: Integer;
begin
imports_count:=Length(FFunctionImports);
WriteUleb(FWasmSections[wsiImport],imports_count);
for i:=0 to Length(FFunctionImports)-1 do
with FFunctionImports[i] do
begin
WriteName(FWasmSections[wsiImport],ModName);
WriteName(FWasmSections[wsiImport],Name);
WriteByte(FWasmSections[wsiImport],$00);
WriteUleb(FWasmSections[wsiImport],TypeIdx);
end;
end;
begin
result:=false;
FFuncTypes.WriteTo(FWasmSections[wsiType]);
WriteImportSection;
{...}
Writer.write(WasmModuleMagic,SizeOf(WasmModuleMagic));
Writer.write(WasmVersion,SizeOf(WasmVersion));
WriteWasmSection(wsiType);
WriteWasmSection(wsiImport);
result := true;
end;