소스 검색

Merged revisions 2029 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

r2029 (jonas)
* properly fixed allocating procedure symbols, now also works for nested
procedures

git-svn-id: branches/fixes_2_0@2030 -

Jonas Maebe 20 년 전
부모
커밋
7af62e75d3
2개의 변경된 파일27개의 추가작업 그리고 10개의 파일을 삭제
  1. 20 0
      compiler/ncgutil.pas
  2. 7 10
      compiler/psub.pas

+ 20 - 0
compiler/ncgutil.pas

@@ -54,6 +54,7 @@ interface
 
     function  maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
 
+    procedure alloc_proc_symbol(pd: tprocdef);
     procedure gen_proc_symbol(list:Taasmoutput);
     procedure gen_proc_symbol_end(list:Taasmoutput);
     procedure gen_proc_entry_code(list:Taasmoutput);
@@ -1652,6 +1653,25 @@ implementation
                                 Entry/Exit
 ****************************************************************************}
 
+    procedure alloc_proc_symbol(pd: tprocdef);
+     var
+        sym: tai_symbol;
+        item: tstringlistitem;
+      begin
+        item := tstringlistitem(pd.aliasnames.first);
+        while assigned(item) do
+          begin
+            if (cs_profile in aktmoduleswitches) or
+               (po_global in current_procinfo.procdef.procoptions) then
+              sym := Tai_symbol.createname_global(item.str,AT_FUNCTION,0)
+            else
+              sym := Tai_symbol.createname(item.str,AT_FUNCTION,0);
+            sym.free;
+            item := tstringlistitem(item.next);
+          end;
+       end;
+
+
     procedure gen_proc_symbol(list:Taasmoutput);
       var
         hs : string;

+ 7 - 10
compiler/psub.pas

@@ -608,7 +608,7 @@ implementation
         oldprocinfo : tprocinfo;
         oldaktmaxfpuregisters : longint;
         oldfilepos : tfileposinfo;
-        templist, symlist : Taasmoutput;
+        templist : Taasmoutput;
         headertai : tai;
       begin
         { the initialization procedure can be empty, then we
@@ -636,7 +636,6 @@ implementation
         aktbreaklabel:=nil;
         aktcontinuelabel:=nil;
         templist:=Taasmoutput.create;
-        symlist:=Taasmoutput.create;
 
         { add parast/localst to symtablestack }
         add_to_symtablestack;
@@ -709,12 +708,6 @@ implementation
                 procdef.has_paraloc_info:=true;
               end;
 
-            { allocate the symbol associated with the procedure, so that }
-            { references to itself are not treated as references to      }
-            { externals                                                  }
-            aktfilepos:=entrypos;
-            gen_proc_symbol(symlist);
-          
             { generate code for the node tree }
             do_secondpass(code);
             aktproccode.concatlist(exprasmlist);
@@ -777,9 +770,10 @@ implementation
 
             { generate symbol and save end of header position }
             aktfilepos:=entrypos;
-            headertai:=tai(symlist.last);
+            gen_proc_symbol(templist);
+            headertai:=tai(templist.last);
             { insert symbol }
-            aktproccode.insertlist(symlist);
+            aktproccode.insertlist(templist);
 
             { Free space in temp/registers for parast and localst, must be
               done after gen_entry_code }
@@ -900,6 +894,9 @@ implementation
       var
         _class,hp : tobjectdef;
       begin
+        { allocate the symbol for this procedure }
+        alloc_proc_symbol(procdef);
+
         { insert symtables for the class, but only if it is no nested function }
         if assigned(procdef._class) and
            not(assigned(parent) and