CodeTools, JCF: Support more procedure directives. Issue #28462, patch from Jeppe Johansen.

git-svn-id: trunk@49591 -
This commit is contained in:
juha 2015-08-03 22:21:59 +00:00
parent ecede8c684
commit 5f8660b1de
4 changed files with 45 additions and 3 deletions

View File

@ -898,6 +898,7 @@ begin
Add('FAR' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('FAR' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('FORWARD' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('FORWARD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('INLINE' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('INLINE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('INTERRUPT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('IOCHECK' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('IOCHECK' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LIBRARY' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('LIBRARY' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LOCAL' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('LOCAL' ,{$ifdef FPC}@{$endif}AllwaysTrue);

View File

@ -1778,6 +1778,8 @@ begin
SaveRaiseCharExpectedButAtomFound(':'); SaveRaiseCharExpectedButAtomFound(':');
ReadNextAtom; ReadNextAtom;
ReadConstant(true,false,[]); ReadConstant(true,false,[]);
end else if UpAtomIs('INTERRUPT') then begin
ReadNextAtom;
end else if UpAtomIs('SYSCALL') then begin end else if UpAtomIs('SYSCALL') then begin
ReadNextAtom; ReadNextAtom;
AtomIsIdentifierSaveE; AtomIsIdentifierSaveE;

View File

@ -248,6 +248,7 @@ type
procedure RecogniseHintDirectives; procedure RecogniseHintDirectives;
procedure RecognisePropertyDirectives; procedure RecognisePropertyDirectives;
procedure RecogniseExternalProcDirective; procedure RecogniseExternalProcDirective;
function RecognisePublicProcDirective: boolean;
procedure RecogniseAttributes; procedure RecogniseAttributes;
@ -3950,6 +3951,12 @@ begin
begin begin
RecogniseExternalProcDirective; RecogniseExternalProcDirective;
end; end;
ttPublic:
begin
{ Break the loop if we have found a class visibility "public" }
if not RecognisePublicProcDirective then
break;
end;
ttDispId: ttDispId:
begin begin
Recognise(ttDispId); Recognise(ttDispId);
@ -3981,14 +3988,20 @@ begin
{ right, i'll fake this one { right, i'll fake this one
ExternalProcDirective -> ExternalProcDirective ->
External ["'" libname "'" ["name" "'" procname "'"]] External ["'" libname "'"] ["name" "'" procname "'"]
also allow "index expr" also allow "index expr"
} }
PushNode(nExternalDirective); PushNode(nExternalDirective);
Recognise(ttExternal); Recognise(ttExternal);
if fcTokenList.FirstSolidTokenType in (IdentiferTokens + [ttQuotedLiteralString]) then
if fcTokenList.FirstSolidTokenType = ttName then
begin
Recognise(ttName);
RecogniseConstantExpression;
end
else if fcTokenList.FirstSolidTokenType in (IdentiferTokens + [ttQuotedLiteralString]) then
begin begin
Recognise((IdentiferTokens + [ttQuotedLiteralString])); Recognise((IdentiferTokens + [ttQuotedLiteralString]));
@ -4008,6 +4021,27 @@ begin
PopNode; PopNode;
end; end;
function TBuildParseTree.RecognisePublicProcDirective: boolean;
begin
{
PublicProcDirective ->
Public ["name" "'" symname "'"]
}
result:=false;
if TopNode.HasParentNode([nClassBody, nObjectType]) then
exit;
Recognise(ttPublic);
if fcTokenList.FirstSolidTokenType = ttName then
begin
Recognise(ttName);
RecogniseConstantExpression;
end;
result:=true;
end;
procedure TBuildParseTree.RecogniseObjectType; procedure TBuildParseTree.RecogniseObjectType;
begin begin
{ ObjectType -> OBJECT [ObjHeritage] [ObjFieldList] [MethodList] END { ObjectType -> OBJECT [ObjHeritage] [ObjFieldList] [MethodList] END

View File

@ -190,6 +190,7 @@ type
ttReintroduce, ttReintroduce,
ttGeneric, ttGeneric,
ttCVar, ttCVar,
ttNostackframe,
// used in asm // used in asm
ttOffset, ttOffset,
ttPtr, ttPtr,
@ -216,6 +217,7 @@ type
{ Additional Free Pascal directives } { Additional Free Pascal directives }
ttExperimental, ttExperimental,
ttUnimplemented, ttUnimplemented,
ttInterrupt,
{ built-in constants } { built-in constants }
ttNil, ttNil,
@ -361,7 +363,8 @@ const
ttNear, ttDynamic, ttExport, ttOverride, ttResident, ttLocal, ttNear, ttDynamic, ttExport, ttOverride, ttResident, ttLocal,
ttOverload, ttReintroduce, ttOverload, ttReintroduce,
ttDeprecated, ttLibrary, ttPlatform, ttExperimental, ttUnimplemented, ttDeprecated, ttLibrary, ttPlatform, ttExperimental, ttUnimplemented,
ttStatic, ttFinal, ttVarArgs, ttUnsafe, ttEnumerator]; ttStatic, ttFinal, ttVarArgs, ttUnsafe, ttEnumerator, ttNostackframe, ttInterrupt,
ttPublic];
ClassDirectives: TTokenTypeSet = ClassDirectives: TTokenTypeSet =
[ttPrivate, ttProtected, ttPublic, ttPublished, ttAutomated, ttStrict]; [ttPrivate, ttProtected, ttPublic, ttPublished, ttAutomated, ttStrict];
@ -684,6 +687,7 @@ begin
AddKeyword('reintroduce', wtReservedWordDirective, ttReintroduce); AddKeyword('reintroduce', wtReservedWordDirective, ttReintroduce);
AddKeyword('cvar', wtReservedWordDirective, ttCVar); AddKeyword('cvar', wtReservedWordDirective, ttCVar);
AddKeyword('nostackframe', wtReservedWordDirective, ttNostackframe);
// asm // asm
AddKeyword('offset', wtReservedWordDirective, ttOffset); AddKeyword('offset', wtReservedWordDirective, ttOffset);
@ -712,6 +716,7 @@ begin
{ Additional Free Pascal directives } { Additional Free Pascal directives }
AddKeyword('experimental', wtReservedWordDirective, ttExperimental); AddKeyword('experimental', wtReservedWordDirective, ttExperimental);
AddKeyword('unimplemented', wtReservedWordDirective, ttUnimplemented); AddKeyword('unimplemented', wtReservedWordDirective, ttUnimplemented);
AddKeyword('interrupt', wtReservedWordDirective, ttInterrupt);
{ operators that are words not symbols } { operators that are words not symbols }
AddKeyword('and', wtOperator, ttAnd); AddKeyword('and', wtOperator, ttAnd);