Fixed macro expansion
This commit is contained in:
@@ -212,11 +212,6 @@ begin
|
||||
FNextIsTail := FIsTailStack.Peek;
|
||||
N.ExpandedBody := Accept(N.ExpandedBody);
|
||||
|
||||
// Also visit the original call nodes, though they are not in tail pos
|
||||
FNextIsTail := False;
|
||||
N.Callee := Accept(N.Callee);
|
||||
N.Arguments := AcceptNodes(N.Arguments);
|
||||
|
||||
Result := N;
|
||||
end;
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ type
|
||||
function VisitKeyword(const Node: IKeywordNode): IAstNode; override;
|
||||
|
||||
// Compile-time nodes (should not be present)
|
||||
function VisitMacroExpansionNode(const Node: IMacroExpansionNode): IAstNode; override;
|
||||
function VisitMacroDefinition(const Node: IMacroDefinitionNode): IAstNode; override;
|
||||
public
|
||||
constructor Create(const ADescriptor: IScopeDescriptor);
|
||||
@@ -148,12 +147,6 @@ begin
|
||||
raise Exception.Create('TTypeChecker: MacroDefinition node encountered.');
|
||||
end;
|
||||
|
||||
function TTypeChecker.VisitMacroExpansionNode(const Node: IMacroExpansionNode): IAstNode;
|
||||
begin
|
||||
// TypeChecker runs *after* expansion, so we just visit the body.
|
||||
Result := Accept(Node.ExpandedBody);
|
||||
end;
|
||||
|
||||
function TTypeChecker.VisitVariableDeclaration(const Node: IVariableDeclarationNode): IAstNode;
|
||||
var
|
||||
initType: IStaticType;
|
||||
|
||||
@@ -503,12 +503,14 @@ var
|
||||
N: TMacroExpansionNode;
|
||||
begin
|
||||
N := (Node as TMacroExpansionNode);
|
||||
// Visit original call parts
|
||||
N.Callee := Accept(N.Callee);
|
||||
N.Arguments := AcceptNodes(N.Arguments);
|
||||
// Visit expanded body
|
||||
|
||||
// ONLY visit the expanded body, as this is the "real" AST node.
|
||||
N.ExpandedBody := Accept(N.ExpandedBody);
|
||||
Result := Node;
|
||||
|
||||
// Callee and Arguments are metadata for the visualizer and must NOT be visited
|
||||
// by subsequent phases (Binder, TypeChecker, etc.).
|
||||
|
||||
Result := Node; // Return the (mutated) wrapper
|
||||
end;
|
||||
|
||||
function TAstTransformer.VisitBlockExpression(const Node: IBlockExpressionNode): IAstNode;
|
||||
|
||||
Reference in New Issue
Block a user