DecodedFunction.cs 1.2 KB

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