Skip to content

Commit

Permalink
virtual instance method usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Sep 30, 2022
1 parent 76aa30c commit 959cb29
Show file tree
Hide file tree
Showing 33 changed files with 10 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Common
/// A generic linked implementation of IDebuggable that can be used by any link core
/// </summary>
/// <seealso cref="IDebuggable" />
public class LinkedDebuggable : IDebuggable
public partial class LinkedDebuggable : IDebuggable
{
private readonly IEmulator[] _linkedCores;
private readonly int _numCores;
Expand Down Expand Up @@ -46,8 +46,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; }

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;

using BizHawk.Common;

namespace BizHawk.Emulation.Common
{
/// <summary>
Expand All @@ -12,6 +14,12 @@ namespace BizHawk.Emulation.Common
/// </summary>
public interface IDebuggable : IEmulatorService
{
public static class MethodDefaultImpls
{
public static bool CanStep(IDebuggable self, StepType type)
=> false;
}

/// <summary>
/// Returns a list of CPU registers and their current state
/// </summary>
Expand All @@ -31,6 +39,7 @@ public interface IDebuggable : IEmulatorService
/// Informs the calling code whether or not the given step type is implemented,
/// if false, a NotImplementedException will be thrown if Step is called with the given value
/// </summary>
[VirtualMethod]
bool CanStep(StepType type);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
[FeatureNotImplemented]
public void SetCpuRegister(string register, int value) => throw new NotImplementedException();

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public partial class TI83 : IDebuggable
[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

public bool CanStep(StepType type) => false;

public long TotalExecutedCycles => _cpu.TotalExecutedCycles;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public partial class AmstradCPC : IDebuggable

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public partial class ZXSpectrum : IDebuggable

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public partial class Atari2600 : IDebuggable

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public partial class A7800Hawk : IDebuggable

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public void SetCpuRegister(string register, int value)
}
}

public bool CanStep(StepType type)
=> false;

[FeatureNotImplemented]
public void Step(StepType type)
=> throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public partial class ColecoVision : IDebuggable

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; }

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public IDictionary<string, RegisterValue> GetCpuFlagsAndRegisters()
[FeatureNotImplemented]
public IMemoryCallbackSystem MemoryCallbacks => throw new NotImplementedException();

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public long TotalExecutedCycles => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; }

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public void SetCpuRegister(string register, int value)
}
}

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public void SetCpuRegister(string register, int value)
_core.SetReg(ncpu == 9 ? 0 : 1, index, value);
}

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public partial class NES : IDebuggable

public void SetCpuRegister(string register, int value) => cpu.SetCpuRegister(register, value);

public bool CanStep(StepType type) => false;

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

[FeatureNotImplemented]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public void SetCpuRegister(string register, int value)
throw new NotImplementedException();
}

public bool CanStep(StepType type) { return false; }

[FeatureNotImplemented]
public void Step(StepType type) { throw new NotImplementedException(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type)
{
return false;
}

[FeatureNotImplemented]
public void Step(StepType type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public void SetCpuRegister(string register, int value)
value);
}

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks => _GBCore.MemoryCallbacks;

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

public bool CanStep(StepType type)
{
return false;
}

[FeatureNotImplemented]
public void Step(StepType type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public partial class SMS : IDebuggable

public void SetCpuRegister(string register, int value) => Cpu.SetCpuRegister(register, value);

public bool CanStep(StepType type) => false;

public IMemoryCallbackSystem MemoryCallbacks { get; } = new MemoryCallbackSystem(new[] { "System Bus" });

[FeatureNotImplemented]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public void SetCpuRegister(string register, int value)

public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks;

public bool CanStep(StepType type) { return false; }

[FeatureNotImplemented]
public void Step(StepType type) { throw new NotImplementedException(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public void SetCpuRegister(string register, int value)
private readonly MemoryCallbackSystem _memoryCallbacks = new MemoryCallbackSystem(new[] { "System Bus" }); // Note: there is no system bus memory domain, but there's also no hard rule that the memory callback system domains have to correspond to actual domains in MemoryDomains, that could be good, or bad, but something to be careful about
public IMemoryCallbackSystem MemoryCallbacks => _memoryCallbacks;

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down
2 changes: 0 additions & 2 deletions src/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ public void SetCpuRegister(string register, int value)
throw new NotImplementedException();
}

public bool CanStep(StepType type) => false;

[FeatureNotImplemented]
public void Step(StepType type) => throw new NotImplementedException();

Expand Down

0 comments on commit 959cb29

Please sign in to comment.