Refactoring
This commit is contained in:
@@ -246,7 +246,7 @@ begin
|
|||||||
Result := Node
|
Result := Node
|
||||||
else
|
else
|
||||||
// Rebuild, preserving the original CallNode metadata
|
// Rebuild, preserving the original CallNode metadata
|
||||||
Result := TMacroExpansionNode.Create(Node.CallNode, newBody.AsTypedNode);
|
Result := TAst.MacroExpansionNode(Node.CallNode, newBody);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAstTCO.VisitFunctionCall(const Node: IFunctionCallNode): IAstNode;
|
function TAstTCO.VisitFunctionCall(const Node: IFunctionCallNode): IAstNode;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ type
|
|||||||
TScopeItem = record
|
TScopeItem = record
|
||||||
Value: TDataValue;
|
Value: TDataValue;
|
||||||
IsBoxed: Boolean;
|
IsBoxed: Boolean;
|
||||||
function GetContent: TDataValue;
|
function GetContent: TDataValue; inline;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -485,6 +485,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TExecutionScope.TScopeItem.GetContent: TDataValue;
|
||||||
|
begin
|
||||||
|
Result := Value;
|
||||||
|
if IsBoxed then
|
||||||
|
Result := Result.AsIntf<IValueCell>.Value;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TScopeDescriptor }
|
{ TScopeDescriptor }
|
||||||
|
|
||||||
constructor TScopeDescriptor.Create(const AParent: IScopeDescriptor);
|
constructor TScopeDescriptor.Create(const AParent: IScopeDescriptor);
|
||||||
@@ -657,11 +664,4 @@ begin
|
|||||||
Result := TExecutionScope.Create(Parent, Descriptor, CapturedUpvalues);
|
Result := TExecutionScope.Create(Parent, Descriptor, CapturedUpvalues);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TExecutionScope.TScopeItem.GetContent: TDataValue;
|
|
||||||
begin
|
|
||||||
Result := Value;
|
|
||||||
if IsBoxed then
|
|
||||||
Result := Result.AsIntf<IValueCell>.Value;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ begin
|
|||||||
exit(Node);
|
exit(Node);
|
||||||
|
|
||||||
// The body changed. Create a NEW wrapper node.
|
// The body changed. Create a NEW wrapper node.
|
||||||
Result := TMacroExpansionNode.Create(Node.CallNode, newBody);
|
Result := TAst.MacroExpansionNode(Node.CallNode, newBody);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAstTransformer.VisitBlockExpression(const Node: IBlockExpressionNode): IAstNode;
|
function TAstTransformer.VisitBlockExpression(const Node: IBlockExpressionNode): IAstNode;
|
||||||
|
|||||||
+15
-15
@@ -252,21 +252,6 @@ type
|
|||||||
property Arguments: TArray<IAstNode> read FArguments write FArguments; // Writeable
|
property Arguments: TArray<IAstNode> read FArguments write FArguments; // Writeable
|
||||||
end;
|
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)
|
TBlockExpressionNode = class(TAstTypedNode, IBlockExpressionNode)
|
||||||
private
|
private
|
||||||
FExpressions: TArray<IAstNode>;
|
FExpressions: TArray<IAstNode>;
|
||||||
@@ -516,6 +501,21 @@ type
|
|||||||
property Expression: IQuasiquoteNode read GetExpression;
|
property Expression: IQuasiquoteNode read GetExpression;
|
||||||
end;
|
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)
|
TNopNode = class(TAstNode, INopNode)
|
||||||
private
|
private
|
||||||
function GetKind: TAstNodeKind; override;
|
function GetKind: TAstNodeKind; override;
|
||||||
|
|||||||
Reference in New Issue
Block a user