Finished node immutability

This commit is contained in:
Michael Schimmel
2025-11-05 18:33:29 +01:00
parent 1f0eef7698
commit 5003cfd899
5 changed files with 71 additions and 80 deletions
-20
View File
@@ -91,26 +91,6 @@ var
left, right: IAstNode;
nodeType: IStaticType;
begin
// Get the type *before* replacing the node (it's an IAstTypedNode)
nodeType := Node.AsTypedNode.StaticType;
// --- Transformation: Keyword-as-Function ---
if Node.Callee.Kind = akKeyword then
begin
var keywordNode := Node.Callee.AsKeyword;
if Length(Node.Arguments) <> 1 then
raise EArgumentException.CreateFmt(
'Keyword :%s expects exactly one argument (the record/map), but got %d',
[keywordNode.Value.Name, Length(Node.Arguments)]);
// Visit the base node
var baseNode := Accept(Node.Arguments[0]);
// Create the new MemberAccess node, preserving the type
Result := TAst.MemberAccess(baseNode, keywordNode, nodeType);
exit;
end;
// --- Optimization: Operator Folding ---
if Node.Callee.Kind = akIdentifier then
begin