refactor(hosting): drop CallScript/OnStub from IHost (now trace events)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,7 @@ if (args[0] == "run")
|
||||
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, {runHost.CallScriptCount} call-scripts (halt: {vm.HaltReason})");
|
||||
Console.WriteLine($"{Path.GetFileName(args[1])}: {vm.Steps} steps, {vm.Emitted.Count} show-text, {vm.CallScriptDispatches} 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)}");
|
||||
@@ -213,8 +213,6 @@ sealed class AudioTraceHost : IHost
|
||||
: $"{e.Archive} {e.Name}" + (ResourceMap.AudioPath(e) == null ? " [NO FILE]" : "")));
|
||||
}
|
||||
public void ShowText(int offset, string text) { }
|
||||
public void CallScript(long id) { }
|
||||
public void OnStub(int opcode) { }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int slot, int width, int height) { }
|
||||
public void SetTexture(long resourceId, int slot) { }
|
||||
@@ -263,8 +261,6 @@ sealed class GfxTraceHost : IHost
|
||||
Events.Add($"create-texture slot={slot} {width}x{height}");
|
||||
}
|
||||
public void ShowText(int offset, string text) { }
|
||||
public void CallScript(long id) { }
|
||||
public void OnStub(int opcode) { }
|
||||
public void WaitForInput() { }
|
||||
public void PlayBgm(long id) { }
|
||||
public void PlayVoice(long id) { }
|
||||
|
||||
@@ -7,10 +7,7 @@ public class CallScriptIntegrationTests
|
||||
{
|
||||
private sealed class NullHost : IHost
|
||||
{
|
||||
public int CallScripts;
|
||||
public void ShowText(int o, string t) { }
|
||||
public void CallScript(long id) => CallScripts++;
|
||||
public void OnStub(int op) { }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int s, int w, int h) { }
|
||||
public void SetTexture(long r, int s) { }
|
||||
|
||||
@@ -13,10 +13,7 @@ public class CallScriptTests
|
||||
|
||||
private sealed class NullHost : IHost
|
||||
{
|
||||
public List<long> Calls = new();
|
||||
public void ShowText(int o, string t) { }
|
||||
public void CallScript(long id) => Calls.Add(id);
|
||||
public void OnStub(int op) { }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int s, int w, int h) { }
|
||||
public void SetTexture(long r, int s) { }
|
||||
|
||||
@@ -28,8 +28,6 @@ public class GameSessionTests
|
||||
public int Voices;
|
||||
public List<int> Emitted = new();
|
||||
public void ShowText(int o, string t) => Emitted.Add(o);
|
||||
public void CallScript(long id) { }
|
||||
public void OnStub(int op) { }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int s, int w, int h) { }
|
||||
public void SetTexture(long r, int s) { }
|
||||
|
||||
@@ -8,11 +8,9 @@ using Age.Engine.Model;
|
||||
/// provider for synthetic call-script targets.</summary>
|
||||
internal sealed class RecordingHost : IHost
|
||||
{
|
||||
public int Waits, CallScripts;
|
||||
public int Waits;
|
||||
public readonly List<(int Offset, string Text)> Lines = new();
|
||||
public void ShowText(int offset, string text) => Lines.Add((offset, text));
|
||||
public void CallScript(long id) => CallScripts++;
|
||||
public void OnStub(int opcode) { }
|
||||
public void WaitForInput() => Waits++;
|
||||
public void CreateTexture(int slot, int w, int h) { }
|
||||
public void SetTexture(long resId, int slot) { }
|
||||
|
||||
@@ -10,8 +10,6 @@ public class TextureGeometryTests
|
||||
private sealed class FakeSizeHost : IHost
|
||||
{
|
||||
public void ShowText(int o, string t) { }
|
||||
public void CallScript(long id) { }
|
||||
public void OnStub(int op) { }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int slot, int w, int h) { }
|
||||
public void SetTexture(long resId, int slot) { }
|
||||
|
||||
@@ -12,8 +12,6 @@ public class TextureOpsTests
|
||||
public List<(int slot, int w, int h)> Draws = new();
|
||||
public int Creates;
|
||||
public void ShowText(int o, string t) { }
|
||||
public void CallScript(long id) { }
|
||||
public void OnStub(int op) { }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int slot, int w, int h) => Creates++;
|
||||
public void SetTexture(long resId, int slot) => Sets.Add((resId, slot));
|
||||
|
||||
@@ -2,11 +2,7 @@ namespace Age.Engine.Hosting;
|
||||
public sealed class CaptureHost : IHost
|
||||
{
|
||||
public List<(int Offset, string Text)> Emitted { get; } = new();
|
||||
public int CallScriptCount { get; private set; }
|
||||
public Dictionary<int, int> Stubs { get; } = new();
|
||||
public void ShowText(int offset, string text) => Emitted.Add((offset, text));
|
||||
public void CallScript(long id) => CallScriptCount++;
|
||||
public void OnStub(int opcode) { Stubs.TryGetValue(opcode, out var c); Stubs[opcode] = c + 1; }
|
||||
public void WaitForInput() { }
|
||||
public void CreateTexture(int slot, int width, int height) { }
|
||||
public void SetTexture(long resourceId, int slot) { }
|
||||
|
||||
@@ -2,8 +2,6 @@ namespace Age.Engine.Hosting;
|
||||
public interface IHost
|
||||
{
|
||||
void ShowText(int offset, string text);
|
||||
void CallScript(long id);
|
||||
void OnStub(int opcode);
|
||||
void WaitForInput();
|
||||
void CreateTexture(int slot, int width, int height);
|
||||
void SetTexture(long resourceId, int slot);
|
||||
|
||||
Reference in New Issue
Block a user