ForBlock.cs 1.1 KB

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