|
@@ -57,7 +57,7 @@ interface
|
|
procedure WriteOutGlobalInt32(const aname: string; val: integer; isconst: boolean = true);
|
|
procedure WriteOutGlobalInt32(const aname: string; val: integer; isconst: boolean = true);
|
|
|
|
|
|
procedure WriteInstruction(hp: tai);
|
|
procedure WriteInstruction(hp: tai);
|
|
- procedure WriteProcDef(pd: tprocdef; stub: Boolean = false);
|
|
|
|
|
|
+ procedure WriteProcDef(pd: tprocdef; stub: Boolean = false; stubUnreachable: Boolean = true);
|
|
procedure WriteProcParams(pd: tprocdef);
|
|
procedure WriteProcParams(pd: tprocdef);
|
|
procedure WriteProcResult(pd: tprocdef);
|
|
procedure WriteProcResult(pd: tprocdef);
|
|
procedure WriteSymtableProcdefs(st: TSymtable);
|
|
procedure WriteSymtableProcdefs(st: TSymtable);
|
|
@@ -260,7 +260,7 @@ implementation
|
|
writer.AsmLn;
|
|
writer.AsmLn;
|
|
end;
|
|
end;
|
|
|
|
|
|
- procedure TWabtTextAssembler.WriteProcDef(pd: tprocdef; stub: Boolean );
|
|
|
|
|
|
+ procedure TWabtTextAssembler.WriteProcDef(pd: tprocdef; stub: Boolean; stubUnreachable: Boolean);
|
|
var
|
|
var
|
|
i : integer;
|
|
i : integer;
|
|
begin
|
|
begin
|
|
@@ -288,6 +288,9 @@ implementation
|
|
if not stub then begin
|
|
if not stub then begin
|
|
WriteTempAlloc(tcpuprocdef(pd).exprasmlist);
|
|
WriteTempAlloc(tcpuprocdef(pd).exprasmlist);
|
|
WriteTree(tcpuprocdef(pd).exprasmlist);
|
|
WriteTree(tcpuprocdef(pd).exprasmlist);
|
|
|
|
+ end else begin
|
|
|
|
+ if stubUnreachable then
|
|
|
|
+ writer.AsmWriteLn(#9#9'unreachable');
|
|
end;
|
|
end;
|
|
writer.AsmWriteln(#9')');
|
|
writer.AsmWriteln(#9')');
|
|
writer.AsmLn;
|
|
writer.AsmLn;
|
|
@@ -597,9 +600,9 @@ implementation
|
|
WriteSymtableProcdefs(current_module.globalsymtable);
|
|
WriteSymtableProcdefs(current_module.globalsymtable);
|
|
WriteSymtableProcdefs(current_module.localsymtable);
|
|
WriteSymtableProcdefs(current_module.localsymtable);
|
|
|
|
|
|
- if current_module.islibrary then
|
|
|
|
- WriteExports(current_asmdata.asmlists[al_exports])
|
|
|
|
- else
|
|
|
|
|
|
+ if current_module.islibrary then begin
|
|
|
|
+ WriteExports(current_asmdata.asmlists[al_exports]);
|
|
|
|
+ end else
|
|
WriteUnitExports(current_module.globalsymtable);
|
|
WriteUnitExports(current_module.globalsymtable);
|
|
|
|
|
|
//WriteSymtableStructDefs(current_module.globalsymtable);
|
|
//WriteSymtableStructDefs(current_module.globalsymtable);
|
|
@@ -763,12 +766,32 @@ implementation
|
|
begin
|
|
begin
|
|
if not Assigned(p) then Exit;
|
|
if not Assigned(p) then Exit;
|
|
hp:=tai(p.First);
|
|
hp:=tai(p.First);
|
|
|
|
+ if not Assigned(hp) then Exit;
|
|
|
|
+
|
|
|
|
+ // writting out table, so wat2wasm can create reallocation symbols
|
|
|
|
+ writer.AsmWrite(#9'(table 0 funcref)');
|
|
|
|
+ writer.AsmWriteLn(#9'(elem 0 (i32.const 0) ');
|
|
|
|
+ while Assigned(hp) do begin
|
|
|
|
+ case hp.typ of
|
|
|
|
+ ait_importexport:
|
|
|
|
+ begin
|
|
|
|
+ x:=tai_impexp(hp);
|
|
|
|
+ writer.AsmWrite(#9#9);
|
|
|
|
+ writer.AsmWriteLn(GetWasmName(x.intname));
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ hp := tai_impexp(hp.Next);
|
|
|
|
+ end;
|
|
|
|
+ writer.AsmWriteLn(#9') ');
|
|
|
|
+
|
|
|
|
+ // writing export sections
|
|
|
|
+ hp:=tai(p.First);
|
|
while Assigned(hp) do begin
|
|
while Assigned(hp) do begin
|
|
case hp.typ of
|
|
case hp.typ of
|
|
ait_importexport:
|
|
ait_importexport:
|
|
begin
|
|
begin
|
|
x:=tai_impexp(hp);
|
|
x:=tai_impexp(hp);
|
|
- writer.AsmWrite('(export "');
|
|
|
|
|
|
+ writer.AsmWrite(#9#9'(export "');
|
|
writer.AsmWrite(x.extname);
|
|
writer.AsmWrite(x.extname);
|
|
writer.AsmWrite('" (');
|
|
writer.AsmWrite('" (');
|
|
case x.symstype of
|
|
case x.symstype of
|
|
@@ -856,11 +879,11 @@ implementation
|
|
else
|
|
else
|
|
proc := nil;
|
|
proc := nil;
|
|
if proc<>nil then begin
|
|
if proc<>nil then begin
|
|
- writer.AsmWrite(#9'(import "_fpc_use" "');
|
|
|
|
|
|
+ {writer.AsmWrite(#9'(import "_fpc_use" "');
|
|
writer.AsmWrite(proc.mangledname);
|
|
writer.AsmWrite(proc.mangledname);
|
|
- writer.AsmWrite('" ');
|
|
|
|
|
|
+ writer.AsmWrite('" ');}
|
|
WriteProcDef(proc, true);
|
|
WriteProcDef(proc, true);
|
|
- writer.AsmWrite(')');
|
|
|
|
|
|
+ //writer.AsmWrite(')');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -954,7 +977,7 @@ implementation
|
|
id : as_wasm_wabt;
|
|
id : as_wasm_wabt;
|
|
idtxt : 'Wabt';
|
|
idtxt : 'Wabt';
|
|
asmbin : 'wat2wasm';
|
|
asmbin : 'wat2wasm';
|
|
- asmcmd : '$EXTRAOPT $ASM';
|
|
|
|
|
|
+ asmcmd : '-r --no-canonicalize-leb128s -o $OBJ $EXTRAOPT $ASM';
|
|
supported_targets : [system_wasm_wasm32];
|
|
supported_targets : [system_wasm_wasm32];
|
|
flags : [];
|
|
flags : [];
|
|
labelprefix : 'L';
|
|
labelprefix : 'L';
|