summaryrefslogtreecommitdiff
path: root/python/function.py
diff options
context:
space:
mode:
authorChinmay <chinmay1dd@gmail.com>2020-09-03 14:01:48 -0700
committerChinmay Deshpande <chinmay1dd@gmail.com>2020-09-10 08:45:04 -0700
commit78ae59ac4998ac66ff104f1ac6ef365b301feb43 (patch)
tree3a2a7b672e66903c1c843e3716d9a0ed3034922a /python/function.py
parent10315ca50d1679a7f5ca865e500356bd246c4c4e (diff)
Adds tests related to UIDF
Diffstat (limited to 'python/function.py')
-rw-r--r--python/function.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/python/function.py b/python/function.py
index bb4f817a..44c2f383 100644
--- a/python/function.py
+++ b/python/function.py
@@ -263,8 +263,11 @@ class ValueRange(object):
return "<range: %#x to %#x>" % (self.start, self.end)
return "<range: %#x to %#x, step %#x>" % (self.start, self.end, self.step)
-
-
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+ return self.start == other.start and self.end == other.end and self.step == other.step
+
@property
def start(self):
""" """
@@ -361,7 +364,7 @@ class PossibleValueSet(object):
if self._type == RegisterValueType.ConstantPointerValue:
return "<const ptr %#x>" % self.value
if self._type == RegisterValueType.StackFrameOffset:
- return "<stack frame offset %#x>" % self.offset
+ return "<stack frame offset %#x>" % self._offset
if self._type == RegisterValueType.SignedRangeValue:
return "<signed ranges: %s>" % repr(self.ranges)
if self._type == RegisterValueType.UnsignedRangeValue:
@@ -377,10 +380,18 @@ class PossibleValueSet(object):
return "<undetermined>"
def __eq__(self, other):
- if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantValue] and isinstance(other, numbers.Integral):
+ if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and isinstance(other, numbers.Integral):
return self.value == other
- if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantValue] and hasattr(other, 'type') and other.type == self.type:
+ if self.type in [RegisterValueType.ConstantValue, RegisterValueType.ConstantPointerValue] and hasattr(other, 'type') and other.type == self.type:
return self.value == other.value
+ elif self.type == RegisterValueType.StackFrameOffset and hasattr(other, 'type') and other.type == self.type:
+ return self.offset == other.offset
+ elif self.type in [RegisterValueType.SignedRangeValue, RegisterValueType.UnsignedRangeValue] and hasattr(other, 'type') and other.type == self.type:
+ return self.ranges == other.ranges
+ elif self.type in [RegisterValueType.InSetOfValues, RegisterValueType.NotInSetOfValues] and hasattr(other, 'type') and other.type == self.type:
+ return self.values == other.values
+ elif self.type == RegisterValueType.UndeterminedValue and hasattr(other, 'type'):
+ return self.type == other.type
else:
return self == other
@@ -581,7 +592,7 @@ class PossibleValueSet(object):
"""
result = PossibleValueSet()
result.type = RegisterValueType.StackFrameOffset
- result.value = value
+ result.offset = offset
return result
@classmethod