Refactoring

This commit is contained in:
Michael Schimmel
2025-11-05 13:48:10 +01:00
parent c0a689d2bc
commit 218bd9f506
4 changed files with 25 additions and 25 deletions
+1 -1
View File
@@ -246,7 +246,7 @@ begin
Result := Node
else
// Rebuild, preserving the original CallNode metadata
Result := TMacroExpansionNode.Create(Node.CallNode, newBody.AsTypedNode);
Result := TAst.MacroExpansionNode(Node.CallNode, newBody);
end;
function TAstTCO.VisitFunctionCall(const Node: IFunctionCallNode): IAstNode;
+8 -8
View File
@@ -112,7 +112,7 @@ type
TScopeItem = record
Value: TDataValue;
IsBoxed: Boolean;
function GetContent: TDataValue;
function GetContent: TDataValue; inline;
end;
private
@@ -485,6 +485,13 @@ begin
end;
end;
function TExecutionScope.TScopeItem.GetContent: TDataValue;
begin
Result := Value;
if IsBoxed then
Result := Result.AsIntf<IValueCell>.Value;
end;
{ TScopeDescriptor }
constructor TScopeDescriptor.Create(const AParent: IScopeDescriptor);
@@ -657,11 +664,4 @@ begin
Result := TExecutionScope.Create(Parent, Descriptor, CapturedUpvalues);
end;
function TExecutionScope.TScopeItem.GetContent: TDataValue;
begin
Result := Value;
if IsBoxed then
Result := Result.AsIntf<IValueCell>.Value;
end;
end.
+1 -1
View File
@@ -579,7 +579,7 @@ begin
exit(Node);
// The body changed. Create a NEW wrapper node.
Result := TMacroExpansionNode.Create(Node.CallNode, newBody);
Result := TAst.MacroExpansionNode(Node.CallNode, newBody);
end;
function TAstTransformer.VisitBlockExpression(const Node: IBlockExpressionNode): IAstNode;
+15 -15
View File
@@ -252,21 +252,6 @@ type
property Arguments: TArray<IAstNode> read FArguments write FArguments; // Writeable
end;
TMacroExpansionNode = class(TAstTypedNode, IMacroExpansionNode)
private
FCallNode: IFunctionCallNode;
FExpandedBody: IAstTypedNode;
function GetCallNode: IFunctionCallNode;
function GetExpandedBody: IAstNode;
function GetKind: TAstNodeKind; override;
public
constructor Create(const ACallNode: IFunctionCallNode; const AExpandedBody: IAstTypedNode);
function Accept(const Visitor: IAstVisitor): TDataValue; override;
function AsMacroExpansion: IMacroExpansionNode; override;
property CallNode: IFunctionCallNode read GetCallNode;
property ExpandedBody: IAstTypedNode read FExpandedBody;
end;
TBlockExpressionNode = class(TAstTypedNode, IBlockExpressionNode)
private
FExpressions: TArray<IAstNode>;
@@ -516,6 +501,21 @@ type
property Expression: IQuasiquoteNode read GetExpression;
end;
TMacroExpansionNode = class(TAstTypedNode, IMacroExpansionNode)
private
FCallNode: IFunctionCallNode;
FExpandedBody: IAstTypedNode;
function GetCallNode: IFunctionCallNode;
function GetExpandedBody: IAstNode;
function GetKind: TAstNodeKind; override;
public
constructor Create(const ACallNode: IFunctionCallNode; const AExpandedBody: IAstTypedNode);
function Accept(const Visitor: IAstVisitor): TDataValue; override;
function AsMacroExpansion: IMacroExpansionNode; override;
property CallNode: IFunctionCallNode read GetCallNode;
property ExpandedBody: IAstTypedNode read FExpandedBody;
end;
TNopNode = class(TAstNode, INopNode)
private
function GetKind: TAstNodeKind; override;