Binder refactoring - extracted TCO - WIP

This commit is contained in:
Michael Schimmel
2025-11-01 15:44:56 +01:00
parent 915deb4dc0
commit 8f29212cba
6 changed files with 228 additions and 151 deletions
+6 -2
View File
@@ -41,6 +41,7 @@ uses
Myc.Ast.MacroExpander,
Myc.Ast.TypeChecker,
Myc.Ast.Lowering,
Myc.Ast.Compiler.TCO,
FMX.DialogService,
FMX.ListView.Types,
FMX.ListView.Appearances,
@@ -214,7 +215,7 @@ end;
function TForm1.CompileAst(const ANode: IAstNode; const AParentScope: IExecutionScope; out ADescriptor: IScopeDescriptor): IAstNode;
var
macroDescriptor: IScopeDescriptor;
expandedAst, boundAst, typedAst: IAstNode;
expandedAst, boundAst, typedAst, loweredAst: IAstNode;
begin
// Step 1: Expand macros (Phase 1)
expandedAst := TMacroExpander.ExpandMacros(AParentScope, ANode, macroDescriptor, CreateEvaluator);
@@ -226,7 +227,10 @@ begin
typedAst := TTypeChecker.CheckTypes(boundAst, ADescriptor);
// Step 4: Lowering / Canonicalization (Phase 4)
Result := TAstLowerer.Lower(typedAst);
loweredAst := TAstLowerer.Lower(typedAst);
// Step 5: Tail Call Optimization (Phase 5)
Result := TAstTCO.Optimize(loweredAst);
end;
function TForm1.ExecuteAst(const ANode: IAstNode; const AParentScope: IExecutionScope): TDataValue;