* fix compiling binaries on JVM: the entries list contains pinitfinalentry values, not tused_unit

This commit is contained in:
Sven/Sarah Barth 2025-01-10 22:59:55 +01:00
parent 1202b2612f
commit 366acce9ef

View File

@ -390,35 +390,33 @@ implementation
class procedure tjvmnodeutils.insert_init_final_table(main: tmodule; entries:tfplist); class procedure tjvmnodeutils.insert_init_final_table(main: tmodule; entries:tfplist);
var var
hp : tused_unit;
unitinits : TAsmList; unitinits : TAsmList;
unitclassname: string; unitclassname: string;
mainpsym: tsym; mainpsym: tsym;
mainpd: tprocdef; mainpd: tprocdef;
m : tmodule;
i : integer; i : integer;
entry : pinitfinalentry;
begin begin
unitinits:=TAsmList.Create; unitinits:=TAsmList.Create;
for I:=0 to entries.Count-1 do for I:=0 to entries.Count-1 do
begin begin
hp:=tused_unit(entries[i]); entry:=pinitfinalentry(entries[i]);
m:=hp.u;
{ class constructors are automatically handled by the JVM } { class constructors are automatically handled by the JVM }
{ for non-main module, call the unit init code and make it external } { for non-main module, call the unit init code and make it external }
if (m<>main) and ((m.moduleflags*[mf_init,mf_finalize])<>[]) then if (entry^.module<>main) and ((entry^.initfunc<>'') or (entry^.finifunc<>'')) then
begin begin
{ trigger init code by referencing the class representing the { trigger init code by referencing the class representing the
unit; if necessary, it will register the fini code to run on unit; if necessary, it will register the fini code to run on
exit} exit}
unitclassname:=''; unitclassname:='';
if assigned(hp.u.namespace) then if assigned(entry^.module.namespace) then
begin begin
unitclassname:=hp.u.namespace^+'/'; unitclassname:=entry^.module.namespace^+'/';
replace(unitclassname,'.','/'); replace(unitclassname,'.','/');
end; end;
unitclassname:=unitclassname+hp.u.realmodulename^; unitclassname:=unitclassname+entry^.module.realmodulename^;
unitinits.concat(taicpu.op_sym(a_new,current_asmdata.RefAsmSymbol(unitclassname,AT_METADATA))); unitinits.concat(taicpu.op_sym(a_new,current_asmdata.RefAsmSymbol(unitclassname,AT_METADATA)));
unitinits.concat(taicpu.op_none(a_pop)); unitinits.concat(taicpu.op_none(a_pop));
end; end;