From 8e1dd27896a9128b8b4727305d73442e62a7246d Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 31 May 2006 11:49:37 +0000 Subject: [PATCH] * properly copy tasmlabels when generating altsymbols git-svn-id: trunk@3753 - --- compiler/aasmbase.pas | 33 +++++++++++++++++++++++++++++++-- compiler/aasmdata.pas | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/compiler/aasmbase.pas b/compiler/aasmbase.pas index 48fe365996..f8ee2f15e4 100644 --- a/compiler/aasmbase.pas +++ b/compiler/aasmbase.pas @@ -89,11 +89,13 @@ interface { Cached objsymbol } cachedobjsymbol : TObject; constructor create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype); + function getaltcopy(altnr: longint): tasmsymbol; virtual; function is_used:boolean; procedure increfs; procedure decrefs; function getrefs: longint; end; + TAsmSymbolClass = class of TAsmSymbol; TAsmLabel = class(TAsmSymbol) labelnr : longint; @@ -101,6 +103,7 @@ interface is_set : boolean; constructor createlocal(nr:longint;ltyp:TAsmLabelType); constructor createglobal(const modulename:string;nr:longint;ltyp:TAsmLabelType); + function getaltcopy(altnr: longint): tasmsymbol; override; function getname:string;override; end; @@ -251,6 +254,15 @@ implementation end; + function tasmsymbol.getaltcopy(altnr: longint): tasmsymbol; + begin + result := TAsmSymbol(TAsmSymbolClass(classtype).createname(name+'_'+tostr(altnr))); + result.bind:=bind; + result.typ:=typ; + result.refs:=0; + end; + + function tasmsymbol.is_used:boolean; begin is_used:=(refs>0); @@ -282,7 +294,7 @@ implementation *****************************************************************************} constructor tasmlabel.createlocal(nr:longint;ltyp:TAsmLabelType); - begin; + begin inherited create(target_asm.labelprefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,AT_LABEL); labelnr:=nr; labeltype:=ltyp; @@ -291,7 +303,7 @@ implementation constructor tasmlabel.createglobal(const modulename:string;nr:longint;ltyp:TAsmLabelType); - begin; + begin inherited create('_$'+modulename+'$_L'+asmlabeltypeprefix[ltyp]+tostr(nr),AB_GLOBAL,AT_DATA); labelnr:=nr; labeltype:=ltyp; @@ -301,6 +313,23 @@ implementation end; + function tasmlabel.getaltcopy(altnr: longint): tasmsymbol; + begin; + result := inherited getaltcopy(altnr); + tasmlabel(result).labelnr:=labelnr; + tasmlabel(result).labeltype:=labeltype; + tasmlabel(result).is_set:=false; + case bind of + AB_GLOBAL: + result.increfs; + AB_LOCAL: + ; + else + internalerror(2006053101); + end; + end; + + function tasmlabel.getname:string; begin getname:=inherited getname; diff --git a/compiler/aasmdata.pas b/compiler/aasmdata.pas index 82b846e495..5db9d94851 100644 --- a/compiler/aasmdata.pas +++ b/compiler/aasmdata.pas @@ -369,7 +369,7 @@ implementation begin if not assigned(p.altsymbol) then begin - p.altsymbol:=tasmsymbol.create(p.name+'_'+tostr(FNextAltNr),p.bind,p.typ); + p.altsymbol:=p.getaltcopy(FNextAltNr); FAsmSymbolDict.insert(p.altsymbol); FAltSymbolList.Add(p); end;