mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 17:59:37 +01:00
* get proper moduleindex when loading a unit, fixes #4778
git-svn-id: trunk@5097 -
This commit is contained in:
parent
568e21ef1d
commit
2974bbaf10
@ -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_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:=tmodule(loaded_units.first);
|
||||
while assigned(hp) and (hp.unit_index<>moduleindex) do
|
||||
hp:=tmodule(hp.next);
|
||||
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);
|
||||
|
||||
@ -111,7 +111,7 @@ interface
|
||||
line : longint;
|
||||
column : word;
|
||||
fileindex : word;
|
||||
{ moduleindex : word; }
|
||||
moduleindex : word;
|
||||
end;
|
||||
|
||||
tcodepagestring = string[20];
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user