RomanYankovsky / DelphiAST

Abstract syntax tree builder for Delphi
Mozilla Public License 2.0
271 stars 116 forks source link

procedure declaration with varargs are not supported. #246

Closed JBontes closed 4 years ago

JBontes commented 6 years ago

Fix:

varargs is a kind of external directive.

type
  TAttributeValue = (atAsm, atTrue, atFunction, atProcedure, atOperator, atClassOf, atClass,
    atConst, atConstructor, atDestructor, atEnum, atInterface, atNil, atNumeric,
    atOut, atPointer, atName, atString, atSubRange, atVar, atType{ExplicitType},
    atObject, atSealed, atAbstract, atBegin, atOf_Object{procedure of object},
    atVarargs, atExternal{Varargs and external are mutually exclusive});

procedure TPasSyntaxTreeBuilder.DirectiveVarargs;
begin
  FStack.Push(ntExternal).Attribute[anKind]:= AttributeValues[atVarArgs];
  try
    inherited;
  finally
    FStack.Pop;
  end;
end;

procedure TPasSyntaxTreeBuilder.ExternalDirective;
begin
  FStack.Push(ntExternal).Attribute[anKind]:= AttributeValues[atExternal];
  try
    inherited;
  finally
    FStack.Pop;
  end;
end;