diff options
Diffstat (limited to 'Spv.Generator/TypeDeclarationKey.cs')
| -rw-r--r-- | Spv.Generator/TypeDeclarationKey.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Spv.Generator/TypeDeclarationKey.cs b/Spv.Generator/TypeDeclarationKey.cs new file mode 100644 index 00000000..a4aa9563 --- /dev/null +++ b/Spv.Generator/TypeDeclarationKey.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace Spv.Generator +{ + internal struct TypeDeclarationKey : IEquatable<TypeDeclarationKey> + { + private Instruction _typeDeclaration; + + public TypeDeclarationKey(Instruction typeDeclaration) + { + _typeDeclaration = typeDeclaration; + } + + public override int GetHashCode() + { + return DeterministicHashCode.Combine(_typeDeclaration.Opcode, _typeDeclaration.GetHashCodeContent()); + } + + public bool Equals(TypeDeclarationKey other) + { + return _typeDeclaration.Opcode == other._typeDeclaration.Opcode && _typeDeclaration.EqualsContent(other._typeDeclaration); + } + + public override bool Equals([NotNullWhen(true)] object obj) + { + return obj is TypeDeclarationKey && Equals((TypeDeclarationKey)obj); + } + } +} |
