function references: make names of interface methods valid Pascal identifiers

On high level targets, and on PowerPC/PowerPC64, interface method thunks are
implemented using internally-generated Pascal wrappers, so the method names
need to be valid Pascal identifiers.

Additionally, that wrapper code uses the procsym's realname, so also
update the realname field when changing the name of anonymous methods.
This commit is contained in:
Jonas Maebe 2022-05-29 22:17:41 +02:00
parent 29cfa3b225
commit 59f293711a
2 changed files with 4 additions and 3 deletions

View File

@ -883,7 +883,7 @@ implementation
something like file position however as this might be inside
an include file that's included multiple times }
str(checkstack^.symtable.symlist.count,orgsp);
orgsp:='_$Anonymous$'+orgsp;
orgsp:='__FPCINTERNAL__Anonymous_'+orgsp;
sp:=upper(orgsp);
spnongen:=sp;
orgspnongen:=orgsp;

View File

@ -915,7 +915,7 @@ implementation
end;
implintf:=capturedef.register_implemented_interface(result,true);
invokename:=method_name_funcref_invoke_decl+'$'+fileinfo_to_suffix(sym.fileinfo);
invokename:=method_name_funcref_invoke_decl+'__FPCINTERNAL__'+fileinfo_to_suffix(sym.fileinfo);
ps:=cprocsym.create(invokename);
pd:=tprocdef(tabstractprocdef(n.resultdef).getcopyas(procdef,pc_normal,'',false));
@ -1130,7 +1130,7 @@ implementation
end;
implintf:=capturedef.register_implemented_interface(result,true);
invokename:=method_name_funcref_invoke_decl+'$'+fileinfo_to_suffix(pd.fileinfo);
invokename:=method_name_funcref_invoke_decl+'__FPCINTERNAL__'+fileinfo_to_suffix(pd.fileinfo);
if po_anonymous in pd.procoptions then
begin
{ turn the anonymous function into a method of the capturer }
@ -1140,6 +1140,7 @@ implementation
exclude(pd.procoptions,po_delphi_nested_cc);
pd.was_anonymous:=true;
pd.procsym.ChangeOwnerAndName(capturedef.symtable,upcase(invokename));
pd.procsym.realname:=invokename;
pd.parast.symtablelevel:=normal_function_level;
pd.localst.symtablelevel:=normal_function_level;
{ retrieve framepointer and self parameters if any }