Codetools: Support ArrayToDynArray and other missing modeswitches. Issue #36796.

git-svn-id: trunk@62768 -
This commit is contained in:
juha 2020-03-15 17:55:43 +00:00
parent 51f2804834
commit de408de69e
2 changed files with 13 additions and 9 deletions

View File

@ -1777,7 +1777,7 @@ procedure TFDHelpersList.AddFromList(const Tool: TFindDeclarationTool;
FromNode: TFDHelpersListItem; FromNode: TFDHelpersListItem;
begin begin
FromNode := TFDHelpersListItem(ANode.Data); FromNode := TFDHelpersListItem(ANode.Data);
if (Kind=fdhlkDelphiHelper) and not (msMultiHelpers in Tool.Scanner.CompilerModeSwitches) then if (Kind=fdhlkDelphiHelper) and not (cmsMultiHelpers in Tool.Scanner.CompilerModeSwitches) then
if FTree.FindKey(FromNode, @CompareHelpersList) <> nil then if FTree.FindKey(FromNode, @CompareHelpersList) <> nil then
Exit(nil); //FPC & Delphi don't support duplicate class helpers! Exit(nil); //FPC & Delphi don't support duplicate class helpers!
Result := TFDHelpersListItem.Create; Result := TFDHelpersListItem.Create;
@ -1841,7 +1841,7 @@ begin
if ExprType.Desc in xtAllIdentTypes then if ExprType.Desc in xtAllIdentTypes then
begin begin
if (Kind=fdhlkDelphiHelper) and not (msMultiHelpers in Tool.Scanner.CompilerModeSwitches) then begin if (Kind=fdhlkDelphiHelper) and not (cmsMultiHelpers in Tool.Scanner.CompilerModeSwitches) then begin
// class/type/record helpers only allow one helper per class // class/type/record helpers only allow one helper per class
OldKey := FTree.FindKey(@ExprType, @CompareHelpersListExprType); OldKey := FTree.FindKey(@ExprType, @CompareHelpersListExprType);
if OldKey <> nil then if OldKey <> nil then
@ -4520,7 +4520,7 @@ var
finally finally
Params.Flags := OldFlags; Params.Flags := OldFlags;
end; end;
until ((HelperKind=fdhlkDelphiHelper) and not (msMultiHelpers in Params.StartTool.Scanner.CompilerModeSwitches)) until ((HelperKind=fdhlkDelphiHelper) and not (cmsMultiHelpers in Params.StartTool.Scanner.CompilerModeSwitches))
or (not Helpers.GetNext(HelperContext,HelperIterator)); or (not Helpers.GetNext(HelperContext,HelperIterator));
//debugln(['SearchInHelpers END']); //debugln(['SearchInHelpers END']);
end; end;

View File

@ -213,19 +213,21 @@ type
ansistring; similarly, char becomes unicodechar rather than ansichar } ansistring; similarly, char becomes unicodechar rather than ansichar }
cmsTypeHelpers, { allows the declaration of "type helper" (non-Delphi) or "record helper" cmsTypeHelpers, { allows the declaration of "type helper" (non-Delphi) or "record helper"
(Delphi) for primitive types } (Delphi) for primitive types }
cmsClosures, { Anonymous methods } cmsClosures, { Anonymous methods } // not in tmodeswitch / globtype.pas !!!
cmsCBlocks, { support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension) } cmsCBlocks, { support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension) }
cmsISOlike_IO, { I/O as it required by an ISO compatible compiler } cmsISOlike_IO, { I/O as it required by an ISO compatible compiler }
cmsISOLike_Program_Para, { program parameters as it required by an ISO compatible compiler } cmsISOLike_Program_Para, { program parameters as it required by an ISO compatible compiler }
cmsISOLike_Mod, { mod operation as it is required by an iso compatible compiler } cmsISOLike_Mod, { mod operation as it is required by an iso compatible compiler }
cmsArrayOperators, { use Delphi compatible array operators instead of custom ones ("+") } cmsArrayOperators, { use Delphi compatible array operators instead of custom ones ("+") }
cmsMultiHelpers, { helpers can appear in multiple scopes simultaneously }
cmsArray2dynarray, { regular arrays can be implicitly converted to dynamic arrays }
cmsPrefixedAttributes, { enable attributes that are defined before the type they belong to }
// not yet in FPC, supported by pas2js: // not yet in FPC, supported by pas2js:
cmsPrefixedAttributes, { allow Delphi attributes, disable FPC [] proc modifier }
cmsExternalClass, { pas2js: allow class external [pkgname] name [symbol] } cmsExternalClass, { pas2js: allow class external [pkgname] name [symbol] }
cmsIgnoreAttributes, { pas2js: ignore attributes } cmsIgnoreAttributes, { pas2js: ignore attributes }
cmsOmitRTTI, { pas2js: treat class section 'published' as 'public' and typeinfo does not work on symbols declared with this switch } cmsOmitRTTI, { pas2js: treat class section 'published' as 'public' and typeinfo does not work on symbols declared with this switch }
msMultiHelpers, { off=only one helper per type, on=all } cmsImplicitFunctionSpecialization { infer types on calls of generic functions }
msImplicitFunctionSpecialization { infer types on calls of generic functions }
); );
TCompilerModeSwitches = set of TCompilerModeSwitch; TCompilerModeSwitches = set of TCompilerModeSwitch;
const const
@ -303,17 +305,19 @@ const
'FINALFIELDS', 'FINALFIELDS',
'UNICODESTRINGS', 'UNICODESTRINGS',
'TYPEHELPERS', 'TYPEHELPERS',
'CLOSURES', 'CLOSURES', // not in tmodeswitch / globtype.pas
'CBLOCKS', 'CBLOCKS',
'ISOIO', 'ISOIO',
'ISOPROGRAMPARAS', 'ISOPROGRAMPARAS',
'ISOMOD', 'ISOMOD',
'ARRAYOPERATORS', 'ARRAYOPERATORS',
'MULTIHELPERS',
'ARRAYTODYNARRAY',
'PREFIXEDATTRIBUTES', 'PREFIXEDATTRIBUTES',
// not yet in FPC, supported by pas2js:
'EXTERNALCLASS', 'EXTERNALCLASS',
'IGNOREATTRIBUTES', 'IGNOREATTRIBUTES',
'OMITRTTI', 'OMITRTTI',
'MULTIHELPERS',
'IMPLICITFUNCTIONSPECIALIZATION' 'IMPLICITFUNCTIONSPECIALIZATION'
); );