From 557c962f0c76919b67cd4bc54c795b8a533cd1f2 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 12 May 2011 18:46:00 +0000 Subject: [PATCH] codetools: changed CompielrModeSwitch to set git-svn-id: trunk@30698 - --- components/codetools/finddeclarationtool.pas | 6 ++-- components/codetools/identcompletiontool.pas | 2 +- components/codetools/linkscanner.pas | 31 ++++++++------------ components/codetools/pascalparsertool.pas | 6 ++-- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 9cbdb1ec59..6f454c135a 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -1932,7 +1932,7 @@ begin or ((Scanner.CompilerMode=cmMacPas) and (Scanner.PascalCompiler=pcFPC) and (CompareIdentifiers(PChar(Result),'MacPas')=0)) - or ((Scanner.CompilerModeSwitch=cmsObjectiveC1) + or ((cmsObjectiveC1 in Scanner.CompilerModeSwitches) and ((CompareIdentifiers(PChar(Result),'ObjC')=0) or (CompareIdentifiers(PChar(Result),'ObjCBase')=0))) then begin @@ -6204,13 +6204,13 @@ begin if Result and Params.IsFinal then exit; end; if (CurUnitType>sutObjCBase) - and (Scanner.CompilerModeSwitch=cmsObjectiveC1) then begin + and (cmsObjectiveC1 in Scanner.CompilerModeSwitches) then begin // try hidden used fpc unit 'objcbase' Result:=FindIdentifierInUsedUnit('ObjCBase',Params); if Result and Params.IsFinal then exit; end; if (CurUnitType>sutObjC) - and (Scanner.CompilerModeSwitch=cmsObjectiveC1) then begin + and (cmsObjectiveC1 in Scanner.CompilerModeSwitches) then begin // try hidden used fpc unit 'objc' Result:=FindIdentifierInUsedUnit('ObjC',Params); if Result and Params.IsFinal then exit; diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index e8b765818d..511ba179d5 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -1362,7 +1362,7 @@ begin if (Scanner.CompilerMode=cmMacPas) and (Scanner.PascalCompiler=pcFPC) then AddSystemUnit('MacPas'); - if (Scanner.CompilerModeSwitch=cmsObjectiveC1) then begin + if (cmsObjectiveC1 in Scanner.CompilerModeSwitches) then begin AddSystemUnit('ObjC'); AddSystemUnit('ObjCBase'); end; diff --git a/components/codetools/linkscanner.pas b/components/codetools/linkscanner.pas index db83388aea..9397b8c078 100644 --- a/components/codetools/linkscanner.pas +++ b/components/codetools/linkscanner.pas @@ -132,8 +132,7 @@ type TCompilerMode = (cmFPC, cmDELPHI, cmGPC, cmTP, cmOBJFPC, cmMacPas, cmISO); TCompilerModeSwitch = ( - cmsDefault, - cmsClass, + cmsClass, cmsObjpas, cmsResult, cmsString_pchar, @@ -160,6 +159,7 @@ type cmsNonLocalGoto, cmsAdvancedRecords ); + TCompilerModeSwitches = set of TCompilerModeSwitch; TPascalCompiler = (pcFPC, pcDelphi); @@ -327,12 +327,11 @@ type FSkippingDirectives: TLSSkippingDirective; FSkipIfLevel: integer; FCompilerMode: TCompilerMode; - FCompilerModeSwitch: TCompilerModeSwitch; + FCompilerModeSwitches: TCompilerModeSwitches; FPascalCompiler: TPascalCompiler; FMacros: PSourceLinkMacro; FMacroCount, fMacroCapacity: integer; procedure SetCompilerMode(const AValue: TCompilerMode); - procedure SetCompilerModeSwitch(const AValue: TCompilerModeSwitch); procedure SkipTillEndifElse(SkippingUntil: TLSSkippingDirective); function InternalIfDirective: boolean; @@ -497,8 +496,8 @@ type property NestedComments: boolean read FNestedComments; property CompilerMode: TCompilerMode read FCompilerMode write SetCompilerMode; - property CompilerModeSwitch: TCompilerModeSwitch - read FCompilerModeSwitch write SetCompilerModeSwitch; + property CompilerModeSwitches: TCompilerModeSwitches + read FCompilerModeSwitches write FCompilerModeSwitches; property PascalCompiler: TPascalCompiler read FPascalCompiler write FPascalCompiler; property ScanTill: TLinkScannerRange read FScanTill write SetScanTill; @@ -537,7 +536,7 @@ const ); CompilerModeSwitchNames: array[TCompilerModeSwitch] of shortstring=( - 'Default', 'CLASS', 'OBJPAS', 'RESULT', 'PCHARTOSTRING', 'CVAR', + 'CLASS', 'OBJPAS', 'RESULT', 'PCHARTOSTRING', 'CVAR', 'NESTEDCOMMENTS', 'CLASSICPROCVARS', 'MACPROCVARS', 'REPEATFORWARD', 'POINTERTOPROCVAR', 'AUTODEREF', 'INITFINAL', 'POINTERARITHMETICS', 'ANSISTRINGS', 'OUT', 'DEFAULTPARAMETERS', 'HINTDIRECTIVE', @@ -2519,12 +2518,14 @@ begin if CompareUpToken(CompilerModeSwitchNames[ModeSwitch],Src,ValStart,SrcPos) then begin Result:=true; - CompilerModeSwitch:=ModeSwitch; - break; + if (SrcPos<=SrcLen) and (Src[SrcPos]='-') then + Exclude(FCompilerModeSwitches,ModeSwitch) + else + Include(FCompilerModeSwitches,ModeSwitch); + exit; end; end; - if not Result then - RaiseExceptionFmt(ctsInvalidModeSwitch,[copy(Src,ValStart,SrcPos-ValStart)]); + RaiseExceptionFmt(ctsInvalidModeSwitch,[copy(Src,ValStart,SrcPos-ValStart)]); end; function TLinkScanner.ThreadingDirective: boolean; @@ -3545,7 +3546,7 @@ begin FCompilerMode:=AValue; FNestedComments:=(PascalCompiler=pcFPC) and (FCompilerMode in [cmFPC,cmOBJFPC]); - FCompilerModeSwitch:=cmsDefault; + FCompilerModeSwitches:=[]; end; function TLinkScanner.GetIgnoreMissingIncludeFiles: boolean; @@ -3553,12 +3554,6 @@ begin Result:=lssIgnoreMissingIncludeFiles in FStates; end; -procedure TLinkScanner.SetCompilerModeSwitch(const AValue: TCompilerModeSwitch); -begin - if FCompilerModeSwitch=AValue then exit; - FCompilerModeSwitch:=AValue; -end; - function TLinkScanner.InternalIfDirective: boolean; // {$if expression} or {$ifc expression} or indirectly called by {$elifc expression} var diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index d7b42d8bb4..87d84ec912 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -131,7 +131,7 @@ type protected // parsing FLastCompilerMode: TCompilerMode; - FLastCompilerModeSwitch: TCompilerModeSwitch; + FLastCompilerModeSwitches: TCompilerModeSwitches; procedure FetchScannerSource(Range: TLinkScannerRange); override; // sections function KeyWordFuncSection: boolean; @@ -4532,9 +4532,9 @@ begin //debugln(['TPascalParserTool.FetchScannerSource link scanner has changed ',MainFilename]); FLastScannerChangeStep:=Scanner.ChangeStep; AllChanged:=(FLastCompilerMode<>Scanner.CompilerMode) - or (FLastCompilerModeSwitch<>Scanner.CompilerModeSwitch); + or (FLastCompilerModeSwitches<>Scanner.CompilerModeSwitches); FLastCompilerMode:=Scanner.CompilerMode; - FLastCompilerModeSwitch:=Scanner.CompilerModeSwitch; + FLastCompilerModeSwitches:=Scanner.CompilerModeSwitches; NewSrc:=Scanner.CleanedSrc; NewSrcLen:=length(NewSrc); if AllChanged then begin