aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Tamper/Operations/ForBlock.cs
blob: 1e8cafa84bdf6853c93b1ac9a76b1d0fd87f2081 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections.Generic;

namespace Ryujinx.HLE.HOS.Tamper.Operations
{
    class ForBlock : IOperation
    {
        private readonly ulong _count;
        private readonly Register _register;
        private readonly 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();
                }
            }
        }
    }
}