Scripting refinement

This commit is contained in:
Michael Schimmel
2025-09-21 12:51:06 +02:00
parent 36fe827b00
commit 8041f7355f
2 changed files with 65 additions and 11 deletions
+19 -11
View File
@@ -112,6 +112,7 @@ type
function ExecuteAst(const ANode: IAstNode; const AParentScope: IExecutionScope): TDataValue;
procedure UpdateScript;
procedure ShowVizualization(X, Y: Single);
procedure PrintScript(const Node: IAstNode);
public
{ Public declarations }
end;
@@ -631,6 +632,7 @@ begin
)
]
);
FLastAst := setupAst;
// 1. Bind and execute the setup script.
@@ -963,6 +965,21 @@ begin
UpdateScript;
end;
procedure TForm1.PrintScript(const Node: IAstNode);
begin
try
FScriptUpdate := true;
try
ScriptMemo.Lines.Text := ScriptMemo.Lines.Text + #10#13 + TAstScript.Print(Node);
finally
FScriptUpdate := false;
end;
except
on E: Exception do
ScriptMemo.Lines.Add(E.Message);
end;
end;
procedure TForm1.ScriptMemoChange(Sender: TObject);
begin
if FScriptUpdate then
@@ -1006,17 +1023,8 @@ end;
procedure TForm1.UpdateScript;
begin
try
FScriptUpdate := true;
try
ScriptMemo.Lines.Text := TAstScript.Print(FLastAst);
finally
FScriptUpdate := false;
end;
except
on E: Exception do
ScriptMemo.Lines.Add(E.Message);
end;
Memo1.Lines.Clear;
PrintScript(FLastAst);
FWorkspace.DeleteChildren;
ShowVizualization(14, 14);