diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2019-08-16 20:28:04 -0400 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2019-08-16 20:28:04 -0400 |
| commit | 2cb81a1d1d4384dcb129ca0c05f15d56cfff3408 (patch) | |
| tree | 3ec945e2cdad4ba814903066e4dcab7c0adec840 /python/function.py | |
| parent | 02023064fc5e112985035a9c0b3dc0957cdfda02 (diff) | |
add hash method for RegisterValue, MediumLevelILOperationAndSize, and MediumLevelILInstruction
Diffstat (limited to 'python/function.py')
| -rw-r--r-- | python/function.py | 12 |
1 files changed, 10 insertions, 2 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 |
