Imutability for macro nodes

This commit is contained in:
Michael Schimmel
2025-11-05 12:19:34 +01:00
parent 60358365cd
commit 9bd2d6f7ab
10 changed files with 385 additions and 151 deletions
+22 -20
View File
@@ -179,7 +179,7 @@ type
// This node is illegal during compilation.
end;
IConstantNode = interface(IAstNode)
IConstantNode = interface(IAstTypedNode)
// Represents a constant value in the AST (Scalar, Text, or Void).
{$region 'private'}
function GetValue: TDataValue;
@@ -187,7 +187,7 @@ type
property Value: TDataValue read GetValue;
end;
IIdentifierNode = interface(IAstNode)
IIdentifierNode = interface(IAstTypedNode)
{$region 'private'}
function GetName: string;
{$endregion}
@@ -202,7 +202,7 @@ type
end;
// Represents a keyword literal in the AST (e.g., :foo)
IKeywordNode = interface(IAstNode)
IKeywordNode = interface(IAstTypedNode)
{$region 'private'}
function GetValue: IKeyword;
{$endregion}
@@ -210,7 +210,7 @@ type
property Value: IKeyword read GetValue;
end;
IBinaryExpressionNode = interface(IAstNode)
IBinaryExpressionNode = interface(IAstTypedNode)
{$region 'private'}
function GetLeft: IAstNode;
function GetOperator: TScalar.TBinaryOp;
@@ -221,7 +221,7 @@ type
property Right: IAstNode read GetRight;
end;
IUnaryExpressionNode = interface(IAstNode)
IUnaryExpressionNode = interface(IAstTypedNode)
{$region 'private'}
function GetOperator: TScalar.TUnaryOp;
function GetRight: IAstNode;
@@ -230,7 +230,7 @@ type
property Right: IAstNode read GetRight;
end;
IIfExpressionNode = interface(IAstNode)
IIfExpressionNode = interface(IAstTypedNode)
{$region 'private'}
function GetCondition: IAstNode;
function GetThenBranch: IAstNode;
@@ -241,7 +241,7 @@ type
property ElseBranch: IAstNode read GetElseBranch;
end;
ITernaryExpressionNode = interface(IAstNode)
ITernaryExpressionNode = interface(IAstTypedNode)
{$region 'private'}
function GetCondition: IAstNode;
function GetThenBranch: IAstNode;
@@ -252,7 +252,7 @@ type
property ElseBranch: IAstNode read GetElseBranch;
end;
ILambdaExpressionNode = interface(IAstNode)
ILambdaExpressionNode = interface(IAstTypedNode)
{$region 'private'}
function GetParameters: TArray<IIdentifierNode>;
function GetBody: IAstNode;
@@ -261,7 +261,7 @@ type
property Body: IAstNode read GetBody;
end;
IFunctionCallNode = interface(IAstNode)
IFunctionCallNode = interface(IAstTypedNode)
{$region 'private'}
function GetCallee: IAstNode;
function GetArguments: TArray<IAstNode>;
@@ -271,30 +271,32 @@ type
end;
// A node representing a macro call.
IMacroExpansionNode = interface(IFunctionCallNode)
IMacroExpansionNode = interface(IAstTypedNode)
{$region 'private'}
function GetCallNode: IFunctionCallNode;
function GetExpandedBody: IAstNode;
{$endregion}
// The AST fragment that resulted from the macro expansion.
property CallNode: IFunctionCallNode read GetCallNode;
property ExpandedBody: IAstNode read GetExpandedBody;
end;
// A node representing a tail-recursive call.
IRecurNode = interface(IAstNode)
IRecurNode = interface(IAstTypedNode)
{$region 'private'}
function GetArguments: TArray<IAstNode>;
{$endregion}
property Arguments: TArray<IAstNode> read GetArguments;
end;
IBlockExpressionNode = interface(IAstNode)
IBlockExpressionNode = interface(IAstTypedNode)
{$region 'private'}
function GetExpressions: TArray<IAstNode>;
{$endregion}
property Expressions: TArray<IAstNode> read GetExpressions;
end;
IVariableDeclarationNode = interface(IAstNode)
IVariableDeclarationNode = interface(IAstTypedNode)
{$region 'private'}
function GetIdentifier: IIdentifierNode;
function GetInitializer: IAstNode;
@@ -303,7 +305,7 @@ type
property Initializer: IAstNode read GetInitializer;
end;
IAssignmentNode = interface(IAstNode)
IAssignmentNode = interface(IAstTypedNode)
{$region 'private'}
function GetIdentifier: IIdentifierNode;
function GetValue: IAstNode;
@@ -347,7 +349,7 @@ type
property Expression: IQuasiquoteNode read GetExpression;
end;
IIndexerNode = interface(IAstNode)
IIndexerNode = interface(IAstTypedNode)
{$region 'private'}
function GetBase: IAstNode;
function GetIndex: IAstNode;
@@ -356,7 +358,7 @@ type
property Index: IAstNode read GetIndex;
end;
IMemberAccessNode = interface(IAstNode)
IMemberAccessNode = interface(IAstTypedNode)
{$region 'private'}
function GetBase: IAstNode;
function GetMember: IKeywordNode;
@@ -366,21 +368,21 @@ type
end;
// Represents a record literal, e.g., {:a 1 :b 2}
IRecordLiteralNode = interface(IAstNode)
IRecordLiteralNode = interface(IAstTypedNode)
{$region 'private'}
function GetFields: TArray<TRecordFieldLiteral>;
{$endregion}
property Fields: TArray<TRecordFieldLiteral> read GetFields;
end;
ICreateSeriesNode = interface(IAstNode)
ICreateSeriesNode = interface(IAstTypedNode)
{$region 'private'}
function GetDefinition: String;
{$endregion}
property Definition: String read GetDefinition;
end;
IAddSeriesItemNode = interface(IAstNode)
IAddSeriesItemNode = interface(IAstTypedNode)
{$region 'private'}
function GetSeries: IIdentifierNode;
function GetValue: IAstNode;
@@ -391,7 +393,7 @@ type
property Lookback: IAstNode read GetLookback;
end;
ISeriesLengthNode = interface(IAstNode)
ISeriesLengthNode = interface(IAstTypedNode)
{$region 'private'}
function GetSeries: IIdentifierNode;
{$endregion}