Преглед на файлове

* properly copy tasmlabels when generating altsymbols

git-svn-id: trunk@3753 -
Jonas Maebe преди 19 години
родител
ревизия
8e1dd27896
променени са 2 файла, в които са добавени 32 реда и са изтрити 3 реда
  1. 31 2
      compiler/aasmbase.pas
  2. 1 1
      compiler/aasmdata.pas

+ 31 - 2
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;

+ 1 - 1
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;