mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-14 12:56:41 +00:00
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Ryujinx.HLE.HOS.Tamper.Operations
|
||
|
{
|
||
|
class ForBlock : IOperation
|
||
|
{
|
||
|
private ulong _count;
|
||
|
private Register _register;
|
||
|
private IEnumerable<IOperation> _operations;
|
||
|
|
||
|
public ForBlock(ulong count, Register register, IEnumerable<IOperation> operations)
|
||
|
{
|
||
|
_count = count;
|
||
|
_register = register;
|
||
|
_operations = operations;
|
||
|
}
|
||
|
|
||
|
public ForBlock(ulong count, Register register, params IOperation[] operations)
|
||
|
{
|
||
|
_count = count;
|
||
|
_register = register;
|
||
|
_operations = operations;
|
||
|
}
|
||
|
|
||
|
public void Execute()
|
||
|
{
|
||
|
for (ulong i = 0; i < _count; i++)
|
||
|
{
|
||
|
// Set the register and execute the operations so that changing the
|
||
|
// register during runtime does not break iteration.
|
||
|
|
||
|
_register.Set<ulong>(i);
|
||
|
|
||
|
foreach (IOperation op in _operations)
|
||
|
{
|
||
|
op.Execute();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|