Handle NIL entries in deflist after commit 48986

git-svn-id: trunk@49230 -
This commit is contained in:
pierre 2021-04-18 15:44:07 +00:00
parent 70760208bb
commit e6045673ee
4 changed files with 36 additions and 22 deletions

View File

@ -813,6 +813,9 @@ uses
st : TSymtable;
i : longint;
begin
{ since commit 48986 deflist might have NIL entries }
if not assigned(def) then
exit;
case def.typ of
procdef:
tprocdef(def).forwarddef:=false;

View File

@ -618,6 +618,9 @@ implementation
for i:=current_module.localsymtable.deflist.count-1 downto 0 do
begin
def:=tdef(current_module.localsymtable.deflist[i]);
{ since commit 48986 deflist might have NIL entries }
if not assigned(def) then
continue;
{ this also frees def, as the defs are owned by the symtable }
if not def.is_registered and
not(df_not_registered_no_free in def.defoptions) then

View File

@ -70,31 +70,36 @@ implementation
procedure TLLVMMachineCodePlaygroundAssembler.WriteImports;
var
i : integer;
def : tdef;
proc : tprocdef;
list : TAsmList;
cur_unit: tused_unit;
begin
for i:=0 to current_module.deflist.Count-1 do
if assigned(current_module.deflist[i]) and (tdef(current_module.deflist[i]).typ=procdef) then
begin
proc := tprocdef(current_module.deflist[i]);
if (po_external in proc.procoptions) and assigned(proc.import_dll) then
begin
//WriteProcDef(proc);
list:=TAsmList.Create;
thlcgwasm(hlcg).g_procdef(list,proc);
WriteTree(list);
list.free;
writer.AsmWrite(#9'.import_module'#9);
writer.AsmWrite(proc.mangledname);
writer.AsmWrite(', ');
writer.AsmWriteLn(proc.import_dll^);
writer.AsmWrite(#9'.import_name'#9);
writer.AsmWrite(proc.mangledname);
writer.AsmWrite(', ');
writer.AsmWriteLn(proc.import_name^);
end;
end;
begin
def:=tdef(current_module.deflist[i]);
{ since commit 48986 deflist might have NIL entries }
if assigned(def) and (def.typ=procdef) then
begin
proc := tprocdef(def);
if (po_external in proc.procoptions) and assigned(proc.import_dll) then
begin
//WriteProcDef(proc);
list:=TAsmList.Create;
thlcgwasm(hlcg).g_procdef(list,proc);
WriteTree(list);
list.free;
writer.AsmWrite(#9'.import_module'#9);
writer.AsmWrite(proc.mangledname);
writer.AsmWrite(', ');
writer.AsmWriteLn(proc.import_dll^);
writer.AsmWrite(#9'.import_name'#9);
writer.AsmWrite(proc.mangledname);
writer.AsmWrite(', ');
writer.AsmWriteLn(proc.import_name^);
end;
end;
end;
list:=TAsmList.Create;
cur_unit:=tused_unit(usedunits.First);
while assigned(cur_unit) do

View File

@ -957,14 +957,17 @@ implementation
procedure TWabtTextAssembler.WriteImports;
var
i : integer;
def : tdef;
proc : tprocdef;
sym : tsym;
j : integer;
psym : tprocsym;
begin
for i:=0 to current_module.deflist.Count-1 do begin
if tdef(current_module.deflist[i]).typ = procdef then begin
proc := tprocdef(current_module.deflist[i]);
def:=tdef(current_module.deflist[i]);
{ since commit 48986 deflist might have NIL entries }
if assigned(def) and (def.typ=procdef) then begin
proc := tprocdef(def);
if (po_external in proc.procoptions) and assigned(proc.import_dll) then begin
writer.AsmWrite(#9'(import "');
writer.AsmWrite(proc.import_dll^);