From 630824de49fcde2f61701ac2019834bda079a341 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Wed, 22 Jul 2020 16:49:08 -0400 Subject: Expose C++ HLIL instruction comparison operators to Python --- python/highlevelil.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'python/highlevelil.py') diff --git a/python/highlevelil.py b/python/highlevelil.py index 6b197fac..e815df48 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -344,12 +344,32 @@ class HighLevelILInstruction(object): def __eq__(self, other): if not isinstance(other, self.__class__): return NotImplemented - return (self._function, self._expr_index) == (other._function, other._expr_index) + return core.BNHighLevelILExprEqual(self._function.handle, self._expr_index, other._function.handle, other._expr_index) def __ne__(self, other): if not isinstance(other, self.__class__): return NotImplemented - return not (self == other) + return not core.BNHighLevelILExprEqual(self._function.handle, self._expr_index, other._function.handle, other._expr_index) + + def __lt__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return core.BNHighLevelILExprLessThan(self._function.handle, self._expr_index, other._function.handle, other._expr_index) + + def __le__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return not core.BNHighLevelILExprLessThan(other._function.handle, other._expr_index, self._function.handle, self._expr_index) + + def __gt__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return core.BNHighLevelILExprLessThan(other._function.handle, other._expr_index, self._function.handle, self._expr_index) + + def __ge__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return not core.BNHighLevelILExprLessThan(self._function.handle, self._expr_index, other._function, other._expr_index) def __hash__(self): return hash((self._function, self._expr_index)) -- cgit v1.3.1