Răsfoiți Sursa

* ensure that all hidden parameter symbols are removed when adding an anonymous function to a capturer (they'll be added again later on)

Sven/Sarah Barth 2 ani în urmă
părinte
comite
430bcac389
1 a modificat fișierele cu 12 adăugiri și 12 ștergeri
  1. 12 12
      compiler/procdefutil.pas

+ 12 - 12
compiler/procdefutil.pas

@@ -1138,7 +1138,6 @@ implementation
       invokename : tsymstr;
       i : longint;
       outerself,
-      fpsym,
       selfsym,
       sym : tsym;
       info : pcapturedsyminfo;
@@ -1147,6 +1146,7 @@ implementation
       invokedef,
       parentdef,
       curpd : tprocdef;
+      syms : tfpobjectlist;
     begin
       capturer:=nil;
       result:=funcref_intf_for_proc(pd,fileinfo_to_suffix(pd.fileinfo));
@@ -1203,24 +1203,24 @@ implementation
           pd.procsym.realname:=invokename;
           pd.parast.symtablelevel:=normal_function_level;
           pd.localst.symtablelevel:=normal_function_level;
-          { retrieve framepointer and self parameters if any }
-          fpsym:=nil;
+          { collect all hidden parameters and especially the self parameter (if any) }
           selfsym:=nil;
+          syms:=tfpobjectlist.create(false);
           for i:=0 to pd.parast.symlist.count-1 do
             begin
               sym:=tsym(pd.parast.symlist[i]);
               if sym.typ<>paravarsym then
                 continue;
-              if vo_is_parentfp in tparavarsym(sym).varoptions then
-                fpsym:=sym
-              else if vo_is_self in tparavarsym(sym).varoptions then
-                selfsym:=sym;
-              if assigned(fpsym) and assigned(selfsym) then
-                break;
+              if vo_is_self in tparavarsym(sym).varoptions then
+                selfsym:=sym
+              else if vo_is_hidden_para in tparavarsym(sym).varoptions then
+                syms.add(sym);
             end;
-          { get rid of the framepointer parameter }
-          if assigned(fpsym) then
-            pd.parast.deletesym(fpsym);
+          { get rid of the hidden parameters; they will be added again during
+            buildvmt of the capturer }
+          for i:=0 to syms.count-1 do
+            pd.parast.deletesym(tsym(syms[i]));
+          syms.free;
           outerself:=nil;
           { complain about all symbols that can't be captured and add the symbols
             to this procdefs capturedsyms if it isn't a top level function }