ForBlock.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections.Generic;
  2. namespace Ryujinx.HLE.HOS.Tamper.Operations
  3. {
  4. class ForBlock : IOperation
  5. {
  6. private ulong _count;
  7. private Register _register;
  8. private IEnumerable<IOperation> _operations;
  9. public ForBlock(ulong count, Register register, IEnumerable<IOperation> operations)
  10. {
  11. _count = count;
  12. _register = register;
  13. _operations = operations;
  14. }
  15. public ForBlock(ulong count, Register register, params IOperation[] operations)
  16. {
  17. _count = count;
  18. _register = register;
  19. _operations = operations;
  20. }
  21. public void Execute()
  22. {
  23. for (ulong i = 0; i < _count; i++)
  24. {
  25. // Set the register and execute the operations so that changing the
  26. // register during runtime does not break iteration.
  27. _register.Set<ulong>(i);
  28. foreach (IOperation op in _operations)
  29. {
  30. op.Execute();
  31. }
  32. }
  33. }
  34. }
  35. }