/ src / Ryujinx.Graphics.Shader / Decoders / DecodedFunction.cs
DecodedFunction.cs
 1  using System;
 2  using System.Collections.Generic;
 3  
 4  namespace Ryujinx.Graphics.Shader.Decoders
 5  {
 6      class DecodedFunction
 7      {
 8          private readonly HashSet<DecodedFunction> _callers;
 9  
10          public bool IsCompilerGenerated => Type != FunctionType.User;
11          public FunctionType Type { get; set; }
12          public int Id { get; set; }
13  
14          public ulong Address { get; }
15          public Block[] Blocks { get; private set; }
16  
17          public DecodedFunction(ulong address)
18          {
19              Address = address;
20              _callers = new HashSet<DecodedFunction>();
21              Type = FunctionType.User;
22              Id = -1;
23          }
24  
25          public void SetBlocks(Block[] blocks)
26          {
27              if (Blocks != null)
28              {
29                  throw new InvalidOperationException("Blocks have already been set.");
30              }
31  
32              Blocks = blocks;
33          }
34  
35          public void AddCaller(DecodedFunction caller)
36          {
37              _callers.Add(caller);
38          }
39  
40          public void RemoveCaller(DecodedFunction caller)
41          {
42              if (_callers.Remove(caller) && _callers.Count == 0)
43              {
44                  Type = FunctionType.Unused;
45              }
46          }
47      }
48  }