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