Browse Source

* external used before implemented problem fixed

pierre 26 years ago
parent
commit
f2eb2dc540
2 changed files with 53 additions and 3 deletions
  1. 37 1
      compiler/aasm.pas
  2. 16 2
      compiler/cobjects.pas

+ 37 - 1
compiler/aasm.pas

@@ -319,6 +319,7 @@ type
       asmsymbollist : pasmsymbollist;
 
     function newasmsymbol(const s : string) : pasmsymbol;
+    function renameasmsymbol(const sold, snew : string) : pasmsymbol;
 
   { label functions }
     const
@@ -824,6 +825,38 @@ uses
       end;
 
 
+    { renames an asmsymbol }
+    function renameasmsymbol(const sold, snew : string) : pasmsymbol;
+      var
+        hpold,hpnew : pasmsymbol;
+      begin
+        hpnew:=pasmsymbol(asmsymbollist^.search(snew));
+        if assigned(hpnew) then
+          internalerror(405405);
+        hpold:=pasmsymbol(asmsymbollist^.search(sold));
+        if not assigned(hpold) then
+          internalerror(405406);
+          
+        hpnew:=new(pasmsymbol,init(sold));
+        { replace the old one }
+        { WARNING this heavily depends on the
+          feature that tdictionnary.insert does not delete
+          the tree element that it replaces !! }
+        asmsymbollist^.replace_existing:=true;
+        asmsymbollist^.insert(hpnew);
+        asmsymbollist^.replace_existing:=false;
+        { restore the tree }
+        hpnew^.left:=hpold^.left;
+        hpnew^.right:=hpold^.right;
+        stringdispose(hpold^._name);
+        hpold^._name:=stringdup(snew);
+        hpold^.speedvalue:=getspeedvalue(snew);
+        { now reinsert it at right location !! }
+        asmsymbollist^.insert(hpold);
+        renameasmsymbol:=hpold;
+      end;
+
+
 {*****************************************************************************
                               Label Helpers
 *****************************************************************************}
@@ -937,7 +970,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.31  1999-02-25 21:02:16  peter
+  Revision 1.32  1999-03-01 13:31:59  pierre
+   * external used before implemented problem fixed
+
+  Revision 1.31  1999/02/25 21:02:16  peter
     * ag386bin updates
     + coff writer
 

+ 16 - 2
compiler/cobjects.pas

@@ -163,6 +163,7 @@ unit cobjects;
         Tdictionary=object
             root:Pnamed_object;
             hasharray:Pdictionaryhasharray;
+            replace_existing : boolean;
             constructor init(usehash:boolean);
             procedure clear;virtual;
             procedure foreach(proc2call:Tcallback);
@@ -859,6 +860,7 @@ constructor Tdictionary.init(usehash:boolean);
 begin
     root:=nil;
     hasharray:=nil;
+    replace_existing:=false;
     if usehash then
         begin
             new(hasharray);
@@ -962,7 +964,16 @@ function Tdictionary.insert(obj:Pnamed_object):Pnamed_object;
                                 begin
                                     dispose(s2);
                                     dispose(s1);
-                                    _insert:=osym;
+                                    if replace_existing and
+                                       assigned(osym) then
+                                      begin
+                                        obj^.left:=osym^.left;
+                                        obj^.right:=osym^.right;
+                                        osym:=obj;
+                                        _insert:=obj;
+                                      end
+                                    else
+                                      _insert:=osym;
                                 end;
                     end;
     end;
@@ -1413,7 +1424,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.18  1999-02-24 00:59:13  peter
+  Revision 1.19  1999-03-01 13:32:00  pierre
+   * external used before implemented problem fixed
+
+  Revision 1.18  1999/02/24 00:59:13  peter
     * small updates for ag386bin
 
   Revision 1.17  1999/01/19 11:00:33  daniel