diff options
Diffstat (limited to 'compiler/wasm32/agllvmmc.pas')
-rw-r--r-- | compiler/wasm32/agllvmmc.pas | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/compiler/wasm32/agllvmmc.pas b/compiler/wasm32/agllvmmc.pas index 4468a56f27..de9e0a8b99 100644 --- a/compiler/wasm32/agllvmmc.pas +++ b/compiler/wasm32/agllvmmc.pas @@ -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 @@ -107,13 +112,16 @@ implementation 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 - if assigned(cur_unit.u.deflist[i]) and (tdef(cur_unit.u.deflist[i]).typ = procdef) then - begin - proc := tprocdef(cur_unit.u.deflist[i]); - if (not proc.owner.iscurrentunit or (po_external in proc.procoptions)) and - ((proc.paras.Count=0) or (proc.has_paraloc_info in [callerside,callbothsides])) then - thlcgwasm(hlcg).g_procdef(list,proc); - end; + begin + def:=tdef(cur_unit.u.deflist[i]); + if assigned(def) and (tdef(def).typ = procdef) then + begin + proc := tprocdef(def); + if (not proc.owner.iscurrentunit or (po_external in proc.procoptions)) and + ((proc.paras.Count=0) or (proc.has_paraloc_info in [callerside,callbothsides])) then + thlcgwasm(hlcg).g_procdef(list,proc); + end; + end; cur_unit:=tused_unit(cur_unit.Next); end; WriteTree(list); |