Ver código fonte

+ add method to find a procinfo for a nested function by the corresponding procdef

Sven/Sarah Barth 3 anos atrás
pai
commit
9f3dcdb211
1 arquivos alterados com 17 adições e 0 exclusões
  1. 17 0
      compiler/procinfo.pas

+ 17 - 0
compiler/procinfo.pas

@@ -179,6 +179,7 @@ unit procinfo;
           function has_nestedprocs: boolean;
           function get_normal_proc: tprocinfo;
           procedure addnestedproc(child: tprocinfo);
+          function find_nestedproc_by_pd(pd:tprocdef):tprocinfo;
 
           procedure add_local_ref_sym(sym:tsym);
           procedure export_local_ref_syms;
@@ -286,6 +287,22 @@ implementation
         nestedprocs.insert(child);
       end;
 
+    function tprocinfo.find_nestedproc_by_pd(pd:tprocdef):tprocinfo;
+      var
+        pi : tprocinfo;
+      begin
+        if not assigned(nestedprocs) then
+          exit(nil);
+        pi:=tprocinfo(nestedprocs.first);
+        while assigned(pi) do
+          begin
+            if pi.procdef=pd then
+              exit(pi);
+            pi:=tprocinfo(pi.next);
+          end;
+        result:=nil;
+      end;
+
     procedure tprocinfo.updatestackalignment(alignment: longint);
       begin
         fstackalignment:=max(fstackalignment,alignment);