mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-28 18:03:29 +02:00
* cleanup current module status
* new set_current_module function that sets the current_module and all related variables. Also closes scanner files if required, but that might still need some optimization to prevent closing/opening files too often git-svn-id: trunk@7428 -
This commit is contained in:
parent
085689af60
commit
e2db0a3982
@ -98,8 +98,7 @@ type
|
||||
use_redir,
|
||||
use_bugreport,
|
||||
use_gccoutput,
|
||||
print_source_path,
|
||||
compiling_current : boolean;
|
||||
print_source_path : boolean;
|
||||
{ Redirection support }
|
||||
redirfile : text;
|
||||
{ Special file for bug report }
|
||||
|
@ -178,7 +178,7 @@ begin
|
||||
{ this is needed here for the IDE
|
||||
in case of compilation failure
|
||||
at the previous compile }
|
||||
current_module:=nil;
|
||||
set_current_module(nil);
|
||||
{ read the arguments }
|
||||
read_arguments(cmd);
|
||||
{ inits which depend on arguments }
|
||||
|
@ -195,6 +195,7 @@ interface
|
||||
SmartLinkOFiles : TCmdStrList; { List of .o files which are generated,
|
||||
used to delete them after linking }
|
||||
|
||||
procedure set_current_module(p:tmodule);
|
||||
function get_module(moduleindex : longint) : tmodule;
|
||||
function get_source_file(moduleindex,fileindex : longint) : tinputfile;
|
||||
procedure addloadedunit(hp:tmodule);
|
||||
@ -218,6 +219,40 @@ implementation
|
||||
Global Functions
|
||||
*****************************************************************************}
|
||||
|
||||
procedure set_current_module(p:tmodule);
|
||||
begin
|
||||
{ save the state of the scanner }
|
||||
if assigned(current_scanner) then
|
||||
current_scanner.tempcloseinputfile;
|
||||
{ set new module }
|
||||
current_module:=p;
|
||||
{ restore previous module settings }
|
||||
Fillchar(current_filepos,0,sizeof(current_filepos));
|
||||
if assigned(current_module) then
|
||||
begin
|
||||
current_asmdata:=tasmdata(current_module.asmdata);
|
||||
{ restore scanner and file positions }
|
||||
current_scanner:=tscannerfile(current_module.scanner);
|
||||
if assigned(current_scanner) then
|
||||
begin
|
||||
current_scanner.tempopeninputfile;
|
||||
current_scanner.gettokenpos;
|
||||
parser_current_file:=current_scanner.inputfile.name^;
|
||||
end
|
||||
else
|
||||
begin
|
||||
current_filepos.moduleindex:=current_module.unit_index;
|
||||
parser_current_file:='';
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
current_asmdata:=nil;
|
||||
current_scanner:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function get_module(moduleindex : longint) : tmodule;
|
||||
var
|
||||
hp : tmodule;
|
||||
|
@ -1318,9 +1318,7 @@ uses
|
||||
{ reset }
|
||||
do_load:=true;
|
||||
second_time:=false;
|
||||
current_module:=self;
|
||||
SetCompileModule(current_module);
|
||||
Fillchar(current_filepos,0,sizeof(current_filepos));
|
||||
set_current_module(self);
|
||||
|
||||
{ A force reload }
|
||||
if do_reload then
|
||||
@ -1353,12 +1351,6 @@ uses
|
||||
|
||||
if do_load then
|
||||
begin
|
||||
{ we are loading a new module, save the state of the scanner
|
||||
and reset scanner+module }
|
||||
if assigned(current_scanner) then
|
||||
current_scanner.tempcloseinputfile;
|
||||
current_scanner:=nil;
|
||||
|
||||
{ loading the unit for a second time? }
|
||||
if state=ms_registered then
|
||||
state:=ms_load
|
||||
@ -1470,21 +1462,10 @@ uses
|
||||
assigned(tppumodule(old_current_module).ppufile) then
|
||||
tppumodule(old_current_module).ppufile.tempopen;
|
||||
{$endif SHORT_ON_FILE_HANDLES}
|
||||
|
||||
{ reload old scanner }
|
||||
current_scanner:=tscannerfile(old_current_module.scanner);
|
||||
if assigned(current_scanner) then
|
||||
begin
|
||||
current_scanner.tempopeninputfile;
|
||||
current_scanner.gettokenpos
|
||||
end
|
||||
else
|
||||
fillchar(current_filepos,sizeof(current_filepos),0);
|
||||
end;
|
||||
|
||||
{ we are back, restore current_module }
|
||||
current_module:=old_current_module;
|
||||
SetCompileModule(current_module);
|
||||
set_current_module(old_current_module);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -60,11 +60,10 @@ implementation
|
||||
testcurobject:=0;
|
||||
|
||||
{ Current compiled module/proc }
|
||||
set_current_module(nil);
|
||||
current_module:=nil;
|
||||
compiled_module:=nil;
|
||||
current_asmdata:=nil;
|
||||
current_procinfo:=nil;
|
||||
SetCompileModule(nil);
|
||||
|
||||
loaded_units:=TLinkedList.Create;
|
||||
|
||||
@ -134,11 +133,10 @@ implementation
|
||||
begin
|
||||
{ Reset current compiling info, so destroy routines can't
|
||||
reference the data that might already be destroyed }
|
||||
set_current_module(nil);
|
||||
current_module:=nil;
|
||||
compiled_module:=nil;
|
||||
current_procinfo:=nil;
|
||||
current_asmdata:=nil;
|
||||
SetCompileModule(nil);
|
||||
|
||||
{ unload units }
|
||||
if assigned(loaded_units) then
|
||||
@ -183,7 +181,7 @@ implementation
|
||||
begin
|
||||
new(preprocfile,init('pre'));
|
||||
{ initialize a module }
|
||||
current_module:=new(pmodule,init(filename,false));
|
||||
set_current_module(new(pmodule,init(filename,false)));
|
||||
|
||||
macrosymtablestack:= initialmacrosymtable;
|
||||
current_module.localmacrosymtable:= tmacrosymtable.create(false);
|
||||
@ -275,7 +273,7 @@ implementation
|
||||
oldparse_only : boolean;
|
||||
{ akt.. things }
|
||||
oldcurrent_filepos : tfileposinfo;
|
||||
old_compiled_module : tmodule;
|
||||
old_current_module : tmodule;
|
||||
oldcurrent_procinfo : tprocinfo;
|
||||
old_settings : tsettings;
|
||||
oldsourcecodepage : tcodepagestring;
|
||||
@ -293,7 +291,7 @@ implementation
|
||||
new(olddata);
|
||||
with olddata^ do
|
||||
begin
|
||||
old_compiled_module:=compiled_module;
|
||||
old_current_module:=current_module;
|
||||
{ save symtable state }
|
||||
oldsymtablestack:=symtablestack;
|
||||
oldmacrosymtablestack:=macrosymtablestack;
|
||||
@ -343,7 +341,7 @@ implementation
|
||||
begin
|
||||
if assigned(current_module) then
|
||||
internalerror(200501158);
|
||||
current_module:=tppumodule.create(nil,filename,'',false);
|
||||
set_current_module(tppumodule.create(nil,filename,'',false));
|
||||
addloadedunit(current_module);
|
||||
main_module:=current_module;
|
||||
current_module.state:=ms_compile;
|
||||
@ -352,11 +350,6 @@ implementation
|
||||
(current_module.state in [ms_compile,ms_second_compile])) then
|
||||
internalerror(200212281);
|
||||
|
||||
{ Set the module to use for verbose }
|
||||
compiled_module:=current_module;
|
||||
SetCompileModule(current_module);
|
||||
Fillchar(current_filepos,0,sizeof(current_filepos));
|
||||
|
||||
{ Load current state from the init values }
|
||||
current_settings:=init_settings;
|
||||
|
||||
@ -457,18 +450,6 @@ implementation
|
||||
block_type:=old_block_type;
|
||||
{ restore cg }
|
||||
parse_only:=oldparse_only;
|
||||
{ asm data }
|
||||
if assigned(old_compiled_module) then
|
||||
current_asmdata:=tasmdata(old_compiled_module.asmdata)
|
||||
else
|
||||
current_asmdata:=nil;
|
||||
{ restore previous scanner }
|
||||
if assigned(old_compiled_module) then
|
||||
current_scanner:=tscannerfile(old_compiled_module.scanner)
|
||||
else
|
||||
current_scanner:=nil;
|
||||
if assigned(current_scanner) then
|
||||
parser_current_file:=current_scanner.inputfile.name^;
|
||||
{ restore symtable state }
|
||||
symtablestack:=oldsymtablestack;
|
||||
macrosymtablestack:=oldmacrosymtablestack;
|
||||
@ -508,8 +489,7 @@ implementation
|
||||
end;
|
||||
end;
|
||||
dec(compile_level);
|
||||
compiled_module:=olddata^.old_compiled_module;
|
||||
SetCompileModule(compiled_module);
|
||||
set_current_module(olddata^.old_current_module);
|
||||
|
||||
dispose(olddata);
|
||||
end;
|
||||
|
@ -348,7 +348,7 @@ implementation
|
||||
pbestrealtype:=@s64floattype;
|
||||
|
||||
oldcurrentmodule:=current_module;
|
||||
current_module:=nil;
|
||||
set_current_module(nil);
|
||||
loadtype('byte',u8inttype);
|
||||
loadtype('shortint',s8inttype);
|
||||
loadtype('word',u16inttype);
|
||||
@ -399,7 +399,7 @@ implementation
|
||||
ptruinttype:=u32inttype;
|
||||
ptrsinttype:=s32inttype;
|
||||
{$endif cpu64bit}
|
||||
current_module:=oldcurrentmodule;
|
||||
set_current_module(oldcurrentmodule);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -79,7 +79,6 @@ interface
|
||||
procedure PrepareReport;
|
||||
|
||||
function CheckVerbosity(v:longint):boolean;
|
||||
procedure SetCompileModule(p:tmodulebase);
|
||||
procedure ShowStatus;
|
||||
function ErrorCount:longint;
|
||||
procedure SetErrorFlags(const s:string);
|
||||
@ -120,9 +119,6 @@ implementation
|
||||
uses
|
||||
comphook,fmodule;
|
||||
|
||||
var
|
||||
compiling_module : tmodulebase;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
Extra Handlers for default compiler
|
||||
@ -367,12 +363,6 @@ var
|
||||
end;
|
||||
|
||||
|
||||
procedure SetCompileModule(p:tmodulebase);
|
||||
begin
|
||||
compiling_module:=p;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
lastfileidx,
|
||||
lastmoduleidx : longint;
|
||||
@ -403,9 +393,6 @@ var
|
||||
lastfileidx:=0;
|
||||
lastmoduleidx:=module.unit_index;
|
||||
end;
|
||||
status.compiling_current:=assigned(compiling_module) and
|
||||
(module=compiling_module) and
|
||||
(compiling_module.state in [ms_compile,ms_second_compile]);
|
||||
end;
|
||||
|
||||
|
||||
@ -871,8 +858,6 @@ end;
|
||||
status.currentmodule:='';
|
||||
status.currentsource:='';
|
||||
status.currentsourcepath:='';
|
||||
status.compiling_current:=false;
|
||||
compiling_module:=nil;
|
||||
{ Register internalerrorproc for cutils/cclasses }
|
||||
internalerrorproc:=@internalerror;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user