Ast environment refactoring

This commit is contained in:
Michael Schimmel
2025-11-08 15:57:12 +01:00
parent c16f47c6d5
commit 93dc19497c
5 changed files with 109 additions and 166 deletions
+2 -2
View File
@@ -19,7 +19,6 @@ type
private
FScope: IExecutionScope;
class var
procedure HandleTCO(var ResultValue: TDataValue);
protected
// IAstVisitor methods made virtual for TDebugEvaluatorVisitor to override
@@ -60,6 +59,7 @@ type
// Executes an AST with proper TCO handling. This is the main entry point.
function Execute(const RootNode: IAstNode): TDataValue;
class procedure HandleTCO(var ResultValue: TDataValue); static;
end;
implementation
@@ -149,7 +149,7 @@ begin
Result := function(const AScope: IExecutionScope): IEvaluatorVisitor begin Result := TEvaluatorVisitor.Create(AScope); end;
end;
procedure TEvaluatorVisitor.HandleTCO(var ResultValue: TDataValue);
class procedure TEvaluatorVisitor.HandleTCO(var ResultValue: TDataValue);
begin
// This is the central trampoline loop for Tail Call Optimization.
// It runs as long as the evaluation returns a thunk.