Wire Sys4ScriptProvider into CLI run/play/sweep; validate real subroutine execution

Integration: ADDILL executes ADDILLSUB + CALCREVISE and returns to its own exit.
Sweep (execution on): 284/297 exit clean, 13 STEP-LIMIT (input/state-gated ADV
scenes that now spin headless once subroutine global-writes drive their loops —
state divergence, not a call-script bug; 0 depth-cap, 0 unresolved, 0 crashes).
Removed the dead _halted field (halt propagates via FrameOutcome).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-07-07 13:18:30 -04:00
parent 4c27707d57
commit 6b3d90182e
4 changed files with 65 additions and 10 deletions

View File

@@ -24,9 +24,10 @@ public sealed class GameSession
public void SeedString(int addr, string value) => GlobalStrings[addr] = value;
/// <summary>Run one scene: seed a fresh VM from session state, execute, merge final state back.</summary>
public SceneResult RunScene(Script script, OpcodeTable table, IHost host, VmOptions? options = null)
public SceneResult RunScene(Script script, OpcodeTable table, IHost host,
VmOptions? options = null, IScriptProvider? provider = null)
{
var vm = new VirtualMachine(script, table, host, options);
var vm = new VirtualMachine(script, table, host, options, provider);
foreach (var kv in Globals) vm.Globals[kv.Key] = kv.Value;
foreach (var kv in GlobalStrings) vm.GlobalStrings[kv.Key] = kv.Value;

View File

@@ -17,7 +17,6 @@ public sealed class VirtualMachine
private readonly IScriptProvider? _provider;
private ExecFrame _cur = null!;
private int _depth;
private bool _halted;
public Dictionary<int, long> Globals { get; } = new();
public Dictionary<int, string> GlobalStrings { get; } = new();
@@ -111,11 +110,11 @@ public sealed class VirtualMachine
int pc = frame.Pc;
while (pc >= 0 && pc < frame.Script.Instructions.Count)
{
if (Steps >= _o.MaxSteps) { HaltReason ??= "STEP-LIMIT"; _halted = true; outcome = FrameOutcome.Halted; break; }
if (Steps >= _o.MaxSteps) { HaltReason ??= "STEP-LIMIT"; outcome = FrameOutcome.Halted; break; }
Steps++;
int next = Step(frame.Script.Instructions[pc], pc);
if (next == FRAME_RETURN) { outcome = FrameOutcome.Returned; break; }
if (next == HALT) { _halted = true; outcome = FrameOutcome.Halted; break; }
if (next == HALT) { outcome = FrameOutcome.Halted; break; }
pc = next;
}
_cur = prev; _depth--;