|
| 1 | +using System; |
| 2 | + |
1 | 3 | namespace BinaryNinja |
2 | 4 | { |
3 | | - public sealed class HighLevelILFlowGraphEdge : AbstractFlowGraphEdge<HighLevelILFlowGraphNode> |
| 5 | + public sealed class HighLevelILFlowGraphEdge |
| 6 | + : AbstractFlowGraphEdge<HighLevelILFlowGraphNode>, |
| 7 | + IEquatable<HighLevelILFlowGraphEdge>, |
| 8 | + IComparable<HighLevelILFlowGraphEdge> |
4 | 9 | { |
5 | 10 | internal HighLevelILFlowGraphEdge( |
6 | 11 | BNFlowGraphEdge native, |
@@ -37,5 +42,87 @@ bool outgoing |
37 | 42 | ); |
38 | 43 | } |
39 | 44 | } |
| 45 | + |
| 46 | + public override bool Equals(object? other) |
| 47 | + { |
| 48 | + return this.Equals(other as HighLevelILFlowGraphEdge); |
| 49 | + } |
| 50 | + |
| 51 | + public bool Equals(HighLevelILFlowGraphEdge? other) |
| 52 | + { |
| 53 | + if (other is null) |
| 54 | + { |
| 55 | + return false; |
| 56 | + } |
| 57 | + |
| 58 | + if (ReferenceEquals(this , other)) |
| 59 | + { |
| 60 | + return true; |
| 61 | + } |
| 62 | + |
| 63 | + if (this.Type != other.Type) |
| 64 | + { |
| 65 | + return false; |
| 66 | + } |
| 67 | + |
| 68 | + if (this.Source != other.Source) |
| 69 | + { |
| 70 | + return false; |
| 71 | + } |
| 72 | + |
| 73 | + if (this.Target != other.Target) |
| 74 | + { |
| 75 | + return false; |
| 76 | + } |
| 77 | + |
| 78 | + return true; |
| 79 | + } |
| 80 | + |
| 81 | + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals")] |
| 82 | + public override int GetHashCode() |
| 83 | + { |
| 84 | + return HashCode.Combine<uint,int,int>( |
| 85 | + (uint)this.Type, |
| 86 | + this.Source.GetHashCode(), |
| 87 | + this.Target.GetHashCode() |
| 88 | + ); |
| 89 | + } |
| 90 | + |
| 91 | + public static bool operator ==(HighLevelILFlowGraphEdge? left, HighLevelILFlowGraphEdge? right) |
| 92 | + { |
| 93 | + if (left is null) |
| 94 | + { |
| 95 | + return right is null; |
| 96 | + } |
| 97 | + |
| 98 | + return left.Equals(right); |
| 99 | + } |
| 100 | + |
| 101 | + public static bool operator !=(HighLevelILFlowGraphEdge? left, HighLevelILFlowGraphEdge? right) |
| 102 | + { |
| 103 | + return !(left == right); |
| 104 | + } |
| 105 | + |
| 106 | + public int CompareTo(HighLevelILFlowGraphEdge? other) |
| 107 | + { |
| 108 | + if (other is null) |
| 109 | + { |
| 110 | + return 1; |
| 111 | + } |
| 112 | + |
| 113 | + int result = this.Type.CompareTo(other.Type); |
| 114 | + |
| 115 | + if (0 == result) |
| 116 | + { |
| 117 | + result = this.Source.CompareTo(other.Source); |
| 118 | + } |
| 119 | + |
| 120 | + if (0 == result) |
| 121 | + { |
| 122 | + result = this.Target.CompareTo(other.Target); |
| 123 | + } |
| 124 | + |
| 125 | + return result; |
| 126 | + } |
40 | 127 | } |
41 | 128 | } |
0 commit comments