* tscannerfile is now destroyed in tmodule.reset and current_scanner

is updated accordingly. This removes all the loading and saving of
    the old scanner and the invalid flag marking
This commit is contained in:
peter 2002-08-12 16:46:04 +00:00
parent 9da171faf2
commit 724ece4715
4 changed files with 66 additions and 87 deletions

View File

@ -426,15 +426,12 @@ uses
dispose(map); dispose(map);
if assigned(imports) then if assigned(imports) then
imports.free; imports.free;
imports:=nil;
if assigned(_exports) then if assigned(_exports) then
_exports.free; _exports.free;
_exports:=nil;
if assigned(externals) then if assigned(externals) then
externals.free; externals.free;
externals:=nil;
if assigned(scanner) then if assigned(scanner) then
tscannerfile(scanner).SetInvalid; tscannerfile(scanner).free;
used_units.free; used_units.free;
dependent_units.free; dependent_units.free;
resourcefiles.Free; resourcefiles.Free;
@ -465,10 +462,8 @@ uses
{$endif} {$endif}
if assigned(globalsymtable) then if assigned(globalsymtable) then
globalsymtable.free; globalsymtable.free;
globalsymtable:=nil;
if assigned(localsymtable) then if assigned(localsymtable) then
localsymtable.free; localsymtable.free;
localsymtable:=nil;
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d.free; d.free;
{$endif} {$endif}
@ -488,7 +483,14 @@ uses
pm : tdependent_unit; pm : tdependent_unit;
begin begin
if assigned(scanner) then if assigned(scanner) then
tscannerfile(scanner).SetInvalid; begin
{ also update current_scanner if it was pointing
to this module }
if current_scanner=tscannerfile(scanner) then
current_scanner:=nil;
tscannerfile(scanner).free;
scanner:=nil;
end;
if assigned(globalsymtable) then if assigned(globalsymtable) then
begin begin
globalsymtable.free; globalsymtable.free;
@ -595,7 +597,12 @@ uses
end. end.
{ {
$Log$ $Log$
Revision 1.25 2002-08-11 14:28:19 peter Revision 1.26 2002-08-12 16:46:04 peter
* tscannerfile is now destroyed in tmodule.reset and current_scanner
is updated accordingly. This removes all the loading and saving of
the old scanner and the invalid flag marking
Revision 1.25 2002/08/11 14:28:19 peter
* TScannerFile.SetInvalid added that will also reset inputfile * TScannerFile.SetInvalid added that will also reset inputfile
Revision 1.24 2002/08/11 13:24:11 peter Revision 1.24 2002/08/11 13:24:11 peter

View File

@ -364,7 +364,7 @@ uses
procedure tppumodule.writeusedmacros; procedure tppumodule.writeusedmacros;
begin begin
ppufile.do_crc:=false; ppufile.do_crc:=false;
current_scanner.macros.foreach({$ifdef FPCPROCVAR}@{$endif}writeusedmacro,nil); tscannerfile(scanner).macros.foreach({$ifdef FPCPROCVAR}@{$endif}writeusedmacro,nil);
ppufile.writeentry(ibusedmacros); ppufile.writeentry(ibusedmacros);
ppufile.do_crc:=true; ppufile.do_crc:=true;
end; end;
@ -486,12 +486,15 @@ uses
was_defined_at_startup, was_defined_at_startup,
was_used : boolean; was_used : boolean;
begin begin
{ only possible when we've a scanner of the current file }
if not assigned(current_scanner) then
exit;
while not ppufile.endofentry do while not ppufile.endofentry do
begin begin
hs:=ppufile.getstring; hs:=ppufile.getstring;
was_defined_at_startup:=boolean(ppufile.getbyte); was_defined_at_startup:=boolean(ppufile.getbyte);
was_used:=boolean(ppufile.getbyte); was_used:=boolean(ppufile.getbyte);
mac:=tmacro(current_scanner.macros.search(hs)); mac:=tmacro(tscannerfile(current_scanner).macros.search(hs));
if assigned(mac) then if assigned(mac) then
begin begin
{$ifndef EXTDEBUG} {$ifndef EXTDEBUG}
@ -1089,15 +1092,15 @@ uses
in_second_compile:=true; in_second_compile:=true;
Message1(parser_d_compiling_second_time,modulename^); Message1(parser_d_compiling_second_time,modulename^);
end; end;
current_scanner.tempcloseinputfile; if assigned(current_scanner) then
current_scanner.tempcloseinputfile;
name:=mainsource^; name:=mainsource^;
if assigned(scanner) then
tscannerfile(scanner).SetInvalid;
{ compile this module } { compile this module }
current_module:=self; current_module:=self;
compile(name); compile(name);
in_second_compile:=false; in_second_compile:=false;
if (not current_scanner.invalid) then { the scanner can be reset }
if assigned(current_scanner) then
current_scanner.tempopeninputfile; current_scanner.tempopeninputfile;
end; end;
end; end;
@ -1192,9 +1195,7 @@ uses
begin begin
{ remove the old unit, but save the scanner } { remove the old unit, but save the scanner }
loaded_units.remove(hp); loaded_units.remove(hp);
scanner:=tscannerfile(hp.scanner);
hp.reset; hp.reset;
hp.scanner:=scanner;
{ try to reopen ppu } { try to reopen ppu }
hp.search_unit(s,fn,false); hp.search_unit(s,fn,false);
{ try to load the unit a second time first } { try to load the unit a second time first }
@ -1207,7 +1208,6 @@ uses
{ generates a new unit info record } { generates a new unit info record }
begin begin
current_module:=tppumodule.create(s,fn,true); current_module:=tppumodule.create(s,fn,true);
scanner:=nil;
second_time:=false; second_time:=false;
end; end;
{ close old_current_ppu on system that are { close old_current_ppu on system that are
@ -1259,7 +1259,12 @@ uses
end. end.
{ {
$Log$ $Log$
Revision 1.19 2002-08-11 14:28:19 peter Revision 1.20 2002-08-12 16:46:04 peter
* tscannerfile is now destroyed in tmodule.reset and current_scanner
is updated accordingly. This removes all the loading and saving of
the old scanner and the invalid flag marking
Revision 1.19 2002/08/11 14:28:19 peter
* TScannerFile.SetInvalid added that will also reset inputfile * TScannerFile.SetInvalid added that will also reset inputfile
Revision 1.18 2002/08/11 13:24:11 peter Revision 1.18 2002/08/11 13:24:11 peter

View File

@ -238,8 +238,6 @@ implementation
oldpattern, oldpattern,
oldorgpattern : string; oldorgpattern : string;
old_block_type : tblock_type; old_block_type : tblock_type;
oldcurrent_scanner,prev_scanner,
scanner : tscannerfile;
{ symtable } { symtable }
oldrefsymtable, oldrefsymtable,
olddefaultsymtablestack, olddefaultsymtablestack,
@ -314,7 +312,6 @@ implementation
oldidtoken:=idtoken; oldidtoken:=idtoken;
old_block_type:=block_type; old_block_type:=block_type;
oldtokenpos:=akttokenpos; oldtokenpos:=akttokenpos;
oldcurrent_scanner:=current_scanner;
oldsourcecodepage:=aktsourcecodepage; oldsourcecodepage:=aktsourcecodepage;
{ save cg } { save cg }
oldparse_only:=parse_only; oldparse_only:=parse_only;
@ -376,12 +373,7 @@ implementation
fillchar(overloaded_operators,sizeof(toverloaded_operators),0); fillchar(overloaded_operators,sizeof(toverloaded_operators),0);
{ reset the unit or create a new program } { reset the unit or create a new program }
if assigned(current_module) then if assigned(current_module) then
begin current_module.reset
{current_module.reset this is wrong !! }
scanner:=tscannerfile(current_module.scanner);
current_module.reset;
tscannerfile(current_module.scanner):=scanner;
end
else else
begin begin
current_module:=tppumodule.create(filename,'',false); current_module:=tppumodule.create(filename,'',false);
@ -416,12 +408,11 @@ implementation
{ startup scanner and load the first file } { startup scanner and load the first file }
current_scanner:=tscannerfile.Create(filename); current_scanner:=tscannerfile.Create(filename);
current_scanner.firstfile; current_scanner.firstfile;
current_module.scanner:=current_scanner;
{ macros } { macros }
default_macros; default_macros;
{ read the first token } { read the first token }
current_scanner.readtoken; current_scanner.readtoken;
prev_scanner:=tscannerfile(current_module.scanner);
current_module.scanner:=current_scanner;
{ init code generator for a new module } { init code generator for a new module }
codegen_newmodule; codegen_newmodule;
@ -475,10 +466,7 @@ implementation
{ free scanner } { free scanner }
current_scanner.free; current_scanner.free;
current_scanner:=nil; current_scanner:=nil;
{ restore previous scanner !! } current_module.scanner:=nil;
current_module.scanner:=prev_scanner;
if assigned(prev_scanner) then
prev_scanner.SetInvalid;
if (compile_level>1) then if (compile_level>1) then
begin begin
@ -493,8 +481,8 @@ implementation
idtoken:=oldidtoken; idtoken:=oldidtoken;
akttokenpos:=oldtokenpos; akttokenpos:=oldtokenpos;
block_type:=old_block_type; block_type:=old_block_type;
current_scanner:=oldcurrent_scanner; current_scanner:=tscannerfile(old_compiled_module.scanner);
if not current_scanner.invalid then if assigned(current_scanner) then
parser_current_file:=current_scanner.inputfile.name^; parser_current_file:=current_scanner.inputfile.name^;
{ restore cg } { restore cg }
parse_only:=oldparse_only; parse_only:=oldparse_only;
@ -580,24 +568,14 @@ implementation
do_extractsymbolinfo{$ifdef FPC}(){$endif}; do_extractsymbolinfo{$ifdef FPC}(){$endif};
end; end;
if current_module.in_second_compile then if current_module.in_second_compile then
begin begin
current_module.in_second_compile:=false; current_module.in_second_compile:=false;
current_module.in_compile:=true; current_module.in_compile:=true;
end end
else else
current_module.in_compile:=false; current_module.in_compile:=false;
(* Obsolete code aktprocsym
is disposed by the localsymtable disposal (PM)
{ Free last aktprocsym }
if assigned(aktprocsym) and (aktprocsym.owner=nil) then
begin
{ init parts are not needed in units !! }
if current_module.is_unit then
aktprocdef.forwarddef:=false;
dispose(aktprocsym,done);
end; *)
end; end;
dec(compile_level); dec(compile_level);
@ -611,7 +589,12 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.39 2002-08-12 15:08:40 carl Revision 1.40 2002-08-12 16:46:04 peter
* tscannerfile is now destroyed in tmodule.reset and current_scanner
is updated accordingly. This removes all the loading and saving of
the old scanner and the invalid flag marking
Revision 1.39 2002/08/12 15:08:40 carl
+ stab register indexes for powerpc (moved from gdb to cpubase) + stab register indexes for powerpc (moved from gdb to cpubase)
+ tprocessor enumeration moved to cpuinfo + tprocessor enumeration moved to cpuinfo
+ linker in target_info is now a class + linker in target_info is now a class

View File

@ -79,9 +79,7 @@ interface
end; end;
tscannerfile = class tscannerfile = class
private public
FInvalid : boolean; { flag if sourcefiles have been destroyed ! }
public
inputfile : tinputfile; { current inputfile list } inputfile : tinputfile; { current inputfile list }
inputbuffer, { input buffer } inputbuffer, { input buffer }
@ -109,7 +107,6 @@ interface
constructor Create(const fn:string); constructor Create(const fn:string);
destructor Destroy;override; destructor Destroy;override;
{ File buffer things } { File buffer things }
procedure setinvalid;
function openinputfile:boolean; function openinputfile:boolean;
procedure closeinputfile; procedure closeinputfile;
function tempopeninputfile:boolean; function tempopeninputfile:boolean;
@ -151,7 +148,6 @@ interface
procedure readtoken; procedure readtoken;
function readpreproc:ttoken; function readpreproc:ttoken;
function asmgetchar:char; function asmgetchar:char;
property Invalid:boolean read FInvalid;
end; end;
{$ifdef PREPROCWRITE} {$ifdef PREPROCWRITE}
@ -915,7 +911,6 @@ implementation
nexttoken:=NOTOKEN; nexttoken:=NOTOKEN;
lastasmgetchar:=#0; lastasmgetchar:=#0;
ignoredirectives:=TStringList.Create; ignoredirectives:=TStringList.Create;
Finvalid:=false;
in_asm_string:=false; in_asm_string:=false;
macros:=tdictionary.create; macros:=tdictionary.create;
end; end;
@ -938,26 +933,19 @@ implementation
destructor tscannerfile.destroy; destructor tscannerfile.destroy;
begin begin
if not invalid then if (not current_module.in_second_load) and
(status.errorcount=0) then
checkpreprocstack
else
begin begin
if status.errorcount=0 then while assigned(preprocstack) do
checkpreprocstack poppreprocstack;
else
begin
while assigned(preprocstack) do
poppreprocstack;
end;
{ close file, but only if we are the first compile }
{ probably not necessary anymore with invalid flag PM }
if not current_module.in_second_compile then
begin
if not inputfile.closed then
closeinputfile;
end;
end; end;
ignoredirectives.free; if not inputfile.closed then
macros.free; closeinputfile;
end; ignoredirectives.free;
macros.free;
end;
procedure tscannerfile.def_macro(const s : string); procedure tscannerfile.def_macro(const s : string);
@ -1000,15 +988,6 @@ implementation
end; end;
procedure tscannerfile.setinvalid;
begin
{ mark the tscannerfile as invalid and reset inputfile
so it can not be reused }
Finvalid:=true;
inputfile:=nil;
end;
function tscannerfile.openinputfile:boolean; function tscannerfile.openinputfile:boolean;
begin begin
openinputfile:=inputfile.open; openinputfile:=inputfile.open;
@ -2796,7 +2775,12 @@ exit_label:
end. end.
{ {
$Log$ $Log$
Revision 1.43 2002-08-11 14:28:19 peter Revision 1.44 2002-08-12 16:46:04 peter
* tscannerfile is now destroyed in tmodule.reset and current_scanner
is updated accordingly. This removes all the loading and saving of
the old scanner and the invalid flag marking
Revision 1.43 2002/08/11 14:28:19 peter
* TScannerFile.SetInvalid added that will also reset inputfile * TScannerFile.SetInvalid added that will also reset inputfile
Revision 1.42 2002/08/10 14:46:31 carl Revision 1.42 2002/08/10 14:46:31 carl