New visualizer
This commit is contained in:
+17
-14
@@ -36,7 +36,7 @@ uses
|
||||
FMX.Layouts,
|
||||
FMX.Objects,
|
||||
Myc.Ast.Debugger,
|
||||
Myc.Fmx.AstEditor,
|
||||
Myc.Fmx.AstVisualizer,
|
||||
Myc.Fmx.AstEditor.Node,
|
||||
Myc.Fmx.AstEditor.Workspace,
|
||||
FMX.DialogService,
|
||||
@@ -70,7 +70,6 @@ type
|
||||
DoTrigger2Button: TButton;
|
||||
Panel2: TPanel;
|
||||
ClearButton: TButton;
|
||||
FlowOnlyBox: TCheckBox;
|
||||
SeriesTestButton: TButton;
|
||||
OHLCButton: TButton;
|
||||
DebugBox: TCheckBox;
|
||||
@@ -112,6 +111,7 @@ type
|
||||
procedure LoadUserLibButtonClick(Sender: TObject);
|
||||
procedure RTLListViewChange(Sender: TObject);
|
||||
private
|
||||
FCurrUnboundAst: IAstNode;
|
||||
FCurrAst: IAstNode;
|
||||
FCurrDesc: IScopeDescriptor;
|
||||
FGScope: IExecutionScope;
|
||||
@@ -216,6 +216,7 @@ var
|
||||
visitor: IEvaluatorVisitor;
|
||||
begin
|
||||
// The new, streamlined pipeline: The binder handles macro expansion internally.
|
||||
FCurrUnboundAst := ANode;
|
||||
|
||||
// Step 1: Create a binder, passing the evaluator factory for compile-time evaluations.
|
||||
binder := TAstBinder.Create(AParentScope, CreateEvaluator);
|
||||
@@ -1284,13 +1285,13 @@ begin
|
||||
|
||||
Memo1.Lines.Clear;
|
||||
try
|
||||
// Execute the entire script block when it changes
|
||||
var result := ExecuteAst(TAstScript.Parse(ScriptMemo.Lines.Text), FGScope);
|
||||
Memo1.Lines.Add(Format('Script executed. Final result: %s', [result.ToString]));
|
||||
|
||||
// After execution, the FCurrAst is set by ExecuteAst, so we can visualize it
|
||||
FWorkspace.DeleteChildren;
|
||||
ShowVizualization(14, 14);
|
||||
try
|
||||
// Execute the entire script block when it changes
|
||||
var result := ExecuteAst(TAstScript.Parse(ScriptMemo.Lines.Text), FGScope);
|
||||
Memo1.Lines.Add(Format('Script executed. Final result: %s', [result.ToString]));
|
||||
finally
|
||||
ShowVizualization(14, 14);
|
||||
end;
|
||||
except
|
||||
on E: Exception do
|
||||
Memo1.Lines.Add(E.Message);
|
||||
@@ -1307,13 +1308,15 @@ end;
|
||||
|
||||
procedure TForm1.ShowVizualization(X, Y: Single);
|
||||
begin
|
||||
FWorkspace.DeleteChildren;
|
||||
|
||||
if FCurrAst <> nil then
|
||||
begin
|
||||
var visu := TVisualizationMode.vmDetailed;
|
||||
if FlowOnlyBox.IsChecked then
|
||||
visu := TVisualizationMode.vmControlFlow;
|
||||
|
||||
FWorkspace.BuildTree(FCurrAst, FCurrDesc, TPointF.Create(X, Y), visu);
|
||||
FWorkspace.Build(FCurrAst, TPointF.Create(X, Y));
|
||||
end
|
||||
else if FCurrUnboundAst <> nil then
|
||||
begin
|
||||
FWorkspace.Build(FCurrUnboundAst, TPointF.Create(X, Y));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user