TranslatedFunction.cs
1 using ARMeilleure.Common; 2 using System; 3 4 namespace ARMeilleure.Translation 5 { 6 class TranslatedFunction 7 { 8 private readonly GuestFunction _func; // Ensure that this delegate will not be garbage collected. 9 10 public IntPtr FuncPointer { get; } 11 public Counter<uint> CallCounter { get; } 12 public ulong GuestSize { get; } 13 public bool HighCq { get; } 14 15 public TranslatedFunction(GuestFunction func, IntPtr funcPointer, Counter<uint> callCounter, ulong guestSize, bool highCq) 16 { 17 _func = func; 18 FuncPointer = funcPointer; 19 CallCounter = callCounter; 20 GuestSize = guestSize; 21 HighCq = highCq; 22 } 23 24 public ulong Execute(State.ExecutionContext context) 25 { 26 return _func(context.NativeContextPtr); 27 } 28 29 public ulong Execute(WrapperFunction dispatcher, State.ExecutionContext context) 30 { 31 return dispatcher(context.NativeContextPtr, (ulong)FuncPointer); 32 } 33 } 34 }