mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-28 17:00:40 +02:00
* when adding WebAssembly object info, traverse through current_module.used_units,
as well as the usedunits global. This resolves #39543
This commit is contained in:
parent
1fce64fa0a
commit
2c0f10d988
@ -58,6 +58,33 @@ implementation
|
||||
list.Concat(tai_import_name.create(proc.mangledname,proc.import_name^));
|
||||
end;
|
||||
|
||||
procedure InsertUnitInfo(list : TAsmList;cur_unit: tused_unit);
|
||||
var
|
||||
i: Integer;
|
||||
def : tdef;
|
||||
proc : tprocdef;
|
||||
begin
|
||||
if (cur_unit.u.moduleflags * [mf_init,mf_finalize])<>[] then
|
||||
begin
|
||||
if mf_init in cur_unit.u.moduleflags then
|
||||
list.Concat(tai_functype.create(make_mangledname('INIT$',cur_unit.u.globalsymtable,''),TWasmFuncType.Create([],[])));
|
||||
if mf_finalize in cur_unit.u.moduleflags then
|
||||
list.Concat(tai_functype.create(make_mangledname('FINALIZE$',cur_unit.u.globalsymtable,''),TWasmFuncType.Create([],[])));
|
||||
end;
|
||||
for i:=0 to cur_unit.u.deflist.Count-1 do
|
||||
begin
|
||||
def:=tdef(cur_unit.u.deflist[i]);
|
||||
if assigned(def) and (tdef(def).typ = procdef) then
|
||||
begin
|
||||
proc := tprocdef(def);
|
||||
if (po_external in proc.procoptions) and (po_has_importdll in proc.procoptions) then
|
||||
WriteImportDll(list,proc)
|
||||
else if not proc.owner.iscurrentunit or (po_external in proc.procoptions) then
|
||||
thlcgwasm(hlcg).g_procdef(list,proc);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
i : integer;
|
||||
def : tdef;
|
||||
@ -94,25 +121,13 @@ implementation
|
||||
cur_unit:=tused_unit(usedunits.First);
|
||||
while assigned(cur_unit) do
|
||||
begin
|
||||
if (cur_unit.u.moduleflags * [mf_init,mf_finalize])<>[] then
|
||||
begin
|
||||
if mf_init in cur_unit.u.moduleflags then
|
||||
list.Concat(tai_functype.create(make_mangledname('INIT$',cur_unit.u.globalsymtable,''),TWasmFuncType.Create([],[])));
|
||||
if mf_finalize in cur_unit.u.moduleflags then
|
||||
list.Concat(tai_functype.create(make_mangledname('FINALIZE$',cur_unit.u.globalsymtable,''),TWasmFuncType.Create([],[])));
|
||||
end;
|
||||
for i:=0 to cur_unit.u.deflist.Count-1 do
|
||||
begin
|
||||
def:=tdef(cur_unit.u.deflist[i]);
|
||||
if assigned(def) and (tdef(def).typ = procdef) then
|
||||
begin
|
||||
proc := tprocdef(def);
|
||||
if (po_external in proc.procoptions) and (po_has_importdll in proc.procoptions) then
|
||||
WriteImportDll(list,proc)
|
||||
else if not proc.owner.iscurrentunit or (po_external in proc.procoptions) then
|
||||
thlcgwasm(hlcg).g_procdef(list,proc);
|
||||
end;
|
||||
end;
|
||||
InsertUnitInfo(list,cur_unit);
|
||||
cur_unit:=tused_unit(cur_unit.Next);
|
||||
end;
|
||||
cur_unit:=tused_unit(current_module.used_units.First);
|
||||
while assigned(cur_unit) do
|
||||
begin
|
||||
InsertUnitInfo(list,cur_unit);
|
||||
cur_unit:=tused_unit(cur_unit.Next);
|
||||
end;
|
||||
end;
|
||||
|
10
tests/webtbs/tw39543.pp
Normal file
10
tests/webtbs/tw39543.pp
Normal file
@ -0,0 +1,10 @@
|
||||
program tw39543;
|
||||
|
||||
{$MODE objfpc}
|
||||
|
||||
uses
|
||||
uw39543a;
|
||||
|
||||
begin
|
||||
|
||||
end.
|
19
tests/webtbs/uw39543a.pp
Normal file
19
tests/webtbs/uw39543a.pp
Normal file
@ -0,0 +1,19 @@
|
||||
unit uw39543a;
|
||||
|
||||
interface
|
||||
|
||||
{$MODE objfpc}
|
||||
|
||||
uses
|
||||
uw39543b;
|
||||
|
||||
function Test: TVector4;
|
||||
|
||||
implementation
|
||||
|
||||
function Test: TVector4;
|
||||
begin
|
||||
Result := Vector4(1, 2, 3, 4);
|
||||
end;
|
||||
|
||||
end.
|
27
tests/webtbs/uw39543b.pp
Normal file
27
tests/webtbs/uw39543b.pp
Normal file
@ -0,0 +1,27 @@
|
||||
unit uw39543b;
|
||||
|
||||
interface
|
||||
|
||||
{$MODE objfpc}
|
||||
|
||||
type
|
||||
TVector4 = record
|
||||
X, Y, Z, W: Single;
|
||||
end;
|
||||
|
||||
function Vector4(X, Y, Z, W: Single): TVector4;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uw39543a;
|
||||
|
||||
function Vector4(X, Y, Z, W: Single): TVector4;
|
||||
begin
|
||||
Result.X := X;
|
||||
Result.Y := Y;
|
||||
Result.Z := Z;
|
||||
Result.W := W;
|
||||
end;
|
||||
|
||||
end.
|
Loading…
Reference in New Issue
Block a user