Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Methods #213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Source/DelphiAST.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1461,19 +1461,28 @@ procedure TPasSyntaxTreeBuilder.FunctionMethodName;

procedure TPasSyntaxTreeBuilder.FunctionProcedureName;
var
ChildNode, NameNode, TypeParam, TypeNode, Temp: TSyntaxNode;
ChildNode, NameNode, TypeParamsNode, TypeParam, TypeNode, Temp: TSyntaxNode;
FullName, TypeParams: string;
begin
FStack.Push(ntName);
TypeParamsNode := Nil;
NameNode := FStack.Peek;
try
inherited;
TypeParams := '';
for ChildNode in NameNode.ChildNodes do
begin
if TypeParams <> '' then
FullName := FullName + '<' + TypeParams + '>';

TypeParams := '';

TypeParamsNode := Nil;
if ChildNode.Typ = ntTypeParams then
begin
TypeParamsNode := ChildNode;
TypeParams := '';

for TypeParam in ChildNode.ChildNodes do
begin
TypeNode := TypeParam.FindNode(ntType);
Expand All @@ -1485,7 +1494,6 @@ procedure TPasSyntaxTreeBuilder.FunctionProcedureName;
end;
end;

FullName := FullName + '<' + TypeParams + '>';
Continue;
end;

Expand All @@ -1498,6 +1506,11 @@ procedure TPasSyntaxTreeBuilder.FunctionProcedureName;
Temp := FStack.Peek;
DoHandleString(FullName);
Temp.SetAttribute(anName, FullName);
if Assigned(TypeParamsNode) then
begin
NameNode.ExtractChild(TypeParamsNode);
Temp.AddChild(TypeParamsNode);
end;
Temp.DeleteChild(NameNode);
end;
end;
Expand Down
10 changes: 5 additions & 5 deletions Source/SimpleParser/SimpleParser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ procedure TmwSimplePasPar.FunctionMethodDeclaration;
else
begin
Expected(ptColon);
ReturnType;
ReturnType;
FunctionProcedureBlock;
end;
end;
Expand Down Expand Up @@ -2119,7 +2119,7 @@ procedure TmwSimplePasPar.FunctionProcedureBlock;
end;

if HasBlock then
begin
begin
case TokenID of
ptAsm:
begin
Expand Down Expand Up @@ -4412,7 +4412,7 @@ procedure TmwSimplePasPar.ExplicitType;
end;

procedure TmwSimplePasPar.TypeKind;
begin
begin
case TokenID of
ptAsciiChar, ptFloat, ptIntegerConst, ptMinus, ptNil, ptPlus, ptStringConst, ptConst:
begin
Expand Down Expand Up @@ -4678,7 +4678,7 @@ procedure TmwSimplePasPar.ProcedureDeclarationSection;
else
begin
SynError(InvalidProcedureDeclarationSection);
end;
end;
end;
end;

Expand Down Expand Up @@ -5746,4 +5746,4 @@ procedure TmwSimplePasPar.CustomAttribute;
AttributeSections;
end;

end.
end.