From dbf94f4713f7748946434fdb08954efc77ab2b60 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Thu, 22 Dec 2005 20:43:29 +0000 Subject: [PATCH] * properly fixed allocating procedure symbols, now also works for nested procedures git-svn-id: trunk@2029 - --- compiler/ncgutil.pas | 20 ++++++++++++++++++++ compiler/psub.pas | 17 +++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index 043b0d9c62..ba8b13e4d6 100644 --- a/compiler/ncgutil.pas +++ b/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); @@ -1647,6 +1648,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; diff --git a/compiler/psub.pas b/compiler/psub.pas index edf54ee03a..76a7d97d6f 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -609,7 +609,7 @@ implementation oldprocinfo : tprocinfo; oldaktmaxfpuregisters : longint; oldfilepos : tfileposinfo; - templist, symlist : Taasmoutput; + templist : Taasmoutput; headertai : tai; curralign : longint; begin @@ -642,7 +642,6 @@ implementation aktbreaklabel:=nil; aktcontinuelabel:=nil; templist:=Taasmoutput.create; - symlist:=Taasmoutput.create; { add parast/localst to symtablestack } add_to_symtablestack; @@ -688,12 +687,6 @@ 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); @@ -783,9 +776,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 } @@ -911,6 +905,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