Skip to content

Commit e8f3751

Browse files
AntonKuzinAnton Kuzin
andauthored
Allow NoDelegate to **really** do nothing
Co-authored-by: Anton Kuzin <kuzinanton@tut.by>
1 parent 722e640 commit e8f3751

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/kOS.Safe/Encapsulation/KOSDelegate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public List<Structure> GetMergedArgs(List<Structure> args)
6262
return merged;
6363
}
6464

65-
public Structure CallPassingArgs(params Structure[] args)
65+
public virtual Structure CallPassingArgs(params Structure[] args)
6666
{
6767
if (Cpu == null)
6868
throw new KOSCannotCallException();

src/kOS.Safe/Encapsulation/NoDelegate.cs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
31
using kOS.Safe.Execution;
4-
using kOS.Safe.Exceptions;
5-
using kOS.Safe.Compilation;
62

73
namespace kOS.Safe.Encapsulation
84
{
95
/// <summary>
10-
/// A UserDelegate that cannot actually ever executesany user code.
11-
/// Instead, when OpcodeCall() is executed for it, it will merely
12-
/// crash with an exception. The idea is to give scripts something
13-
/// they can use to "unset" a callback hook.
6+
/// A UserDelegate that cannot actually ever execute any user code.
7+
/// The idea is to give scripts something they can use to "unset" a callback hook.
148
/// </summary>
159
[kOS.Safe.Utilities.KOSNomenclature("NoDelegate")]
1610
public class NoDelegate : UserDelegate
@@ -32,15 +26,10 @@ public override KOSDelegate Clone()
3226
{
3327
return new NoDelegate(Cpu);
3428
}
35-
36-
public override void PushUnderArgs()
37-
{
38-
// force it to do nothing.
39-
}
40-
41-
public override Structure CallWithArgsPushedAlready()
29+
30+
public override Structure CallPassingArgs(params Structure[] args)
4231
{
43-
throw new KOSCannotCallException();
32+
return new KOSPassThruReturn();
4433
}
4534

4635
public override string ToString()

0 commit comments

Comments
 (0)