* store scanner directive stack when starting compilation of another module

* reset scanner directive stack position when starting new compilation, resolves #13998

git-svn-id: trunk@13285 -
This commit is contained in:
florian 2009-06-17 21:24:26 +00:00
parent ac550782dc
commit f342e825ab
2 changed files with 39 additions and 22 deletions

View File

@ -86,6 +86,7 @@ implementation
pattern:=''; pattern:='';
orgpattern:=''; orgpattern:='';
current_scanner:=nil; current_scanner:=nil;
switchesstatestackpos:=0;
{ register all nodes and tais } { register all nodes and tais }
registernodes; registernodes;
@ -280,6 +281,8 @@ implementation
oldcurrent_procinfo : tprocinfo; oldcurrent_procinfo : tprocinfo;
old_settings : tsettings; old_settings : tsettings;
oldsourcecodepage : tcodepagestring; oldsourcecodepage : tcodepagestring;
old_switchesstatestack : tswitchesstatestack;
old_switchesstatestackpos : Integer;
end; end;
var var
@ -300,11 +303,13 @@ implementation
with olddata^ do with olddata^ do
begin begin
old_current_module:=current_module; old_current_module:=current_module;
{ save symtable state }
{ save symtable state }
oldsymtablestack:=symtablestack; oldsymtablestack:=symtablestack;
oldmacrosymtablestack:=macrosymtablestack; oldmacrosymtablestack:=macrosymtablestack;
oldcurrent_procinfo:=current_procinfo; oldcurrent_procinfo:=current_procinfo;
{ save scanner state }
{ save scanner state }
oldc:=c; oldc:=c;
oldpattern:=pattern; oldpattern:=pattern;
oldorgpattern:=orgpattern; oldorgpattern:=orgpattern;
@ -312,14 +317,19 @@ implementation
oldidtoken:=idtoken; oldidtoken:=idtoken;
old_block_type:=block_type; old_block_type:=block_type;
oldtokenpos:=current_tokenpos; oldtokenpos:=current_tokenpos;
{ save cg } old_switchesstatestack:=switchesstatestack;
old_switchesstatestackpos:=switchesstatestackpos;
{ save cg }
oldparse_only:=parse_only; oldparse_only:=parse_only;
{ save akt... state }
{ handle the postponed case first } { save akt... state }
{ handle the postponed case first }
flushpendingswitchesstate; flushpendingswitchesstate;
oldcurrent_filepos:=current_filepos; oldcurrent_filepos:=current_filepos;
old_settings:=current_settings; old_settings:=current_settings;
end; end;
{ reset parser, a previous fatal error could have left these variables in an unreliable state, this is { reset parser, a previous fatal error could have left these variables in an unreliable state, this is
important for the IDE } important for the IDE }
afterassignment:=false; afterassignment:=false;
@ -457,8 +467,12 @@ implementation
idtoken:=oldidtoken; idtoken:=oldidtoken;
current_tokenpos:=oldtokenpos; current_tokenpos:=oldtokenpos;
block_type:=old_block_type; block_type:=old_block_type;
switchesstatestack:=old_switchesstatestack;
switchesstatestackpos:=old_switchesstatestackpos;
{ restore cg } { restore cg }
parse_only:=oldparse_only; parse_only:=oldparse_only;
{ restore symtable state } { restore symtable state }
symtablestack:=oldsymtablestack; symtablestack:=oldsymtablestack;
macrosymtablestack:=oldmacrosymtablestack; macrosymtablestack:=oldmacrosymtablestack;

View File

@ -23,22 +23,10 @@ unit scandir;
{$i fpcdefs.inc} {$i fpcdefs.inc}
interface interface
procedure InitScannerDirectives;
implementation
uses uses
SysUtils, globtype;
cutils,cfileutl,
globtype,globals,systems,widestr,cpuinfo,
verbose,comphook,ppu,
scanner,switches,
fmodule,
symconst,symtable,
rabase;
const const
switchesstatestackmax = 20; switchesstatestackmax = 20;
@ -49,10 +37,27 @@ implementation
verbosity: longint; verbosity: longint;
end; end;
type
tswitchesstatestack = array[0..switchesstatestackmax] of tsavedswitchesstate;
var var
switchesstatestack: array[0..switchesstatestackmax] of tsavedswitchesstate; switchesstatestack:tswitchesstatestack;
switchesstatestackpos: Integer; switchesstatestackpos: Integer;
procedure InitScannerDirectives;
implementation
uses
SysUtils,
cutils,cfileutl,
globals,systems,widestr,cpuinfo,
verbose,comphook,ppu,
scanner,switches,
fmodule,
symconst,symtable,
rabase;
{***************************************************************************** {*****************************************************************************
Helpers Helpers
*****************************************************************************} *****************************************************************************}
@ -1405,6 +1410,4 @@ implementation
AddDirective('Z4',directive_all, @dir_z4); AddDirective('Z4',directive_all, @dir_z4);
end; end;
begin
switchesstatestackpos:= 0;
end. end.