Browse Source

+ better reference pos for forward defs

pierre 26 years ago
parent
commit
d766ee87fc
3 changed files with 32 additions and 7 deletions
  1. 6 2
      compiler/symdef.inc
  2. 6 2
      compiler/symdefh.inc
  3. 20 3
      compiler/symtable.pas

+ 6 - 2
compiler/symdef.inc

@@ -3768,7 +3768,7 @@ Const local_symtable_index : longint = $8001;
                                 TFORWARDDEF
 ****************************************************************************}
 
-   constructor tforwarddef.init(const s:string);
+   constructor tforwarddef.init(const s:string;const pos : tfileposinfo);
      var
        oldregisterdef : boolean;
      begin
@@ -3780,6 +3780,7 @@ Const local_symtable_index : longint = $8001;
         registerdef:=oldregisterdef;
         deftype:=forwarddef;
         tosymname:=s;
+        forwardpos:=pos;
      end;
 
 
@@ -3815,7 +3816,10 @@ Const local_symtable_index : longint = $8001;
 
 {
   $Log$
-  Revision 1.175  1999-11-07 23:57:36  pierre
+  Revision 1.176  1999-11-09 23:35:49  pierre
+   + better reference pos for forward defs
+
+  Revision 1.175  1999/11/07 23:57:36  pierre
    + higher level browser
 
   Revision 1.174  1999/11/06 14:34:26  peter

+ 6 - 2
compiler/symdefh.inc

@@ -140,7 +140,8 @@
        pforwarddef = ^tforwarddef;
        tforwarddef = object(tdef)
           tosymname : string;
-          constructor init(const s:string);
+          forwardpos : tfileposinfo;
+          constructor init(const s:string;const pos : tfileposinfo);
           function  gettypename:string;virtual;
        end;
 
@@ -530,7 +531,10 @@
 
 {
   $Log$
-  Revision 1.45  1999-11-06 14:34:27  peter
+  Revision 1.46  1999-11-09 23:35:50  pierre
+   + better reference pos for forward defs
+
+  Revision 1.45  1999/11/06 14:34:27  peter
     * truncated log to 20 revs
 
   Revision 1.44  1999/10/26 12:30:45  peter

+ 20 - 3
compiler/symtable.pas

@@ -1578,6 +1578,7 @@ implementation
     function tsymtable.speedsearch(const s : stringid;speedvalue : longint) : psym;
       var
         hp : psym;
+        newref : pref;
       begin
         hp:=psym(symsearch^.speedsearch(s,speedvalue));
         if assigned(hp) then
@@ -1604,11 +1605,24 @@ implementation
            if assigned(hp) and
               (cs_browser in aktmoduleswitches) and make_ref then
              begin
-                hp^.lastref:=new(pref,init(hp^.lastref,@tokenpos));
+                new(newref,init(hp^.lastref,@tokenpos));
                 { for symbols that are in tables without
                 browser info or syssyms (PM) }
                 if hp^.refcount=0 then
-                  hp^.defref:=hp^.lastref;
+                  begin
+                    hp^.defref:=newref;
+                    hp^.lastref:=newref;
+                  end
+                else
+                if resolving_forward and assigned(hp^.defref) then
+                { put it as second reference }
+                  begin
+                   newref^.nextref:=hp^.defref^.nextref;
+                   hp^.defref^.nextref:=newref;
+                   hp^.lastref^.nextref:=nil;
+                  end
+                else
+                  hp^.lastref:=newref;
                 inc(hp^.refcount);
              end;
          end;
@@ -2468,7 +2482,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.59  1999-11-06 16:21:57  jonas
+  Revision 1.60  1999-11-09 23:35:50  pierre
+   + better reference pos for forward defs
+
+  Revision 1.59  1999/11/06 16:21:57  jonas
     + search optimial register to use in alignment code (compile with
       -dalignreg, -dalignregdebug to see chosen register in
       assembler code). Still needs support in ag386bin.