From 524df9d3368e4d3343b98db65ccbde4b3fab2fcb Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 27 Aug 2017 16:04:36 +0200 Subject: [PATCH] Add ILVariableEqualityComparer --- ICSharpCode.Decompiler/IL/ILVariable.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ICSharpCode.Decompiler/IL/ILVariable.cs b/ICSharpCode.Decompiler/IL/ILVariable.cs index 2861242ca..a6951bcde 100644 --- a/ICSharpCode.Decompiler/IL/ILVariable.cs +++ b/ICSharpCode.Decompiler/IL/ILVariable.cs @@ -339,4 +339,23 @@ namespace ICSharpCode.Decompiler.IL { int IndexInAddressInstructionList { get; set; } } + + public class ILVariableEqualityComparer : IEqualityComparer + { + public static readonly ILVariableEqualityComparer Instance = new ILVariableEqualityComparer(); + + public bool Equals(ILVariable x, ILVariable y) + { + if (x == y) + return true; + if (x == null || y == null) + return false; + return x.Function == y.Function && x.Kind == y.Kind && x.Index == y.Index; + } + + public int GetHashCode(ILVariable obj) + { + return (obj.Function, obj.Kind, obj.Index).GetHashCode(); + } + } }