From f6a8cb229b849fe2e946c9d92516dfbce293adf0 Mon Sep 17 00:00:00 2001 From: Dustin Fraze Date: Tue, 13 Oct 2020 22:28:28 -0400 Subject: Update lowlevelil.py Add string handling to ILRegister comparison. This is especially nice with the CallingConvention API. It returns a string for things like "int_return_reg". This allows comparison without sprinkling of str(). Fix up __ne__ for ILInstruction. --- python/lowlevelil.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'python/lowlevelil.py') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 396f3925..870b787a 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -61,12 +61,14 @@ class ILRegister(object): return self._name def __eq__(self, other): - if not isinstance(other, self.__class__): + if isinstance(other, str) and other in self._arch.regs: + other = binaryninja.lowlevelil.ILRegister(self._arch, self._arch.regs[other].index) + elif not isinstance(other, self.__class__): return NotImplemented return (self._arch, self._index, self._name) == (other._arch, other._index, other._name) def __ne__(self, other): - if not isinstance(other, self.__class__): + if not isinstance(other, (self.__class__, str)): return NotImplemented return not (self == other) -- cgit v1.3.1