mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:29:28 +02:00
* Patch from Mattias Gaertner to make implicitly used units configurable
git-svn-id: trunk@34169 -
This commit is contained in:
parent
e9a1ed9446
commit
298a3ba63d
@ -180,6 +180,7 @@ type
|
||||
private
|
||||
FCurModule: TPasModule;
|
||||
FFileResolver: TBaseFileResolver;
|
||||
FImplicitUses: TStrings;
|
||||
FLastMsg: string;
|
||||
FLastMsgArgs: TMessageArgs;
|
||||
FLastMsgNumber: integer;
|
||||
@ -215,7 +216,6 @@ type
|
||||
Function SaveComments : String;
|
||||
Function SaveComments(Const AValue : String) : String;
|
||||
function LogEvent(E : TPParserLogEvent) : Boolean; inline;
|
||||
procedure SetCurMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const);
|
||||
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Msg : String; SkipSourceInfo : Boolean = False);overload;
|
||||
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const;SkipSourceInfo : Boolean = False);overload;
|
||||
function GetProcTypeFromToken(tk: TToken; IsClass: Boolean=False ): TProcType;
|
||||
@ -256,6 +256,7 @@ type
|
||||
public
|
||||
constructor Create(AScanner: TPascalScanner; AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer);
|
||||
Destructor Destroy; override;
|
||||
procedure SetLastMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const);
|
||||
// General parsing routines
|
||||
function CurTokenName: String;
|
||||
function CurTokenText: String;
|
||||
@ -323,6 +324,7 @@ type
|
||||
Property CurModule : TPasModule Read FCurModule;
|
||||
Property LogEvents : TPParserLogEvents Read FLogEvents Write FLogEvents;
|
||||
Property OnLog : TPasParserLogHandler Read FOnLog Write FOnLog;
|
||||
property ImplicitUses: TStrings read FImplicitUses;
|
||||
property LastMsg: string read FLastMsg write FLastMsg;
|
||||
property LastMsgNumber: integer read FLastMsgNumber write FLastMsgNumber;
|
||||
property LastMsgType: TMessageType read FLastMsgType write FLastMsgType;
|
||||
@ -620,7 +622,7 @@ end;
|
||||
procedure TPasParser.ParseExc(MsgNumber: integer; const Fmt: String;
|
||||
Args: array of const);
|
||||
begin
|
||||
SetCurMsg(mtError,MsgNumber,Fmt,Args);
|
||||
SetLastMsg(mtError,MsgNumber,Fmt,Args);
|
||||
raise EParserError.Create(Format(SParserErrorAtToken,
|
||||
[FLastMsg, CurTokenName, Scanner.CurFilename, Scanner.CurRow, Scanner.CurColumn])
|
||||
{$ifdef addlocation}+' ('+inttostr(scanner.currow)+' '+inttostr(scanner.curcolumn)+')'{$endif},
|
||||
@ -657,10 +659,13 @@ begin
|
||||
If FEngine.NeedComments then
|
||||
FScanner.SkipComments:=Not FEngine.NeedComments;
|
||||
end;
|
||||
FImplicitUses := TStringList.Create;
|
||||
FImplicitUses.Add('System'); // system always implicitely first.
|
||||
end;
|
||||
|
||||
destructor TPasParser.Destroy;
|
||||
begin
|
||||
FreeAndNil(FImplicitUses);
|
||||
FreeAndNil(FCommentsBuffer[0]);
|
||||
FreeAndNil(FCommentsBuffer[1]);
|
||||
if Assigned(FEngine) then
|
||||
@ -2310,9 +2315,15 @@ procedure TPasParser.ParseUsesList(ASection: TPasSection);
|
||||
var
|
||||
AUnitName: String;
|
||||
Element: TPasElement;
|
||||
i: Integer;
|
||||
begin
|
||||
If not (Asection.ClassType=TImplementationSection) Then // interface,program,library,package
|
||||
Element:=CheckUnit('System'); // system always implicitely first.
|
||||
begin
|
||||
// load implicit units, like 'System'
|
||||
for i:=0 to ImplicitUses.Count-1 do
|
||||
CheckUnit(ImplicitUses[i]);
|
||||
end;
|
||||
|
||||
Repeat
|
||||
AUnitName := ExpectIdentifier;
|
||||
NextToken;
|
||||
@ -2674,7 +2685,7 @@ begin
|
||||
Result:=E in FLogEvents;
|
||||
end;
|
||||
|
||||
procedure TPasParser.SetCurMsg(MsgType: TMessageType; MsgNumber: integer;
|
||||
procedure TPasParser.SetLastMsg(MsgType: TMessageType; MsgNumber: integer;
|
||||
const Fmt: String; Args: array of const);
|
||||
begin
|
||||
FLastMsgType := MsgType;
|
||||
@ -2693,7 +2704,7 @@ end;
|
||||
procedure TPasParser.DoLog(MsgType: TMessageType; MsgNumber: integer;
|
||||
const Fmt: String; Args: array of const; SkipSourceInfo: Boolean);
|
||||
begin
|
||||
SetCurMsg(MsgType,MsgNumber,Fmt,Args);
|
||||
SetLastMsg(MsgType,MsgNumber,Fmt,Args);
|
||||
If Assigned(FOnLog) then
|
||||
if SkipSourceInfo or not assigned(scanner) then
|
||||
FOnLog(Self,FLastMsg)
|
||||
|
@ -1244,7 +1244,6 @@ procedure TPascalScanner.HandleIncludeFile(Param: String);
|
||||
|
||||
begin
|
||||
PushStackItem;
|
||||
writeln('TPascalScanner.HandleIncludeFile AAA1 Param="',Param,'"');
|
||||
if Length(Param)>1 then
|
||||
begin
|
||||
if (Param[1]=#39) and (Param[length(Param)]=#39) then
|
||||
|
Loading…
Reference in New Issue
Block a user