From bb15b09b7888d238ab78d249fdf0e0c29999d9df Mon Sep 17 00:00:00 2001 From: Josh Watson Date: Fri, 14 Jul 2017 13:06:36 -0400 Subject: Added __hash__ and __eq__ to Variable and SSAVariable (#725) --- python/function.py | 6 ++++++ python/mediumlevelil.py | 9 +++++++++ 2 files changed, 15 insertions(+) (limited to 'python') diff --git a/python/function.py b/python/function.py index d06d604d..b8db6875 100644 --- a/python/function.py +++ b/python/function.py @@ -203,6 +203,12 @@ class Variable(object): def __str__(self): return self.name + def __eq__(self, other): + return self.identifier == other.identifier + + def __hash__(self): + return hash(self.identifier) + class ConstantReference(object): def __init__(self, val, size, ptr, intermediate): diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index 1274bd9b..1fdfab4b 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -36,6 +36,15 @@ class SSAVariable(object): def __repr__(self): return "" % (repr(self.var), self.version) + def __eq__(self, other): + return ( + (self.var.identifier, self.version) == + (other.var.identifier, other.version) + ) + + def __hash__(self): + return hash(self.var.identifier, self.version) + class MediumLevelILLabel(object): def __init__(self, handle = None): -- cgit v1.3.1