codetools: changed CompielrModeSwitch to set

git-svn-id: trunk@30698 -
This commit is contained in:
mattias 2011-05-12 18:46:00 +00:00
parent fbca65edab
commit 557c962f0c
4 changed files with 20 additions and 25 deletions

View File

@ -1932,7 +1932,7 @@ begin
or ((Scanner.CompilerMode=cmMacPas) or ((Scanner.CompilerMode=cmMacPas)
and (Scanner.PascalCompiler=pcFPC) and (Scanner.PascalCompiler=pcFPC)
and (CompareIdentifiers(PChar(Result),'MacPas')=0)) and (CompareIdentifiers(PChar(Result),'MacPas')=0))
or ((Scanner.CompilerModeSwitch=cmsObjectiveC1) or ((cmsObjectiveC1 in Scanner.CompilerModeSwitches)
and ((CompareIdentifiers(PChar(Result),'ObjC')=0) and ((CompareIdentifiers(PChar(Result),'ObjC')=0)
or (CompareIdentifiers(PChar(Result),'ObjCBase')=0))) or (CompareIdentifiers(PChar(Result),'ObjCBase')=0)))
then begin then begin
@ -6204,13 +6204,13 @@ begin
if Result and Params.IsFinal then exit; if Result and Params.IsFinal then exit;
end; end;
if (CurUnitType>sutObjCBase) if (CurUnitType>sutObjCBase)
and (Scanner.CompilerModeSwitch=cmsObjectiveC1) then begin and (cmsObjectiveC1 in Scanner.CompilerModeSwitches) then begin
// try hidden used fpc unit 'objcbase' // try hidden used fpc unit 'objcbase'
Result:=FindIdentifierInUsedUnit('ObjCBase',Params); Result:=FindIdentifierInUsedUnit('ObjCBase',Params);
if Result and Params.IsFinal then exit; if Result and Params.IsFinal then exit;
end; end;
if (CurUnitType>sutObjC) if (CurUnitType>sutObjC)
and (Scanner.CompilerModeSwitch=cmsObjectiveC1) then begin and (cmsObjectiveC1 in Scanner.CompilerModeSwitches) then begin
// try hidden used fpc unit 'objc' // try hidden used fpc unit 'objc'
Result:=FindIdentifierInUsedUnit('ObjC',Params); Result:=FindIdentifierInUsedUnit('ObjC',Params);
if Result and Params.IsFinal then exit; if Result and Params.IsFinal then exit;

View File

@ -1362,7 +1362,7 @@ begin
if (Scanner.CompilerMode=cmMacPas) if (Scanner.CompilerMode=cmMacPas)
and (Scanner.PascalCompiler=pcFPC) then and (Scanner.PascalCompiler=pcFPC) then
AddSystemUnit('MacPas'); AddSystemUnit('MacPas');
if (Scanner.CompilerModeSwitch=cmsObjectiveC1) then begin if (cmsObjectiveC1 in Scanner.CompilerModeSwitches) then begin
AddSystemUnit('ObjC'); AddSystemUnit('ObjC');
AddSystemUnit('ObjCBase'); AddSystemUnit('ObjCBase');
end; end;

View File

@ -132,7 +132,6 @@ type
TCompilerMode = (cmFPC, cmDELPHI, cmGPC, cmTP, cmOBJFPC, cmMacPas, cmISO); TCompilerMode = (cmFPC, cmDELPHI, cmGPC, cmTP, cmOBJFPC, cmMacPas, cmISO);
TCompilerModeSwitch = ( TCompilerModeSwitch = (
cmsDefault,
cmsClass, cmsClass,
cmsObjpas, cmsObjpas,
cmsResult, cmsResult,
@ -160,6 +159,7 @@ type
cmsNonLocalGoto, cmsNonLocalGoto,
cmsAdvancedRecords cmsAdvancedRecords
); );
TCompilerModeSwitches = set of TCompilerModeSwitch;
TPascalCompiler = (pcFPC, pcDelphi); TPascalCompiler = (pcFPC, pcDelphi);
@ -327,12 +327,11 @@ type
FSkippingDirectives: TLSSkippingDirective; FSkippingDirectives: TLSSkippingDirective;
FSkipIfLevel: integer; FSkipIfLevel: integer;
FCompilerMode: TCompilerMode; FCompilerMode: TCompilerMode;
FCompilerModeSwitch: TCompilerModeSwitch; FCompilerModeSwitches: TCompilerModeSwitches;
FPascalCompiler: TPascalCompiler; FPascalCompiler: TPascalCompiler;
FMacros: PSourceLinkMacro; FMacros: PSourceLinkMacro;
FMacroCount, fMacroCapacity: integer; FMacroCount, fMacroCapacity: integer;
procedure SetCompilerMode(const AValue: TCompilerMode); procedure SetCompilerMode(const AValue: TCompilerMode);
procedure SetCompilerModeSwitch(const AValue: TCompilerModeSwitch);
procedure SkipTillEndifElse(SkippingUntil: TLSSkippingDirective); procedure SkipTillEndifElse(SkippingUntil: TLSSkippingDirective);
function InternalIfDirective: boolean; function InternalIfDirective: boolean;
@ -497,8 +496,8 @@ type
property NestedComments: boolean read FNestedComments; property NestedComments: boolean read FNestedComments;
property CompilerMode: TCompilerMode property CompilerMode: TCompilerMode
read FCompilerMode write SetCompilerMode; read FCompilerMode write SetCompilerMode;
property CompilerModeSwitch: TCompilerModeSwitch property CompilerModeSwitches: TCompilerModeSwitches
read FCompilerModeSwitch write SetCompilerModeSwitch; read FCompilerModeSwitches write FCompilerModeSwitches;
property PascalCompiler: TPascalCompiler property PascalCompiler: TPascalCompiler
read FPascalCompiler write FPascalCompiler; read FPascalCompiler write FPascalCompiler;
property ScanTill: TLinkScannerRange read FScanTill write SetScanTill; property ScanTill: TLinkScannerRange read FScanTill write SetScanTill;
@ -537,7 +536,7 @@ const
); );
CompilerModeSwitchNames: array[TCompilerModeSwitch] of shortstring=( CompilerModeSwitchNames: array[TCompilerModeSwitch] of shortstring=(
'Default', 'CLASS', 'OBJPAS', 'RESULT', 'PCHARTOSTRING', 'CVAR', 'CLASS', 'OBJPAS', 'RESULT', 'PCHARTOSTRING', 'CVAR',
'NESTEDCOMMENTS', 'CLASSICPROCVARS', 'MACPROCVARS', 'REPEATFORWARD', 'NESTEDCOMMENTS', 'CLASSICPROCVARS', 'MACPROCVARS', 'REPEATFORWARD',
'POINTERTOPROCVAR', 'AUTODEREF', 'INITFINAL', 'POINTERARITHMETICS', 'POINTERTOPROCVAR', 'AUTODEREF', 'INITFINAL', 'POINTERARITHMETICS',
'ANSISTRINGS', 'OUT', 'DEFAULTPARAMETERS', 'HINTDIRECTIVE', 'ANSISTRINGS', 'OUT', 'DEFAULTPARAMETERS', 'HINTDIRECTIVE',
@ -2519,12 +2518,14 @@ begin
if CompareUpToken(CompilerModeSwitchNames[ModeSwitch],Src,ValStart,SrcPos) if CompareUpToken(CompilerModeSwitchNames[ModeSwitch],Src,ValStart,SrcPos)
then begin then begin
Result:=true; Result:=true;
CompilerModeSwitch:=ModeSwitch; if (SrcPos<=SrcLen) and (Src[SrcPos]='-') then
break; Exclude(FCompilerModeSwitches,ModeSwitch)
else
Include(FCompilerModeSwitches,ModeSwitch);
exit;
end; end;
end; end;
if not Result then RaiseExceptionFmt(ctsInvalidModeSwitch,[copy(Src,ValStart,SrcPos-ValStart)]);
RaiseExceptionFmt(ctsInvalidModeSwitch,[copy(Src,ValStart,SrcPos-ValStart)]);
end; end;
function TLinkScanner.ThreadingDirective: boolean; function TLinkScanner.ThreadingDirective: boolean;
@ -3545,7 +3546,7 @@ begin
FCompilerMode:=AValue; FCompilerMode:=AValue;
FNestedComments:=(PascalCompiler=pcFPC) FNestedComments:=(PascalCompiler=pcFPC)
and (FCompilerMode in [cmFPC,cmOBJFPC]); and (FCompilerMode in [cmFPC,cmOBJFPC]);
FCompilerModeSwitch:=cmsDefault; FCompilerModeSwitches:=[];
end; end;
function TLinkScanner.GetIgnoreMissingIncludeFiles: boolean; function TLinkScanner.GetIgnoreMissingIncludeFiles: boolean;
@ -3553,12 +3554,6 @@ begin
Result:=lssIgnoreMissingIncludeFiles in FStates; Result:=lssIgnoreMissingIncludeFiles in FStates;
end; end;
procedure TLinkScanner.SetCompilerModeSwitch(const AValue: TCompilerModeSwitch);
begin
if FCompilerModeSwitch=AValue then exit;
FCompilerModeSwitch:=AValue;
end;
function TLinkScanner.InternalIfDirective: boolean; function TLinkScanner.InternalIfDirective: boolean;
// {$if expression} or {$ifc expression} or indirectly called by {$elifc expression} // {$if expression} or {$ifc expression} or indirectly called by {$elifc expression}
var var

View File

@ -131,7 +131,7 @@ type
protected protected
// parsing // parsing
FLastCompilerMode: TCompilerMode; FLastCompilerMode: TCompilerMode;
FLastCompilerModeSwitch: TCompilerModeSwitch; FLastCompilerModeSwitches: TCompilerModeSwitches;
procedure FetchScannerSource(Range: TLinkScannerRange); override; procedure FetchScannerSource(Range: TLinkScannerRange); override;
// sections // sections
function KeyWordFuncSection: boolean; function KeyWordFuncSection: boolean;
@ -4532,9 +4532,9 @@ begin
//debugln(['TPascalParserTool.FetchScannerSource link scanner has changed ',MainFilename]); //debugln(['TPascalParserTool.FetchScannerSource link scanner has changed ',MainFilename]);
FLastScannerChangeStep:=Scanner.ChangeStep; FLastScannerChangeStep:=Scanner.ChangeStep;
AllChanged:=(FLastCompilerMode<>Scanner.CompilerMode) AllChanged:=(FLastCompilerMode<>Scanner.CompilerMode)
or (FLastCompilerModeSwitch<>Scanner.CompilerModeSwitch); or (FLastCompilerModeSwitches<>Scanner.CompilerModeSwitches);
FLastCompilerMode:=Scanner.CompilerMode; FLastCompilerMode:=Scanner.CompilerMode;
FLastCompilerModeSwitch:=Scanner.CompilerModeSwitch; FLastCompilerModeSwitches:=Scanner.CompilerModeSwitches;
NewSrc:=Scanner.CleanedSrc; NewSrc:=Scanner.CleanedSrc;
NewSrcLen:=length(NewSrc); NewSrcLen:=length(NewSrc);
if AllChanged then begin if AllChanged then begin