Browse Source

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.
Jonas Maebe 3 years ago
parent
commit
59f293711a
2 changed files with 4 additions and 3 deletions
  1. 1 1
      compiler/pdecsub.pas
  2. 3 2
      compiler/procdefutil.pas

+ 1 - 1
compiler/pdecsub.pas

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

+ 3 - 2
compiler/procdefutil.pas

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