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
+6 -6
View File
@@ -113,9 +113,9 @@ begin
try
for var node in ANodes do
begin
if (node is TUnquoteSplicingNode) then
if node.Kind = akUnquoteSplicing then
begin
var spliceExpr := (node as TUnquoteSplicingNode).Expression;
var spliceExpr := node.AsUnquoteSplicing.Expression;
// Evaluate the unquoted expression
var evaluatedSpliceValue := FEvaluate(spliceExpr);
@@ -158,9 +158,9 @@ begin
expr := Node.Expression;
// Check if we are unquoting a macro parameter (simple identifier)
if (expr is TIdentifierNode) then
if expr.Kind = akIdentifier then
begin
symbol := FMacroScope.CreateDescriptor.FindSymbol((expr as TIdentifierNode).Name);
symbol := FMacroScope.CreateDescriptor.FindSymbol(expr.AsIdentifier.Name);
if (symbol.Address.Kind = akLocalOrParent) and (symbol.Address.ScopeDepth = 0) then
begin
// It's a parameter. Return the TDataValue containing the AST node passed as argument.
@@ -269,7 +269,7 @@ end;
function TMacroExpander.VisitFunctionCall(const Node: IFunctionCallNode): IAstNode;
var
calleeIdentifier: TIdentifierNode;
calleeIdentifier: IIdentifierNode;
macroDef: IMacroDefinitionNode;
i: Integer;
begin
@@ -277,7 +277,7 @@ begin
if Node.Callee.Kind <> akIdentifier then
exit(inherited VisitFunctionCall(Node));
calleeIdentifier := Node.Callee as TIdentifierNode;
calleeIdentifier := Node.Callee.AsIdentifier;
// Check if this identifier is a macro
macroDef := FCurrentDescriptor.FindMacro(calleeIdentifier.Name);