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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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--;
|
||||
|
||||
Reference in New Issue
Block a user