From 469f7eba4afe3086e98486b6e5f2bebbf61de525 Mon Sep 17 00:00:00 2001 From: Josh Watson Date: Tue, 12 Mar 2019 15:08:31 -0700 Subject: Add __hash__ to IL Function objects They didn't have a __hash__ method so I added one so I can use them in sets. It's really just the hash of the Function object plus a string to indicate it's MLIL or LLIL --- python/lowlevelil.py | 3 +++ python/mediumlevelil.py | 3 +++ 2 files changed, 6 insertions(+) (limited to 'python') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 430e5934..9f23f45b 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -752,6 +752,9 @@ class LowLevelILFunction(object): func_handle = self.source_function.handle self.handle = core.BNCreateLowLevelILFunction(arch.handle, func_handle) + def __hash__(self): + return hash('LLIL') + hash(self.source_function) + def __del__(self): if self.handle is not None: core.BNFreeLowLevelILFunction(self.handle) diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index 0ef09642..e165eaa3 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -633,6 +633,9 @@ class MediumLevelILFunction(object): func_handle = self.source_function.handle self.handle = core.BNCreateMediumLevelILFunction(arch.handle, func_handle) + def __hash__(self): + return hash('MLIL') + hash(self.source_function) + def __del__(self): if self.handle is not None: core.BNFreeMediumLevelILFunction(self.handle) -- cgit v1.3.1