RomanYankovsky / DelphiAST

Abstract syntax tree builder for Delphi
Mozilla Public License 2.0
272 stars 117 forks source link

`absolute` directive is not recorded #253

Open JBontes opened 7 years ago

JBontes commented 7 years ago
var 
  x: integer;
  y: integer absolute x;

The absolute is not recorded. and the x is recorded as if it was a value assigned to the variable.

The fix:

procedure TPasSyntaxTreeBuilder.VarAbsolute;
var
  AbsoluteNode: TSyntaxNode;
  ValueNode: TSyntaxNode;
begin
  AbsoluteNode:= TSyntaxNode.Create(ntUnknown);
  FStack.Push(AbsoluteNode);
  try
    inherited;
  finally
    FStack.Pop;
    ValueNode:= AbsoluteNode.ExtractChild(AbsoluteNode.ChildNode[0]);
    ValueNode.Attribute[anKind]:= AttributeValues[atAbsolute];
    AbsoluteNode.Free;
    FStack.Peek.AddChild(ValueNode);
  end;
end;