ConstantKey.cs 860 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Diagnostics.CodeAnalysis;
  3. namespace Spv.Generator
  4. {
  5. internal struct ConstantKey : IEquatable<ConstantKey>
  6. {
  7. private Instruction _constant;
  8. public ConstantKey(Instruction constant)
  9. {
  10. _constant = constant;
  11. }
  12. public override int GetHashCode()
  13. {
  14. return HashCode.Combine(_constant.Opcode, _constant.GetHashCodeContent(), _constant.GetHashCodeResultType());
  15. }
  16. public bool Equals(ConstantKey other)
  17. {
  18. return _constant.Opcode == other._constant.Opcode && _constant.EqualsContent(other._constant) && _constant.EqualsResultType(other._constant);
  19. }
  20. public override bool Equals([NotNullWhen(true)] object obj)
  21. {
  22. return obj is ConstantKey && Equals((ConstantKey)obj);
  23. }
  24. }
  25. }