浏览代码

* get proper moduleindex when loading a unit, fixes #4778

git-svn-id: trunk@5097 -
florian 19 年之前
父节点
当前提交
2974bbaf10
共有 5 个文件被更改,包括 39 次插入16 次删除
  1. 18 2
      compiler/fmodule.pas
  2. 1 1
      compiler/globals.pas
  3. 1 0
      compiler/scanner.pas
  4. 3 2
      compiler/symtype.pas
  5. 16 11
      compiler/verbose.pas

+ 18 - 2
compiler/fmodule.pas

@@ -195,6 +195,7 @@ interface
        SmartLinkOFiles   : TStringList; { List of .o files which are generated,
                                           used to delete them after linking }
 
+    function get_module(moduleindex : longint) : tmodule;
     function get_source_file(moduleindex,fileindex : longint) : tinputfile;
     procedure addloadedunit(hp:tmodule);
 
@@ -217,13 +218,28 @@ implementation
                              Global Functions
 *****************************************************************************}
 
-    function get_source_file(moduleindex,fileindex : longint) : tinputfile;
+    function get_module(moduleindex : longint) : tmodule;
       var
          hp : tmodule;
       begin
+         result:=nil;
+         if moduleindex=0 then
+           exit;
+         result:=current_module;
+         if not(assigned(loaded_units)) then
+           exit;
          hp:=tmodule(loaded_units.first);
          while assigned(hp) and (hp.unit_index<>moduleindex) do
            hp:=tmodule(hp.next);
+         result:=hp;
+      end;
+
+
+    function get_source_file(moduleindex,fileindex : longint) : tinputfile;
+      var
+         hp : tmodule;
+      begin
+         hp:=get_module(moduleindex);
          if assigned(hp) then
           get_source_file:=hp.sourcefiles.get_file(fileindex)
          else
@@ -585,7 +601,7 @@ implementation
             localmacrosymtable.free;
             localmacrosymtable:=nil;
           end;
-        deflist.free;  
+        deflist.free;
         deflist:=TFPObjectList.Create(false);
         symlist.free;
         symlist:=TFPObjectList.Create(false);

+ 1 - 1
compiler/globals.pas

@@ -111,7 +111,7 @@ interface
          line      : longint;
          column    : word;
          fileindex : word;
-         { moduleindex : word; }
+         moduleindex : word;
        end;
 
        tcodepagestring = string[20];

+ 1 - 0
compiler/scanner.pas

@@ -2085,6 +2085,7 @@ In case not, the value returned can be arbitrary.
         akttokenpos.line:=line_no;
         akttokenpos.column:=lasttokenpos-lastlinepos;
         akttokenpos.fileindex:=inputfile.ref_index;
+        akttokenpos.moduleindex:=current_module.unit_index;
         aktfilepos:=akttokenpos;
       end;
 

+ 3 - 2
compiler/symtype.pas

@@ -625,8 +625,8 @@ implementation
         addconst(slt,v,nil);
         lastsym^.valuedefderef:=d;
       end;
-      
-      
+
+
     procedure tpropaccesslist.addtypederef(slt:tsltype;d:tderef);
       begin
         addtype(slt,nil);
@@ -879,6 +879,7 @@ implementation
          2 : p.column:=(getbyte shl 16) or getword;
          3 : p.column:=getlongint;
         end;
+        p.moduleindex:=current_module.unit_index;
       end;
 
 

+ 16 - 11
compiler/verbose.pas

@@ -118,7 +118,7 @@ interface
 implementation
 
     uses
-      comphook;
+      comphook,fmodule;
 
 var
   compiling_module : tmodulebase;
@@ -362,23 +362,28 @@ var
       end;
 
 
-      var
-        lastfileidx,
-        lastmoduleidx : longint;
+    var
+      lastfileidx,
+      lastmoduleidx : longint;
+
+
     Procedure UpdateStatus;
+      var
+        module : tmodulebase;
       begin
       { fix status }
         status.currentline:=aktfilepos.line;
         status.currentcolumn:=aktfilepos.column;
-        if assigned(compiling_module) and
-           assigned(compiling_module.sourcefiles) and
-           ((compiling_module.unit_index<>lastmoduleidx) or
+        module:=get_module(aktfilepos.moduleindex);
+        if assigned(module) and
+           assigned(module.sourcefiles) and
+           ((module.unit_index<>lastmoduleidx) or
             (aktfilepos.fileindex<>lastfileidx)) then
          begin
            { update status record }
-           status.currentmodule:=compiling_module.modulename^;
-           status.currentsource:=compiling_module.sourcefiles.get_file_name(aktfilepos.fileindex);
-           status.currentsourcepath:=compiling_module.sourcefiles.get_file_path(aktfilepos.fileindex);
+           status.currentmodule:=module.modulename^;
+           status.currentsource:=module.sourcefiles.get_file_name(aktfilepos.fileindex);
+           status.currentsourcepath:=module.sourcefiles.get_file_path(aktfilepos.fileindex);
            { update lastfileidx only if name known PM }
            if status.currentsource<>'' then
              lastfileidx:=aktfilepos.fileindex
@@ -386,7 +391,7 @@ var
              lastfileidx:=0;
            lastmoduleidx:=compiling_module.unit_index;
          end;
-        if assigned(compiling_module) then
+        if assigned(module) then
           status.compiling_current:=(compiling_module.state in [ms_compile,ms_second_compile]);
       end;