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 runHost = new CaptureHost();
|
||||||
var vm = new VirtualMachine(script, table, runHost, null, provider);
|
var vm = new VirtualMachine(script, table, runHost, null, provider);
|
||||||
vm.Run();
|
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}");
|
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();
|
var sources = vm.Emitted.Select(e => e.Script).Distinct().ToList();
|
||||||
Console.WriteLine($"source scripts ({sources.Count}): {string.Join(", ", sources)}");
|
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]" : "")));
|
: $"{e.Archive} {e.Name}" + (ResourceMap.AudioPath(e) == null ? " [NO FILE]" : "")));
|
||||||
}
|
}
|
||||||
public void ShowText(int offset, string text) { }
|
public void ShowText(int offset, string text) { }
|
||||||
public void CallScript(long id) { }
|
|
||||||
public void OnStub(int opcode) { }
|
|
||||||
public void WaitForInput() { }
|
public void WaitForInput() { }
|
||||||
public void CreateTexture(int slot, int width, int height) { }
|
public void CreateTexture(int slot, int width, int height) { }
|
||||||
public void SetTexture(long resourceId, int slot) { }
|
public void SetTexture(long resourceId, int slot) { }
|
||||||
@@ -263,8 +261,6 @@ sealed class GfxTraceHost : IHost
|
|||||||
Events.Add($"create-texture slot={slot} {width}x{height}");
|
Events.Add($"create-texture slot={slot} {width}x{height}");
|
||||||
}
|
}
|
||||||
public void ShowText(int offset, string text) { }
|
public void ShowText(int offset, string text) { }
|
||||||
public void CallScript(long id) { }
|
|
||||||
public void OnStub(int opcode) { }
|
|
||||||
public void WaitForInput() { }
|
public void WaitForInput() { }
|
||||||
public void PlayBgm(long id) { }
|
public void PlayBgm(long id) { }
|
||||||
public void PlayVoice(long id) { }
|
public void PlayVoice(long id) { }
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ public class CallScriptIntegrationTests
|
|||||||
{
|
{
|
||||||
private sealed class NullHost : IHost
|
private sealed class NullHost : IHost
|
||||||
{
|
{
|
||||||
public int CallScripts;
|
|
||||||
public void ShowText(int o, string t) { }
|
public void ShowText(int o, string t) { }
|
||||||
public void CallScript(long id) => CallScripts++;
|
|
||||||
public void OnStub(int op) { }
|
|
||||||
public void WaitForInput() { }
|
public void WaitForInput() { }
|
||||||
public void CreateTexture(int s, int w, int h) { }
|
public void CreateTexture(int s, int w, int h) { }
|
||||||
public void SetTexture(long r, int s) { }
|
public void SetTexture(long r, int s) { }
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ public class CallScriptTests
|
|||||||
|
|
||||||
private sealed class NullHost : IHost
|
private sealed class NullHost : IHost
|
||||||
{
|
{
|
||||||
public List<long> Calls = new();
|
|
||||||
public void ShowText(int o, string t) { }
|
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 WaitForInput() { }
|
||||||
public void CreateTexture(int s, int w, int h) { }
|
public void CreateTexture(int s, int w, int h) { }
|
||||||
public void SetTexture(long r, int s) { }
|
public void SetTexture(long r, int s) { }
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ public class GameSessionTests
|
|||||||
public int Voices;
|
public int Voices;
|
||||||
public List<int> Emitted = new();
|
public List<int> Emitted = new();
|
||||||
public void ShowText(int o, string t) => Emitted.Add(o);
|
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 WaitForInput() { }
|
||||||
public void CreateTexture(int s, int w, int h) { }
|
public void CreateTexture(int s, int w, int h) { }
|
||||||
public void SetTexture(long r, int s) { }
|
public void SetTexture(long r, int s) { }
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ using Age.Engine.Model;
|
|||||||
/// provider for synthetic call-script targets.</summary>
|
/// provider for synthetic call-script targets.</summary>
|
||||||
internal sealed class RecordingHost : IHost
|
internal sealed class RecordingHost : IHost
|
||||||
{
|
{
|
||||||
public int Waits, CallScripts;
|
public int Waits;
|
||||||
public readonly List<(int Offset, string Text)> Lines = new();
|
public readonly List<(int Offset, string Text)> Lines = new();
|
||||||
public void ShowText(int offset, string text) => Lines.Add((offset, text));
|
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 WaitForInput() => Waits++;
|
||||||
public void CreateTexture(int slot, int w, int h) { }
|
public void CreateTexture(int slot, int w, int h) { }
|
||||||
public void SetTexture(long resId, int slot) { }
|
public void SetTexture(long resId, int slot) { }
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ public class TextureGeometryTests
|
|||||||
private sealed class FakeSizeHost : IHost
|
private sealed class FakeSizeHost : IHost
|
||||||
{
|
{
|
||||||
public void ShowText(int o, string t) { }
|
public void ShowText(int o, string t) { }
|
||||||
public void CallScript(long id) { }
|
|
||||||
public void OnStub(int op) { }
|
|
||||||
public void WaitForInput() { }
|
public void WaitForInput() { }
|
||||||
public void CreateTexture(int slot, int w, int h) { }
|
public void CreateTexture(int slot, int w, int h) { }
|
||||||
public void SetTexture(long resId, int slot) { }
|
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 List<(int slot, int w, int h)> Draws = new();
|
||||||
public int Creates;
|
public int Creates;
|
||||||
public void ShowText(int o, string t) { }
|
public void ShowText(int o, string t) { }
|
||||||
public void CallScript(long id) { }
|
|
||||||
public void OnStub(int op) { }
|
|
||||||
public void WaitForInput() { }
|
public void WaitForInput() { }
|
||||||
public void CreateTexture(int slot, int w, int h) => Creates++;
|
public void CreateTexture(int slot, int w, int h) => Creates++;
|
||||||
public void SetTexture(long resId, int slot) => Sets.Add((resId, slot));
|
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 sealed class CaptureHost : IHost
|
||||||
{
|
{
|
||||||
public List<(int Offset, string Text)> Emitted { get; } = new();
|
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 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 WaitForInput() { }
|
||||||
public void CreateTexture(int slot, int width, int height) { }
|
public void CreateTexture(int slot, int width, int height) { }
|
||||||
public void SetTexture(long resourceId, int slot) { }
|
public void SetTexture(long resourceId, int slot) { }
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ namespace Age.Engine.Hosting;
|
|||||||
public interface IHost
|
public interface IHost
|
||||||
{
|
{
|
||||||
void ShowText(int offset, string text);
|
void ShowText(int offset, string text);
|
||||||
void CallScript(long id);
|
|
||||||
void OnStub(int opcode);
|
|
||||||
void WaitForInput();
|
void WaitForInput();
|
||||||
void CreateTexture(int slot, int width, int height);
|
void CreateTexture(int slot, int width, int height);
|
||||||
void SetTexture(long resourceId, int slot);
|
void SetTexture(long resourceId, int slot);
|
||||||
|
|||||||
Reference in New Issue
Block a user