Browse Source

* generate the procsymbol before generating the code for the procedure,
so that refences to this symbol are not treated as external

git-svn-id: trunk@2009 -

Jonas Maebe 19 years ago
parent
commit
b954ea006e
1 changed files with 10 additions and 4 deletions
  1. 10 4
      compiler/psub.pas

+ 10 - 4
compiler/psub.pas

@@ -608,7 +608,7 @@ implementation
         oldprocinfo : tprocinfo;
         oldaktmaxfpuregisters : longint;
         oldfilepos : tfileposinfo;
-        templist : Taasmoutput;
+        templist, symlist : Taasmoutput;
         headertai : tai;
         curralign : longint;
       begin
@@ -637,6 +637,7 @@ implementation
         aktbreaklabel:=nil;
         aktcontinuelabel:=nil;
         templist:=Taasmoutput.create;
+        symlist:=Taasmoutput.create;
 
         { add parast/localst to symtablestack }
         add_to_symtablestack;
@@ -682,6 +683,12 @@ implementation
             set_first_temp_offset;
             generate_parameter_info;
 
+            { 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);
+          
             { Allocate space in temp/registers for parast and localst }
             aktfilepos:=entrypos;
             gen_alloc_symtable(aktproccode,procdef.parast);
@@ -771,10 +778,9 @@ implementation
 
             { generate symbol and save end of header position }
             aktfilepos:=entrypos;
-            gen_proc_symbol(templist);
-            headertai:=tai(templist.last);
+            headertai:=tai(symlist.last);
             { insert symbol }
-            aktproccode.insertlist(templist);
+            aktproccode.insertlist(symlist);
 
             { Free space in temp/registers for parast and localst, must be
               done after gen_entry_code }