RomanYankovsky / DelphiAST

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

Both a class and object can be declared forward. Forwarded object does not currently register. #226

Open JBontes opened 6 years ago

JBontes commented 6 years ago

Currently DelphiAST does not register a forwarded object type reference.
The following snippet fixes this issue.

procedure TPasSyntaxTreeBuilder.ObjectForward;
begin
  FStack.Peek.SetAttribute(anForwarded, AttributeValues[atTrue]);
  FStack.Peek.SetAttribute(anType, AttributeValues[atObject]);
  inherited;
end;

procedure TPasSyntaxTreeBuilder.ClassForward;
begin
  FStack.Peek.SetAttribute(anForwarded, AttributeValues[atTrue]);
  FStack.Peek.SetAttribute(anType, AttributeValues[atClass]);
  inherited;
end;

type
  TAttributeValue = (atAsm, atTrue, atFunction, atProcedure, atClassOf, atClass,
    atConst, atConstructor, atDestructor, atEnum, atInterface, atNil, atNumeric,
    atOut, atPointer, atName, atString, atSubRange, atVar, atType{ExplicitType},
    atObject);

We need to add a attribute anType so we can know if it's a forwarded class or object reference.