* 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);
if assigned(imports) then
imports.free;
imports:=nil;
if assigned(_exports) then
_exports.free;
_exports:=nil;
if assigned(externals) then
externals.free;
externals:=nil;
if assigned(scanner) then
tscannerfile(scanner).SetInvalid;
tscannerfile(scanner).free;
used_units.free;
dependent_units.free;
resourcefiles.Free;
@ -465,10 +462,8 @@ uses
{$endif}
if assigned(globalsymtable) then
globalsymtable.free;
globalsymtable:=nil;
if assigned(localsymtable) then
localsymtable.free;
localsymtable:=nil;
{$ifdef MEMDEBUG}
d.free;
{$endif}
@ -488,7 +483,14 @@ uses
pm : tdependent_unit;
begin
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
begin
globalsymtable.free;
@ -595,7 +597,12 @@ uses
end.
{
$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
Revision 1.24 2002/08/11 13:24:11 peter

View File

@ -364,7 +364,7 @@ uses
procedure tppumodule.writeusedmacros;
begin
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.do_crc:=true;
end;
@ -486,12 +486,15 @@ uses
was_defined_at_startup,
was_used : boolean;
begin
{ only possible when we've a scanner of the current file }
if not assigned(current_scanner) then
exit;
while not ppufile.endofentry do
begin
hs:=ppufile.getstring;
was_defined_at_startup:=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
begin
{$ifndef EXTDEBUG}
@ -1089,15 +1092,15 @@ uses
in_second_compile:=true;
Message1(parser_d_compiling_second_time,modulename^);
end;
current_scanner.tempcloseinputfile;
if assigned(current_scanner) then
current_scanner.tempcloseinputfile;
name:=mainsource^;
if assigned(scanner) then
tscannerfile(scanner).SetInvalid;
{ compile this module }
current_module:=self;
compile(name);
in_second_compile:=false;
if (not current_scanner.invalid) then
{ the scanner can be reset }
if assigned(current_scanner) then
current_scanner.tempopeninputfile;
end;
end;
@ -1192,9 +1195,7 @@ uses
begin
{ remove the old unit, but save the scanner }
loaded_units.remove(hp);
scanner:=tscannerfile(hp.scanner);
hp.reset;
hp.scanner:=scanner;
{ try to reopen ppu }
hp.search_unit(s,fn,false);
{ try to load the unit a second time first }
@ -1207,7 +1208,6 @@ uses
{ generates a new unit info record }
begin
current_module:=tppumodule.create(s,fn,true);
scanner:=nil;
second_time:=false;
end;
{ close old_current_ppu on system that are
@ -1259,7 +1259,12 @@ uses
end.
{
$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
Revision 1.18 2002/08/11 13:24:11 peter

View File

@ -238,8 +238,6 @@ implementation
oldpattern,
oldorgpattern : string;
old_block_type : tblock_type;
oldcurrent_scanner,prev_scanner,
scanner : tscannerfile;
{ symtable }
oldrefsymtable,
olddefaultsymtablestack,
@ -314,7 +312,6 @@ implementation
oldidtoken:=idtoken;
old_block_type:=block_type;
oldtokenpos:=akttokenpos;
oldcurrent_scanner:=current_scanner;
oldsourcecodepage:=aktsourcecodepage;
{ save cg }
oldparse_only:=parse_only;
@ -376,12 +373,7 @@ implementation
fillchar(overloaded_operators,sizeof(toverloaded_operators),0);
{ reset the unit or create a new program }
if assigned(current_module) then
begin
{current_module.reset this is wrong !! }
scanner:=tscannerfile(current_module.scanner);
current_module.reset;
tscannerfile(current_module.scanner):=scanner;
end
current_module.reset
else
begin
current_module:=tppumodule.create(filename,'',false);
@ -416,12 +408,11 @@ implementation
{ startup scanner and load the first file }
current_scanner:=tscannerfile.Create(filename);
current_scanner.firstfile;
current_module.scanner:=current_scanner;
{ macros }
default_macros;
{ read the first token }
current_scanner.readtoken;
prev_scanner:=tscannerfile(current_module.scanner);
current_module.scanner:=current_scanner;
{ init code generator for a new module }
codegen_newmodule;
@ -475,10 +466,7 @@ implementation
{ free scanner }
current_scanner.free;
current_scanner:=nil;
{ restore previous scanner !! }
current_module.scanner:=prev_scanner;
if assigned(prev_scanner) then
prev_scanner.SetInvalid;
current_module.scanner:=nil;
if (compile_level>1) then
begin
@ -493,8 +481,8 @@ implementation
idtoken:=oldidtoken;
akttokenpos:=oldtokenpos;
block_type:=old_block_type;
current_scanner:=oldcurrent_scanner;
if not current_scanner.invalid then
current_scanner:=tscannerfile(old_compiled_module.scanner);
if assigned(current_scanner) then
parser_current_file:=current_scanner.inputfile.name^;
{ restore cg }
parse_only:=oldparse_only;
@ -580,24 +568,14 @@ implementation
do_extractsymbolinfo{$ifdef FPC}(){$endif};
end;
if current_module.in_second_compile then
begin
current_module.in_second_compile:=false;
current_module.in_compile:=true;
end
else
current_module.in_compile:=false;
if current_module.in_second_compile then
begin
current_module.in_second_compile:=false;
current_module.in_compile:=true;
end
else
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;
dec(compile_level);
@ -611,7 +589,12 @@ implementation
end.
{
$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)
+ tprocessor enumeration moved to cpuinfo
+ linker in target_info is now a class

View File

@ -79,9 +79,7 @@ interface
end;
tscannerfile = class
private
FInvalid : boolean; { flag if sourcefiles have been destroyed ! }
public
public
inputfile : tinputfile; { current inputfile list }
inputbuffer, { input buffer }
@ -109,7 +107,6 @@ interface
constructor Create(const fn:string);
destructor Destroy;override;
{ File buffer things }
procedure setinvalid;
function openinputfile:boolean;
procedure closeinputfile;
function tempopeninputfile:boolean;
@ -151,7 +148,6 @@ interface
procedure readtoken;
function readpreproc:ttoken;
function asmgetchar:char;
property Invalid:boolean read FInvalid;
end;
{$ifdef PREPROCWRITE}
@ -915,7 +911,6 @@ implementation
nexttoken:=NOTOKEN;
lastasmgetchar:=#0;
ignoredirectives:=TStringList.Create;
Finvalid:=false;
in_asm_string:=false;
macros:=tdictionary.create;
end;
@ -938,26 +933,19 @@ implementation
destructor tscannerfile.destroy;
begin
if not invalid then
if (not current_module.in_second_load) and
(status.errorcount=0) then
checkpreprocstack
else
begin
if status.errorcount=0 then
checkpreprocstack
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;
while assigned(preprocstack) do
poppreprocstack;
end;
ignoredirectives.free;
macros.free;
end;
if not inputfile.closed then
closeinputfile;
ignoredirectives.free;
macros.free;
end;
procedure tscannerfile.def_macro(const s : string);
@ -1000,15 +988,6 @@ implementation
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;
begin
openinputfile:=inputfile.open;
@ -2796,7 +2775,12 @@ exit_label:
end.
{
$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
Revision 1.42 2002/08/10 14:46:31 carl