Refactoring for immutable nodes

This commit is contained in:
Michael Schimmel
2025-11-05 13:21:17 +01:00
parent 9bd2d6f7ab
commit c0a689d2bc
13 changed files with 217 additions and 190 deletions
+5 -5
View File
@@ -401,7 +401,7 @@ begin
if sym.Address.Kind = akUnresolved then
begin
// Distinguish between loading a macro and loading a function.
if funcAst is TMacroDefinitionNode then
if funcAst.Kind = akMacroDefinition then
begin
// Macros are stored as raw AST nodes in the scope.
FGScope.Define(pair.JsonString.Value, TDataValue.FromIntf<IAstNode>(funcAst));
@@ -461,9 +461,9 @@ begin
definitions.Add(decl.Identifier.Name, decl.Initializer);
end
// Handle macro definitions inside the block
else if expr is TMacroDefinitionNode then
else if expr.Kind = akMacroDefinition then
begin
var macroDef := expr as TMacroDefinitionNode;
var macroDef := expr.AsMacroDefinition;
// Store the entire macro definition node for serialization.
definitions.Add(macroDef.Name.Name, macroDef);
end;
@@ -475,9 +475,9 @@ begin
definitions.Add(decl.Identifier.Name, decl.Initializer);
end
// Handle a single macro definition
else if rootNode is TMacroDefinitionNode then
else if rootNode.Kind = akMacroDefinition then
begin
var macroDef := rootNode as TMacroDefinitionNode;
var macroDef := rootNode.AsMacroDefinition;
definitions.Add(macroDef.Name.Name, macroDef);
end;
+1 -1
View File
@@ -1809,7 +1809,7 @@ end;
function TMacroExpansionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode;
begin
Result := TAst.MacroExpansionNode(FNode.CallNode, FExpandedBodyNode.CreateAst);
Result := TAst.MacroExpansionNode(FNode.CallNode, FExpandedBodyNode.CreateAst.AsTypedNode);
end;
{ TRecurNodeHandler }