TypeDeclarationKey.cs 903 B

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