Refactoring for immutable nodes
This commit is contained in:
@@ -117,11 +117,10 @@ end;
|
||||
function TAstTCO.VisitBlockExpression(const Node: IBlockExpressionNode): IAstNode;
|
||||
var
|
||||
isContextTail: Boolean;
|
||||
newExprs: TArray<IAstNode>; // For CoW
|
||||
newExprs: TArray<IAstNode>;
|
||||
begin
|
||||
isContextTail := FIsTailStack.Peek;
|
||||
|
||||
// Call the base implementation which handles CoW
|
||||
var nTail := High(Node.Expressions);
|
||||
newExprs :=
|
||||
AcceptNodes(
|
||||
@@ -237,20 +236,17 @@ end;
|
||||
|
||||
function TAstTCO.VisitMacroExpansionNode(const Node: IMacroExpansionNode): IAstNode;
|
||||
var
|
||||
N: TMacroExpansionNode;
|
||||
newBody: IAstNode;
|
||||
begin
|
||||
N := (Node as TMacroExpansionNode);
|
||||
|
||||
// Propagate tail call status to the expanded body
|
||||
FNextIsTail := FIsTailStack.Peek;
|
||||
newBody := Accept(N.ExpandedBody);
|
||||
newBody := Accept(Node.ExpandedBody);
|
||||
|
||||
if newBody = N.ExpandedBody then
|
||||
if newBody = Node.ExpandedBody then
|
||||
Result := Node
|
||||
else
|
||||
// Rebuild, preserving the original CallNode metadata
|
||||
Result := TMacroExpansionNode.Create(N.CallNode, newBody, newBody.AsTypedNode.StaticType);
|
||||
Result := TMacroExpansionNode.Create(Node.CallNode, newBody.AsTypedNode);
|
||||
end;
|
||||
|
||||
function TAstTCO.VisitFunctionCall(const Node: IFunctionCallNode): IAstNode;
|
||||
|
||||
Reference in New Issue
Block a user