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 năm trước cách đây
mục cha
commit
59f293711a
2 tập tin đã thay đổi với 4 bổ sung3 xóa
  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
                   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;

+ 3 - 2
compiler/procdefutil.pas

@@ -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 }