Browse Source

* better check for globalsymtable

peter 24 years ago
parent
commit
54b534cde7
2 changed files with 14 additions and 26 deletions
  1. 8 3
      compiler/pdecsub.pas
  2. 6 23
      compiler/symtable.pas

+ 8 - 3
compiler/pdecsub.pas

@@ -447,10 +447,12 @@ begin
           We need to find out if the procedure is global. If it is
           We need to find out if the procedure is global. If it is
           global, it is in the global symtable.}
           global, it is in the global symtable.}
          if not assigned(aktprocsym) and
          if not assigned(aktprocsym) and
-            (symtablestack.symtabletype=staticsymtable) then
+            (symtablestack.symtabletype=staticsymtable) and
+            assigned(symtablestack.next) and
+            (symtablestack.next.unitid=0) then
           begin
           begin
             {Search the procedure in the global symtable.}
             {Search the procedure in the global symtable.}
-            aktprocsym:=tprocsym(search_a_symtable(sp,globalsymtable));
+            aktprocsym:=tprocsym(symtablestack.next.search(sp));
             if assigned(aktprocsym) then
             if assigned(aktprocsym) then
              begin
              begin
                {Check if it is a procedure.}
                {Check if it is a procedure.}
@@ -1845,7 +1847,10 @@ const
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2001-04-13 18:03:16  peter
+  Revision 1.20  2001-04-13 20:05:16  peter
+    * better check for globalsymtable
+
+  Revision 1.19  2001/04/13 18:03:16  peter
     * give error with local external procedure
     * give error with local external procedure
 
 
   Revision 1.18  2001/04/13 01:22:11  peter
   Revision 1.18  2001/04/13 01:22:11  peter

+ 6 - 23
compiler/symtable.pas

@@ -214,7 +214,6 @@ interface
 
 
 {*** Search ***}
 {*** Search ***}
     function  searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
     function  searchsym(const s : stringid;var srsym:tsym;var srsymtable:tsymtable):boolean;
-    function  search_a_symtable(const symbol:string;symtabletype:tsymtabletype):tsym;
     function  searchsymonlyin(p : tsymtable;const s : stringid):tsym;
     function  searchsymonlyin(p : tsymtable;const s : stringid):tsym;
     function  search_class_member(pd : tobjectdef;const s : string):tsym;
     function  search_class_member(pd : tobjectdef;const s : string):tsym;
 
 
@@ -1868,7 +1867,8 @@ implementation
          hsym : tsym;
          hsym : tsym;
       begin
       begin
          { also check the global symtable }
          { also check the global symtable }
-         if assigned(next) then
+         if assigned(next) and
+            (next.unitid=0) then
           begin
           begin
             hsym:=tsym(next.search(sym.name));
             hsym:=tsym(next.search(sym.name));
             if assigned(hsym) then
             if assigned(hsym) then
@@ -2343,26 +2343,6 @@ implementation
       end;
       end;
 
 
 
 
-    function search_a_symtable(const symbol:string;symtabletype:tsymtabletype):tsym;
-    {Search for a symbol in a specified symbol table. Returns nil if
-     the symtable is not found, and also if the symbol cannot be found
-     in the desired symtable }
-    var hsymtab:tsymtable;
-        res:tsym;
-    begin
-        res:=nil;
-        hsymtab:=symtablestack;
-        while (hsymtab<>nil) and (hsymtab.symtabletype<>symtabletype) do
-            hsymtab:=hsymtab.next;
-        if hsymtab<>nil then
-            {We found the desired symtable. Now check if the symbol we
-             search for is defined in it }
-            res:=tsym(hsymtab.search(symbol));
-        search_a_symtable:=res;
-    end;
-
-
-
 {*****************************************************************************
 {*****************************************************************************
                             Definition Helpers
                             Definition Helpers
 *****************************************************************************}
 *****************************************************************************}
@@ -2587,7 +2567,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.32  2001-04-13 18:08:37  peter
+  Revision 1.33  2001-04-13 20:05:15  peter
+    * better check for globalsymtable
+
+  Revision 1.32  2001/04/13 18:08:37  peter
     * scanner object to class
     * scanner object to class
 
 
   Revision 1.31  2001/04/13 01:22:16  peter
   Revision 1.31  2001/04/13 01:22:16  peter