summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2019-08-16 20:28:04 -0400
committerJordan Wiens <jordan@psifertex.com>2019-08-16 20:28:04 -0400
commit2cb81a1d1d4384dcb129ca0c05f15d56cfff3408 (patch)
tree3ec945e2cdad4ba814903066e4dcab7c0adec840 /python
parent02023064fc5e112985035a9c0b3dc0957cdfda02 (diff)
add hash method for RegisterValue, MediumLevelILOperationAndSize, and MediumLevelILInstruction
Diffstat (limited to 'python')
-rw-r--r--python/function.py12
-rw-r--r--python/mediumlevelil.py7
2 files changed, 16 insertions, 3 deletions
diff --git a/python/function.py b/python/function.py
index 2f89c799..0bac5e23 100644
--- a/python/function.py
+++ b/python/function.py
@@ -112,10 +112,18 @@ class RegisterValue(object):
return "<imported address from entry %#x>" % self._value
return "<undetermined>"
+ def __hash__(self):
+ if self._type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue, RegisterValueType.ImportedAddressValue, RegisterValueType.ReturnAddressValue]:
+ return hash(self._value)
+ elif self.type == RegisterValueType.EntryValue:
+ return hash(self._reg)
+ elif self._type == RegisterValueType.StackFrameOffset:
+ return hash(self._offset)
+
def __eq__(self, other):
- if self._type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue, ImportedAddressValue, ReturnAddressValue] and isinstance(other, numbers.Integral):
+ if self._type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue, RegisterValueType.ImportedAddressValue, RegisterValueType.ReturnAddressValue] and isinstance(other, numbers.Integral):
return self._value == other
- elif self._type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue, ImportedAddressValue, ReturnAddressValue] and hasattr(other, 'type') and other.type == self._type:
+ elif self._type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue, RegisterValueType.ImportedAddressValue, RegisterValueType.ReturnAddressValue] and hasattr(other, 'type') and other.type == self._type:
return self._value == other.value
elif self._type == RegisterValueType.EntryValue and hasattr(other, "type") and other.type == self._type:
return self._reg == other.reg
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index dca7b0c8..a90fb0aa 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -99,6 +99,9 @@ class MediumLevelILOperationAndSize(object):
else:
return False
+ def __hash__(self):
+ return hash((self._size, self._operation))
+
@property
def operation(self):
""" """
@@ -356,6 +359,9 @@ class MediumLevelILInstruction(object):
def __repr__(self):
return "<il: %s>" % str(self)
+ def __hash__(self):
+ return hash((self._instr_index, self._function))
+
def __eq__(self, value):
if not isinstance(value, type(self)):
return False
@@ -1141,7 +1147,6 @@ class MediumLevelILFunction(object):
self._source_function = value
-
class MediumLevelILBasicBlock(basicblock.BasicBlock):
def __init__(self, view, handle, owner):
super(MediumLevelILBasicBlock, self).__init__(handle, view)