aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/IntermediateRepresentation/Operation.cs
blob: 620bf3f6e21b07843e45fc10c823b7dc98b88dfa (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
namespace ARMeilleure.IntermediateRepresentation
{
    class Operation : Node
    {
        public Instruction Instruction { get; private set; }

        public Operation(
            Instruction instruction,
            Operand destination,
            params Operand[] sources) : base(destination, sources.Length)
        {
            Instruction = instruction;

            for (int index = 0; index < sources.Length; index++)
            {
                SetSource(index, sources[index]);
            }
        }

        public Operation(
            Instruction instruction,
            Operand[] destinations,
            Operand[] sources) : base(destinations, sources.Length)
        {
            Instruction = instruction;

            for (int index = 0; index < sources.Length; index++)
            {
                SetSource(index, sources[index]);
            }
        }

        public void TurnIntoCopy(Operand source)
        {
            Instruction = Instruction.Copy;

            SetSources(new Operand[] { source });
        }
    }
}