mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 22:07:56 +02:00
* Remove freeold from set_current_scanner
This commit is contained in:
parent
7cd044eae7
commit
6f7481fd24
@ -348,7 +348,7 @@ implementation
|
||||
current_asmdata:=tasmdata(current_module.asmdata);
|
||||
current_debuginfo:=tdebuginfo(current_module.debuginfo);
|
||||
{ restore scanner and file positions }
|
||||
set_current_scanner(tscannerfile(current_module.scanner),false);
|
||||
set_current_scanner(tscannerfile(current_module.scanner));
|
||||
if assigned(current_scanner) then
|
||||
begin
|
||||
current_scanner.tempopeninputfile;
|
||||
@ -364,7 +364,7 @@ implementation
|
||||
else
|
||||
begin
|
||||
current_asmdata:=nil;
|
||||
set_current_scanner(nil,false);
|
||||
set_current_scanner(nil);
|
||||
current_debuginfo:=nil;
|
||||
end;
|
||||
end;
|
||||
@ -683,7 +683,7 @@ implementation
|
||||
{ also update current_scanner if it was pointing
|
||||
to this module }
|
||||
if current_scanner=tscannerfile(scanner) then
|
||||
set_current_scanner(nil,false);
|
||||
set_current_scanner(nil);
|
||||
freeandnil(scanner);
|
||||
|
||||
end;
|
||||
@ -786,7 +786,7 @@ implementation
|
||||
{ also update current_scanner if it was pointing
|
||||
to this module }
|
||||
if current_scanner=tscannerfile(scanner) then
|
||||
set_current_scanner(nil,false);
|
||||
set_current_scanner(nil);
|
||||
freeandnil(scanner);
|
||||
end;
|
||||
if assigned(procinfo) then
|
||||
@ -1153,7 +1153,7 @@ implementation
|
||||
if assigned(scanner) then
|
||||
begin
|
||||
if current_scanner=tscannerfile(scanner) then
|
||||
set_current_scanner(nil,false);
|
||||
set_current_scanner(nil);
|
||||
FreeAndNil(scanner);
|
||||
scanner:=nil;
|
||||
end;
|
||||
|
@ -151,7 +151,7 @@ uses
|
||||
current_module:=old_current_module; {!}
|
||||
current_asmdata:=old_asmdata;
|
||||
current_debuginfo:=old_debuginfo;
|
||||
set_current_scanner(old_scanner,False);
|
||||
set_current_scanner(old_scanner);
|
||||
parser_current_file:=old_parser_file;
|
||||
end;
|
||||
end;
|
||||
|
@ -85,7 +85,7 @@ implementation
|
||||
pattern:='';
|
||||
orgpattern:='';
|
||||
cstringpattern:='';
|
||||
set_current_scanner(nil,true);
|
||||
set_current_scanner(nil);
|
||||
switchesstatestackpos:=0;
|
||||
|
||||
{ register all nodes and tais }
|
||||
@ -218,7 +218,7 @@ implementation
|
||||
if assigned(current_scanner) then
|
||||
begin
|
||||
current_scanner.free;
|
||||
set_current_scanner(nil,true);
|
||||
set_current_scanner(nil);
|
||||
|
||||
end;
|
||||
|
||||
@ -407,7 +407,7 @@ implementation
|
||||
sc.firstfile;
|
||||
module.scanner:=sc;
|
||||
module.mainscanner:=sc;
|
||||
set_current_scanner(sc,false);
|
||||
set_current_scanner(sc);
|
||||
|
||||
{ init macros before anything in the file is parsed.}
|
||||
module.localmacrosymtable:= tmacrosymtable.create(false);
|
||||
@ -469,7 +469,7 @@ implementation
|
||||
macrosymtablestack:=nil;
|
||||
symtablestack:=nil;
|
||||
if current_scanner=current_module.scanner then
|
||||
set_current_scanner(nil,false);
|
||||
set_current_scanner(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -256,7 +256,9 @@ interface
|
||||
function readpreprocint(var value:int64;const place:string):boolean;
|
||||
function readpreprocset(conform_to:tsetdef;var value:tnormalset;const place:string):boolean;
|
||||
function asmgetchar:char;
|
||||
{$ifdef EXTDEBUG}
|
||||
function DumpPointer : string;
|
||||
{$endif EXTDEBUG}
|
||||
end;
|
||||
|
||||
{$ifdef PREPROCWRITE}
|
||||
@ -299,13 +301,16 @@ interface
|
||||
procedure DoneScanner;
|
||||
|
||||
function current_scanner : tscannerfile; { current scanner in use }
|
||||
procedure set_current_scanner(avalue : tscannerfile; FreeOld : Boolean); { current scanner in use }
|
||||
procedure set_current_scanner(avalue : tscannerfile); { current scanner in use }
|
||||
|
||||
{ To be called when the language mode is finally determined }
|
||||
Function SetCompileMode(const s:string; changeInit: boolean):boolean;
|
||||
Function SetCompileModeSwitch(s:string; changeInit: boolean):boolean;
|
||||
procedure SetAppType(NewAppType:tapptype);
|
||||
|
||||
var
|
||||
onfreescanner : procedure(s : tscannerfile) = nil;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -324,11 +329,19 @@ implementation
|
||||
{ dictionaries with the supported directives }
|
||||
turbo_scannerdirectives : TFPHashObjectList; { for other modes }
|
||||
mac_scannerdirectives : TFPHashObjectList; { for mode mac }
|
||||
_current_scanner : tscannerfile; { current scanner in use }
|
||||
{
|
||||
By default the current_scanner is current_module.scanner.
|
||||
set_current_scanner sets the _temp_scanner variable.
|
||||
If _temp_scanner is set, it is returned as the current scanner
|
||||
}
|
||||
_temp_scanner : tscannerfile;
|
||||
|
||||
function current_scanner : tscannerfile; { current scanner in use }
|
||||
|
||||
begin
|
||||
Result:=_temp_scanner;
|
||||
if result<>nil then
|
||||
exit;
|
||||
if assigned(current_module) then
|
||||
Result:=Tscannerfile(current_module.scanner)
|
||||
else
|
||||
@ -506,13 +519,9 @@ implementation
|
||||
{$endif i8086}
|
||||
end;
|
||||
|
||||
|
||||
procedure set_current_scanner(avalue: tscannerfile; FreeOld: Boolean);
|
||||
procedure set_current_scanner(avalue: tscannerfile);
|
||||
begin
|
||||
if (avalue=nil) and FreeOld and (_current_scanner<>nil) then
|
||||
_current_scanner.Free;
|
||||
|
||||
_current_scanner:=avalue;
|
||||
_temp_scanner:=avalue;
|
||||
end;
|
||||
|
||||
Function SetCompileMode(const s:string; changeInit: boolean):boolean;
|
||||
@ -2972,7 +2981,7 @@ type
|
||||
TSCANNERFILE
|
||||
****************************************************************************}
|
||||
|
||||
constructor tscannerfile.Create(const fn: string; is_macro: boolean);
|
||||
constructor tscannerfile.Create(const fn: string; is_macro: boolean);
|
||||
begin
|
||||
inputfile:=do_openinputfile(fn);
|
||||
if is_macro then
|
||||
@ -3015,8 +3024,10 @@ type
|
||||
end;
|
||||
|
||||
|
||||
destructor tscannerfile.Destroy;
|
||||
destructor tscannerfile.Destroy;
|
||||
begin
|
||||
if assigned(onfreescanner) then
|
||||
onfreescanner(self);
|
||||
if assigned(current_module) and
|
||||
(current_module.state=ms_compiled) and
|
||||
(status.errorcount=0) then
|
||||
@ -6216,6 +6227,7 @@ exit_label:
|
||||
until false;
|
||||
end;
|
||||
|
||||
{$ifdef EXTDEBUG}
|
||||
function tscannerfile.DumpPointer: string;
|
||||
var
|
||||
i: Integer;
|
||||
@ -6224,12 +6236,13 @@ exit_label:
|
||||
Result:='';
|
||||
if inputpointer=nil then exit;
|
||||
i:=0;
|
||||
While (inputpointer[I]<>#0) and (i<100) do
|
||||
While (inputpointer[I]<>#0) and (i<200) do
|
||||
inc(i);
|
||||
Setlength(result,I);
|
||||
move(inputpointer^,Result[1],I);
|
||||
result:='<'+inttostr(inputstart)+'>'+result;
|
||||
end;
|
||||
|
||||
{$endif EXTDEBUG}
|
||||
|
||||
{*****************************************************************************
|
||||
Helpers
|
||||
|
@ -168,7 +168,7 @@ implementation
|
||||
in the current one }
|
||||
old_block_type:=block_type;
|
||||
sstate.new_scanner:=tscannerfile.Create('_Macro_.'+tempname,true);
|
||||
set_current_scanner(sstate.new_scanner,False);
|
||||
set_current_scanner(sstate.new_scanner);
|
||||
block_type:=old_block_type;
|
||||
{ required for e.g. FpcDeepCopy record method (uses "out" parameter; field
|
||||
names are escaped via &, so should not cause conflicts }
|
||||
@ -181,7 +181,7 @@ implementation
|
||||
if sstate.valid then
|
||||
begin
|
||||
sstate.new_scanner.free;
|
||||
set_current_scanner(sstate.old_scanner,false);
|
||||
set_current_scanner(sstate.old_scanner);
|
||||
current_filepos:=sstate.old_filepos;
|
||||
token:=sstate.old_token;
|
||||
current_settings.modeswitches:=sstate.old_modeswitches;
|
||||
|
Loading…
Reference in New Issue
Block a user