TranslatedFunction.cs 1.0 KB

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