Browse Source

* store hidden symbols correctly in ppu

git-svn-id: trunk@1751 -
peter 20 years ago
parent
commit
9a8dc6bfb2
3 changed files with 51 additions and 34 deletions
  1. 2 2
      compiler/pdecsub.pas
  2. 47 32
      compiler/symtable.pas
  3. 2 0
      tests/webtbs/tw2984.pp

+ 2 - 2
compiler/pdecsub.pas

@@ -793,7 +793,7 @@ implementation
                        symbol }
                      if (srsym.typ=unitsym) then
                       begin
-                        srsym.owner.rename(srsym.name,'hidden'+srsym.name);
+                        HideSym(srsym);
                         searchagain:=true;
                       end
                      else
@@ -802,7 +802,7 @@ implementation
                         if (m_fpc in aktmodeswitches) then
                          Message1(parser_e_overloaded_no_procedure,srsym.realname)
                         else
-                         tstoredsymtable(symtablestack).DuplicateSym(nil,srsym);
+                         DuplicateSym(nil,srsym);
                         { rename the name to an unique name to avoid an
                           error when inserting the symbol in the symtable }
                         orgsp:=orgsp+'$'+tostr(aktfilepos.line);

+ 47 - 32
compiler/symtable.pas

@@ -68,7 +68,6 @@ interface
           procedure buildderefimpl;virtual;
           procedure deref;virtual;
           procedure derefimpl;virtual;
-          procedure duplicatesym(dupsym,sym:tsymentry);
           procedure insert(sym : tsymentry);override;
           procedure reset_all_defs;virtual;
           function  speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
@@ -184,6 +183,8 @@ interface
     function  findunitsymtable(st:tsymtable):tsymtable;
     function  FullTypeName(def,otherdef:tdef):string;
     procedure incompatibletypes(def1,def2:tdef);
+    procedure hidesym(sym:tsymentry);
+    procedure duplicatesym(dupsym,sym:tsymentry);
 
 {*** Search ***}
     function  searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
@@ -268,9 +269,6 @@ implementation
       procinfo
       ;
 
-    var
-      dupnr : longint; { unique number for duplicate symbols }
-
 
 {*****************************************************************************
                              TStoredSymtable
@@ -566,31 +564,6 @@ implementation
       end;
 
 
-    procedure tstoredsymtable.duplicatesym(dupsym,sym:tsymentry);
-      var
-        st : tsymtable;
-      begin
-        Message1(sym_e_duplicate_id,tsym(sym).realname);
-        st:=findunitsymtable(sym.owner);
-        with tsym(sym).fileinfo do
-          begin
-            if assigned(st) and
-               (st.symtabletype=globalsymtable) and
-               (not st.iscurrentunit) then
-              Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
-            else
-              Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
-          end;
-        { Rename duplicate sym to an unreachable name, but it can be
-          inserted in the symtable without errors }
-        if assigned(dupsym) then
-          begin
-            inc(dupnr);
-            dupsym.name:='dup'+tostr(dupnr)+dupsym.name;
-          end;
-      end;
-
-
     procedure tstoredsymtable.insert(sym:tsymentry);
       var
          hsym : tsym;
@@ -1204,7 +1177,7 @@ implementation
                (vo_is_funcret in tabstractvarsym(hsym).varoptions) and
                not((m_result in aktmodeswitches) and
                    (vo_is_result in tabstractvarsym(hsym).varoptions)) then
-              hsym.owner.rename(hsym.name,'hidden'+hsym.name)
+              HideSym(hsym)
             else
               DuplicateSym(sym,hsym);
           end;
@@ -1375,7 +1348,7 @@ implementation
                  <unit>.<id>, so we can hide the symbol }
                if (m_duplicate_names in aktmodeswitches) and
                   (hsym.typ=symconst.unitsym) then
-                hsym.owner.rename(hsym.name,'hidden'+hsym.name)
+                HideSym(hsym)
                else
                 DuplicateSym(sym,hsym);
              end;
@@ -1443,7 +1416,7 @@ implementation
               <unit>.<id>, so we can hide the symbol }
             if (m_duplicate_names in aktmodeswitches) and
                (hsym.typ=symconst.unitsym) then
-             hsym.owner.rename(hsym.name,'hidden'+hsym.name)
+             HideSym(hsym)
             else
              DuplicateSym(sym,hsym);
           end;
@@ -1590,6 +1563,48 @@ implementation
       end;
 
 
+    procedure hidesym(sym:tsymentry);
+      var
+        s : string;
+      begin
+        if assigned(sym.owner) then
+          sym.owner.rename(sym.name,'hidden'+sym.name)
+        else
+          sym.name:='hidden'+sym.name;
+        s:='hidden'+tsym(sym).realname;
+        stringdispose(tsym(sym)._realname);
+        tsym(sym)._realname:=stringdup(s);
+      end;
+
+
+      var
+        dupnr : longint; { unique number for duplicate symbols }
+
+    procedure duplicatesym(dupsym,sym:tsymentry);
+      var
+        st : tsymtable;
+      begin
+        Message1(sym_e_duplicate_id,tsym(sym).realname);
+        st:=findunitsymtable(sym.owner);
+        with tsym(sym).fileinfo do
+          begin
+            if assigned(st) and
+               (st.symtabletype=globalsymtable) and
+               (not st.iscurrentunit) then
+              Message2(sym_h_duplicate_id_where,'unit '+st.name^,tostr(line))
+            else
+              Message2(sym_h_duplicate_id_where,current_module.sourcefiles.get_file_name(fileindex),tostr(line));
+          end;
+        { Rename duplicate sym to an unreachable name, but it can be
+          inserted in the symtable without errors }
+        if assigned(dupsym) then
+          begin
+            inc(dupnr);
+            dupsym.name:='dup'+tostr(dupnr)+dupsym.name;
+          end;
+      end;
+
+
 {*****************************************************************************
                                   Search
 *****************************************************************************}

+ 2 - 0
tests/webtbs/tw2984.pp

@@ -1,3 +1,5 @@
+{ %recompile }
+
 uses
   uw2984;