Add subroutine-execution diagnostics + Godot --scene
- CLI run: report call-script dispatch count + distinct source scripts per run. - Godot --scene <NAME>: play any scene (not just SC0000). - Godot reports the call-scripts executed as nested frames at scene end (collected thread-safely; Godot drops GD.Print from the VM background thread). Demonstrated live: SC0240 in Godot executes 29 call-scripts (RESETLAND, SETEN, ADDEN, RENDERMAP, SETOBJ, DRAWOBJ, CALCREVISE, LOOK) as nested subroutine frames. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,10 +14,13 @@ if (args.Length == 0) { Console.WriteLine("usage: run <file> | trace <out.json>"
|
||||
if (args[0] == "run")
|
||||
{
|
||||
var script = Sys4Loader.Load(args[1], table);
|
||||
var vm = new VirtualMachine(script, table, new CaptureHost(), null, provider);
|
||||
var runHost = new CaptureHost();
|
||||
var vm = new VirtualMachine(script, table, runHost, null, provider);
|
||||
vm.Run();
|
||||
Console.WriteLine($"{Path.GetFileName(args[1])}: {vm.Steps} steps, {vm.Emitted.Count} show-text (halt: {vm.HaltReason})");
|
||||
foreach (var (off, text, _) in vm.Emitted.Take(20)) Console.WriteLine($" [{off:x}] {text}");
|
||||
Console.WriteLine($"{Path.GetFileName(args[1])}: {vm.Steps} steps, {vm.Emitted.Count} show-text, {runHost.CallScriptCount} call-scripts (halt: {vm.HaltReason})");
|
||||
foreach (var (off, text, scr) in vm.Emitted.Take(30)) Console.WriteLine($" [{scr} 0x{off:x}] {text}");
|
||||
var sources = vm.Emitted.Select(e => e.Script).Distinct().ToList();
|
||||
Console.WriteLine($"source scripts ({sources.Count}): {string.Join(", ", sources)}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user