فهرست منبع

* local browsing works at first level
ie for function defined in interface or implementation
not yet for functions inside other functions

pierre 26 سال پیش
والد
کامیت
25553ebfea
4فایلهای تغییر یافته به همراه155 افزوده شده و 59 حذف شده
  1. 20 5
      compiler/symdef.inc
  2. 15 1
      compiler/symppu.inc
  3. 6 3
      compiler/symsym.inc
  4. 114 50
      compiler/symtable.pas

+ 20 - 5
compiler/symdef.inc

@@ -217,7 +217,7 @@
                    is_in_current:=true;
                    exit;
                 end
-              else if p^.symtabletype=objectsymtable then
+              else if p^.symtabletype in [{localsymtable,parasymtable,}objectsymtable] then
                 begin
                   if assigned(p^.defowner) then
                     p:=pobjectdef(p^.defowner)^.owner
@@ -381,8 +381,6 @@
       { to avoid infinite loops }
       is_def_stab_written := true;
       stab_str := allstabstring;
-      if asmlist = debuglist then do_count_dbx := true;
-      { count_dbx(stab_str); moved to GDB.PAS}
       asmlist^.concat(new(pai_stabs,init(stab_str)));
       end;
     end;
@@ -1481,7 +1479,6 @@
                   end;
                 st := '"'+st+':t'+numberstring+'=*'+definition^.numberstring
                       +'=xs'+definition^.sym^.name+':",'+tostr(N_LSYM)+',0,'+tostr(sym_line_no)+',0';
-                if asmlist = debuglist then do_count_dbx := true;
                 asmlist^.concat(new(pai_stabs,init(strpnew(st))));
                 end;
               end else inherited concatstabto(asmlist);
@@ -2549,6 +2546,7 @@ Const local_symtable_index : longint = $8001;
         pos : tfileposinfo;
 {$ifndef NOLOCALBROWSER}
         pdo : pobjectdef;
+        st : psymtable;
 {$endif ndef NOLOCALBROWSER}
         move_last : boolean;
       begin
@@ -2569,12 +2567,19 @@ Const local_symtable_index : longint = $8001;
           begin
 {$ifndef NOLOCALBROWSER}
              pdo:=_class;
+             st:=aktlocalsymtable;
              new(parast,loadas(parasymtable));
+             aktlocalsymtable:=parast;
+             parast^.deref;
              parast^.next:=owner;
              parast^.load_browser;
+             aktlocalsymtable:=st;
              new(localst,loadas(localsymtable));
+             aktlocalsymtable:=localst;
+             localst^.deref;
              localst^.next:=parast;
              localst^.load_browser;
+             aktlocalsymtable:=st;
 {$endif ndef NOLOCALBROWSER}
           end;
       end;
@@ -2585,6 +2590,7 @@ Const local_symtable_index : longint = $8001;
         ref : pref;
 {$ifndef NOLOCALBROWSER}
         pdo : pobjectdef;
+        st : psymtable;
 {$endif ndef NOLOCALBROWSER}
         move_last : boolean;
       begin
@@ -2636,16 +2642,20 @@ Const local_symtable_index : longint = $8001;
                PPU files are then easier to read PM }
              if not assigned(parast) then
                parast:=new(psymtable,init(parasymtable));
+             st:=aktlocalsymtable;
+             aktlocalsymtable:=parast;
              parast^.writeas;
              parast^.unitid:=local_symtable_index;
              inc(local_symtable_index);
              parast^.write_browser;
              if not assigned(localst) then
                localst:=new(psymtable,init(localsymtable));
+             aktlocalsymtable:=localst;
              localst^.writeas;
              localst^.unitid:=local_symtable_index;
              inc(local_symtable_index);
              localst^.write_browser;
+             aktlocalsymtable:=st;
              { decrement for }
              local_symtable_index:=local_symtable_index-2;
              pdo:=_class;
@@ -3801,7 +3811,12 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.172  1999-10-26 12:30:45  peter
+  Revision 1.173  1999-11-05 17:18:02  pierre
+    * local browsing works at first level
+      ie for function defined in interface or implementation
+      not yet for functions inside other functions
+
+  Revision 1.172  1999/10/26 12:30:45  peter
     * const parameter is now checked
     * better and generic check if a node can be used for assigning
     * export fixes

+ 15 - 1
compiler/symppu.inc

@@ -111,6 +111,12 @@
               current_ppu^.putbyte(ord(derefaktrecordindex));
               current_ppu^.putword(p^.indexnr);
             end
+           { Local local/para symtable ? }
+           else if (p^.owner=aktlocalsymtable) then
+            begin
+              current_ppu^.putbyte(ord(derefaktlocal));
+              current_ppu^.putword(p^.indexnr);
+            end
            else
             begin
               current_ppu^.putbyte(ord(derefindex));
@@ -466,6 +472,7 @@
               break;
             derefunit,
             derefaktrecordindex,
+            derefaktlocal,
             derefaktstaticindex :
               begin
                 new(p,init(b,current_ppu^.getword));
@@ -473,6 +480,8 @@
                 break;
               end;
             derefindex,
+            dereflocal,
+            derefpara,
             derefrecord :
               begin
                 new(p,init(b,current_ppu^.getword));
@@ -747,7 +756,12 @@
 
 {
   $Log$
-  Revision 1.51  1999-09-16 13:27:08  pierre
+  Revision 1.52  1999-11-05 17:18:03  pierre
+    * local browsing works at first level
+      ie for function defined in interface or implementation
+      not yet for functions inside other functions
+
+  Revision 1.51  1999/09/16 13:27:08  pierre
     + error if PPU modulename is different from what is searched
       (8+3 limitations!)
     + cond ORDERSOURCES to allow recompilation of FP

+ 6 - 3
compiler/symsym.inc

@@ -191,7 +191,6 @@
          if not isstabwritten then
            begin
               stab_str := stabstring;
-              if asmlist = debuglist then do_count_dbx := true;
               { count_dbx(stab_str); moved to GDB.PAS }
               asmlist^.concat(new(pai_stabs,init(stab_str)));
               isstabwritten:=true;
@@ -2140,7 +2139,12 @@
 
 {
   $Log$
-  Revision 1.122  1999-10-21 16:41:41  florian
+  Revision 1.123  1999-11-05 17:18:03  pierre
+    * local browsing works at first level
+      ie for function defined in interface or implementation
+      not yet for functions inside other functions
+
+  Revision 1.122  1999/10/21 16:41:41  florian
     * problems with readln fixed: esi wasn't restored correctly when
       reading ordinal fields of objects futher the register allocation
       didn't take care of the extra register when reading ordinal values
@@ -2641,4 +2645,3 @@
     * symtable adapted for $ifndef OLDPPU
 
 }
-

+ 114 - 50
compiler/symtable.pas

@@ -83,7 +83,7 @@ unit symtable;
       { Deref entry options }
       tdereftype = (derefnil,derefaktrecordindex,derefaktstaticindex,
                     derefunit,derefrecord,derefindex,
-                    dereflocal,derefpara);
+                    dereflocal,derefpara,derefaktlocal);
 
       pderef = ^tderef;
       tderef = object
@@ -450,6 +450,7 @@ implementation
   var
      aktrecordsymtable : psymtable; { current record read from ppu symtable }
      aktstaticsymtable : psymtable; { current static for local ppu symtable }
+     aktlocalsymtable  : psymtable; { current proc local for local ppu symtable }
 {$ifdef GDB}
      asmoutput : paasmoutput;
 {$endif GDB}
@@ -729,6 +730,11 @@ implementation
                  st:=aktstaticsymtable;
                  idx:=p^.index;
                end;
+             derefaktlocal :
+               begin
+                 st:=aktlocalsymtable;
+                 idx:=p^.index;
+               end;
              derefunit :
                begin
 {$ifdef NEWMAP}
@@ -1318,10 +1324,16 @@ implementation
          new(symsearch,init);
          symsearch^.noclear:=true;
          defowner:=nil;
-         storesymtable:=aktrecordsymtable;
-         if typ in [recordsymtable,objectsymtable,
-                    parasymtable,localsymtable] then
-           aktrecordsymtable:=@self;
+         if typ in [recordsymtable,objectsymtable] then
+           begin
+             storesymtable:=aktrecordsymtable;
+             aktrecordsymtable:=@self;
+           end;
+         if typ in [parasymtable,localsymtable] then
+           begin
+             storesymtable:=aktlocalsymtable;
+             aktlocalsymtable:=@self;
+           end;
          { used for local browser }
          if typ=staticppusymtable then
            begin
@@ -1338,7 +1350,7 @@ implementation
 
       { load definitions }
       { we need the correct symtable for registering }
-         if not (typ in [recordsymtable,objectsymtable]) then
+         if not (typ in [localsymtable,parasymtable,recordsymtable,objectsymtable]) then
            begin
              next:=symtablestack;
              symtablestack:=@self;
@@ -1351,11 +1363,15 @@ implementation
          loadsyms;
 
       { now we can deref the syms and defs }
-         if not (typ in [recordsymtable,objectsymtable]) then
+         if not (typ in [localsymtable,parasymtable,
+                         recordsymtable,objectsymtable]) then
            deref;
 
-         aktrecordsymtable:=storesymtable;
-         if not (typ in [recordsymtable,objectsymtable]) then
+         if typ in [recordsymtable,objectsymtable] then
+           aktrecordsymtable:=storesymtable;
+         if typ in [localsymtable,parasymtable] then
+           aktlocalsymtable:=storesymtable;
+         if not (typ in [localsymtable,parasymtable,recordsymtable,objectsymtable]) then
            begin
              symtablestack:=next;
            end;
@@ -1370,9 +1386,16 @@ implementation
       begin
          oldtyp:=current_ppu^.entrytyp;
          storesymtable:=aktrecordsymtable;
-         if symtabletype in [recordsymtable,objectsymtable,
-                    parasymtable,localsymtable] then
-           aktrecordsymtable:=@self;
+         if symtabletype in [recordsymtable,objectsymtable] then
+           begin
+             storesymtable:=aktrecordsymtable;
+             aktrecordsymtable:=@self;
+           end;
+         if symtabletype in [parasymtable,localsymtable] then
+           begin
+             storesymtable:=aktlocalsymtable;
+             aktlocalsymtable:=@self;
+           end;
          if (symtabletype in [recordsymtable,objectsymtable]) then
          current_ppu^.entrytyp:=subentryid;
          { write definitions }
@@ -1380,7 +1403,10 @@ implementation
          { write symbols }
          writesyms;
          current_ppu^.entrytyp:=oldtyp;
-         aktrecordsymtable:=storesymtable;
+         if symtabletype in [recordsymtable,objectsymtable] then
+           aktrecordsymtable:=storesymtable;
+         if symtabletype in [localsymtable,parasymtable] then
+           aktlocalsymtable:=storesymtable;
       end;
 
 
@@ -1604,12 +1630,16 @@ implementation
         prdef : pdef;
         oldrecsyms : psymtable;
       begin
-         if symtabletype in [recordsymtable,objectsymtable,
-                    parasymtable,localsymtable] then
+         if symtabletype in [recordsymtable,objectsymtable] then
            begin
               oldrecsyms:=aktrecordsymtable;
               aktrecordsymtable:=@self;
            end;
+         if symtabletype in [parasymtable,localsymtable] then
+           begin
+              oldrecsyms:=aktlocalsymtable;
+              aktlocalsymtable:=@self;
+           end;
          if symtabletype=staticppusymtable then
            aktstaticsymtable:=@self;
          b:=current_ppu^.readentry;
@@ -1639,9 +1669,10 @@ implementation
              Message1(unit_f_ppu_invalid_entry,tostr(b));
            end;
          until false;
-         if symtabletype in [recordsymtable,objectsymtable,
-                    parasymtable,localsymtable] then
-           aktrecordsymtable:=oldrecsyms;
+        if symtabletype in [recordsymtable,objectsymtable] then
+          aktrecordsymtable:=oldrecsyms;
+        if symtabletype in [parasymtable,localsymtable] then
+          aktlocalsymtable:=oldrecsyms;
       end;
 
 
@@ -1654,18 +1685,23 @@ implementation
          number_symbols;
          number_defs;   }
 
-         if symtabletype in [recordsymtable,objectsymtable,
-                    parasymtable,localsymtable] then
+         if symtabletype in [recordsymtable,objectsymtable] then
            begin
               oldrecsyms:=aktrecordsymtable;
               aktrecordsymtable:=@self;
            end;
+         if symtabletype in [parasymtable,localsymtable] then
+           begin
+              oldrecsyms:=aktlocalsymtable;
+              aktlocalsymtable:=@self;
+           end;
          current_ppu^.writeentry(ibbeginsymtablebrowser);
          foreach({$ifndef TP}@{$endif}write_refs);
          current_ppu^.writeentry(ibendsymtablebrowser);
-         if symtabletype in [recordsymtable,objectsymtable,
-                    parasymtable,localsymtable] then
-           aktrecordsymtable:=oldrecsyms;
+        if symtabletype in [recordsymtable,objectsymtable] then
+          aktrecordsymtable:=oldrecsyms;
+        if symtabletype in [parasymtable,localsymtable] then
+          aktlocalsymtable:=oldrecsyms;
       end;
 
 
@@ -1789,21 +1825,26 @@ implementation
          symsearch^.usehash;
        { reset GDB things }
 {$ifdef GDB}
-         if t = globalsymtable then
+         if (t = globalsymtable) then
            begin
               prev_dbx_counter := dbx_counter;
-              dbx_counter := @dbx_count;
+              dbx_counter := nil;
            end;
          is_stab_written:=false;
+         dbx_count := -1;
          if cs_gdb_dbx in aktglobalswitches then
            begin
              dbx_count := 0;
+             unittypecount:=1;
              if (symtabletype=globalsymtable) then
                pglobaltypecount := @unittypecount;
-             debuglist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0'))));
              unitid:=current_module^.unitcount;
-             inc(current_module^.unitcount);
              debuglist^.concat(new(pai_asm_comment,init(strpnew('Global '+name^+' has index '+tostr(unitid)))));
+             debuglist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'+tostr(N_BINCL)+',0,0,0'))));
+             inc(current_module^.unitcount);
+             dbx_count_ok:=false;
+             dbx_counter:=@dbx_count;
+             do_count_dbx:=true;
            end;
 {$endif GDB}
       end;
@@ -1816,11 +1857,14 @@ implementation
       begin
          unitsym:=nil;
          unitid:=0;
-         if (current_module^.flags and uf_has_dbx)<>0 then
+{$ifdef GDB}
+         if cs_gdb_dbx in aktglobalswitches then
            begin
+              UnitTypeCount:=1;
               storeGlobalTypeCount:=PGlobalTypeCount;
               PglobalTypeCount:=@UnitTypeCount;
            end;
+{$endif GDB}
 
        { load symtables }
          inherited load;
@@ -1837,10 +1881,14 @@ implementation
               else
                dbx_count := readlong;
               dbx_count_ok := true;
-              PGlobalTypeCount:=storeGlobalTypeCount;
            end
          else
-           dbx_count := 0;
+           begin
+             dbx_count := -1;
+             dbx_count_ok:=false;
+           end;
+         if cs_gdb_dbx in aktglobalswitches then
+           PGlobalTypeCount:=storeGlobalTypeCount;
          is_stab_written:=false;
 {$endif GDB}
 
@@ -1932,6 +1980,9 @@ implementation
       { write the symtable entries }
         inherited write;
 
+      { all after doesn't affect crc }
+        current_ppu^.do_crc:=false;
+
       { write dbx count }
 {$ifdef GDB}
         if cs_gdb_dbx in aktglobalswitches then
@@ -1945,8 +1996,6 @@ implementation
 {$endif GDB}
 
         current_ppu^.writeentry(ibendimplementation);
-        { all after doesn't affect crc }
-        current_ppu^.do_crc:=false;
 
          { write static symtable
            needed for local debugging of unit functions }
@@ -1998,7 +2047,8 @@ implementation
         begin
            if is_stab_written then exit;
            if not assigned(name) then name := stringdup('Main_program');
-           if symtabletype = unitsymtable then
+           if (symtabletype = unitsymtable) and
+              (current_module^.globalsymtable<>@Self) then
              begin
                 unitid:=current_module^.unitcount;
                 inc(current_module^.unitcount);
@@ -2009,32 +2059,41 @@ implementation
              begin
                 if dbx_count_ok then
                   begin
-                     asmlist^.insert(new(pai_asm_comment,init(strpnew('"repeated" unit '+name^
-                              +' has index '+tostr(unitid)))));
-                     do_count_dbx:=true;
+                     asmlist^.concat(new(pai_asm_comment,init(strpnew('"repeated" unit '+name^
+                              +' has index '+tostr(unitid)+' dbx count = '+tostr(dbx_count)))));
                      asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
                        +tostr(N_EXCL)+',0,0,'+tostr(dbx_count)))));
                      exit;
+                  end
+                else if (current_module^.globalsymtable<>@Self) then
+                  begin
+                    prev_dbx_count := dbx_counter;
+                    dbx_counter := nil;
+                    do_count_dbx:=false;
+                    if symtabletype = unitsymtable then
+                      asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
+                        +tostr(N_BINCL)+',0,0,0'))));
+                    dbx_counter := @dbx_count;
+                    dbx_count:=0;
+                    do_count_dbx:=assigned(dbx_counter);
                   end;
-                prev_dbx_count := dbx_counter;
-                dbx_counter := nil;
-                if symtabletype = unitsymtable then
-                  asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
-                    +tostr(N_BINCL)+',0,0,0'))));
-                dbx_counter := @dbx_count;
              end;
            asmoutput:=asmlist;
            foreach({$ifndef TP}@{$endif}concattypestab);
            if cs_gdb_dbx in aktglobalswitches then
              begin
-                dbx_counter := prev_dbx_count;
-                do_count_dbx:=true;
-                asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
-                  +tostr(N_EINCL)+',0,0,0'))));
-                dbx_count_ok := true;
+                if (current_module^.globalsymtable<>@Self) then
+                  begin
+                    dbx_counter := prev_dbx_count;
+                    do_count_dbx:=false;
+                    asmlist^.concat(new(pai_asm_comment,init(strpnew('End unit '+name^
+                      +' has index '+tostr(unitid)))));
+                    asmlist^.concat(new(pai_stabs,init(strpnew('"'+name^+'",'
+                      +tostr(N_EINCL)+',0,0,0'))));
+                    do_count_dbx:=assigned(dbx_counter);
+                    dbx_count_ok := true;
+                  end;
              end;
-           asmlist^.concat(new(pai_asm_comment,init(strpnew('End unit '+name^
-                  +' has index '+tostr(unitid)))));
            is_stab_written:=true;
         end;
 {$endif}
@@ -2406,7 +2465,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.56  1999-11-04 23:13:25  peter
+  Revision 1.57  1999-11-05 17:18:03  pierre
+    * local browsing works at first level
+      ie for function defined in interface or implementation
+      not yet for functions inside other functions
+
+  Revision 1.56  1999/11/04 23:13:25  peter
     * moved unit alias support into ifdef
 
   Revision 1.55  1999/11/04 10:54:02  peter