From ef6cddbcef4184d1d41f80ac16c56c173e5d38f6 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Thu, 27 Jun 2019 17:54:48 -0400 Subject: add comparators for MLIL and LLIL instructions --- python/lowlevelil.py | 20 ++++++++++++++++++++ python/mediumlevelil.py | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'python') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index dc679e9f..8249afe8 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -814,6 +814,26 @@ class LowLevelILInstruction(object): return False return self._function == value.function and self.expr_index == value.expr_index + def __lt__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index < value.expr_index + + def __le__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index <= value.expr_index + + def __gt__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index > value.expr_index + + def __ge__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index >= value.expr_index + @property def tokens(self): """LLIL tokens (read-only)""" diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index f73609cc..624f77a2 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -361,6 +361,26 @@ class MediumLevelILInstruction(object): return False return self._function == value.function and self._expr_index == value.expr_index + def __lt__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index < value.expr_index + + def __le__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index <= value.expr_index + + def __gt__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index > value.expr_index + + def __ge__(self, value): + if not isinstance(value, type(self)): + return False + return self._function == value.function and self.expr_index >= value.expr_index + @property def tokens(self): """MLIL tokens (read-only)""" -- cgit v1.3.1