AST Types

This commit is contained in:
Michael Schimmel
2025-10-26 09:58:42 +01:00
parent 85f2e02893
commit e379e6694c
7 changed files with 523 additions and 91 deletions
+8 -5
View File
@@ -141,6 +141,7 @@ uses
Myc.Data.Scalar.JSON,
System.Diagnostics, // For TStopwatch
Myc.Ast.Json, // For TAstJson serialization
Myc.Ast.Types, // Needed for TTypeRules
System.IOUtils; // For TFile
{$R *.fmx}
@@ -349,8 +350,8 @@ begin
// First, deserialize the AST node from JSON.
funcAst := converter.Deserialize(pair.JsonValue as TJSONObject);
var adr := scopeDescr.FindSymbol(pair.JsonString.Value);
if adr.Kind = akUnresolved then
var sym := scopeDescr.FindSymbol(pair.JsonString.Value);
if sym.Address.Kind = akUnresolved then
begin
// Distinguish between loading a macro and loading a function.
if funcAst is TMacroDefinitionNode then
@@ -880,7 +881,7 @@ var
binder: IAstBinder;
setupAst, boundSetupAst, callAst, boundCallAst: IAstNode;
setupDescriptor, callDescriptor: IScopeDescriptor;
seriesAddress: TResolvedAddress;
seriesAddress: TResolvedSymbol; // Use TResolvedSymbol
begin
Memo1.Lines.Clear;
Memo1.Lines.Add(Format('--- Simulating O(1) SMA Crossover Strategy for %d ticks ---', [numRecs]));
@@ -953,7 +954,8 @@ begin
// 4. Get the address of 'current_series' from the new descriptor.
seriesAddress := callDescriptor.FindSymbol('current_series');
if seriesAddress.Kind = akUnresolved then
// Check seriesAddress.Address.Kind instead of seriesAddress.Kind
if seriesAddress.Address.Kind = akUnresolved then
raise Exception.Create('Could not resolve current_series address.');
// 5. Create the final scope and visitor for the simulation loop.
@@ -994,7 +996,8 @@ begin
if series.AsRecordSeries.TotalCount >= smaSlowLength then
begin
loopScope[seriesAddress] := series;
// Use seriesAddress.Address instead of seriesAddress
loopScope[seriesAddress.Address] := series;
var resultValue := visitor.Execute(boundCallAst);
if i mod 50 = 0 then
begin