Developing State handling

This commit is contained in:
Michael Schimmel
2025-10-22 13:26:51 +02:00
parent 03465e21d2
commit dd72401ab5
9 changed files with 465 additions and 109 deletions
+8 -3
View File
@@ -50,15 +50,20 @@ implementation
function TInterpreterScopeTests.Execute(const ANode: IAstNode): TDataValue;
var
binder: IAstBinder;
boundNode: IAstNode;
descriptor: IScopeDescriptor;
runtimeScope: IExecutionScope;
visitor: IEvaluatorVisitor;
begin
// Helper to encapsulate the Bind -> CreateScope -> Evaluate pattern.
binder := TAstBinder.Create(FGlobalScope);
boundNode := binder.Execute(ANode, descriptor);
// The binder needs an evaluator factory to expand macros (even if there are none).
boundNode :=
TAstBinder.Bind(
FGlobalScope,
ANode,
descriptor,
function(const Scope: IExecutionScope): IEvaluatorVisitor begin Result := TEvaluatorVisitor.Create(Scope); end
);
runtimeScope := descriptor.CreateScope(FGlobalScope);
visitor := TEvaluatorVisitor.Create(runtimeScope);
Result := visitor.Execute(boundNode);