From c396d2cfb3682cb4c152b9dba6f866f6783e4a80 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Mon, 30 Oct 2017 17:46:49 -0400 Subject: __hash__ for three types of basic blocks --- python/basicblock.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'python/basicblock.py') diff --git a/python/basicblock.py b/python/basicblock.py index 26db925d..66d96882 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -68,6 +68,9 @@ class BasicBlock(object): """Internal method used to instantiante child instances""" return BasicBlock(view, handle) + def __hash__(self): + return hash((self.start, self.end, self.arch.name)) + @property def function(self): """Basic block function (read-only)""" -- cgit v1.3.1 From 78a9a6fd52cb36e1e2fddfb0cbaf4f56a6b8016e Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Tue, 5 Dec 2017 11:34:32 -0600 Subject: Add __eq__ and __hash__ to BasicBlockEdge --- python/basicblock.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'python/basicblock.py') diff --git a/python/basicblock.py b/python/basicblock.py index 66d96882..8e64c1c1 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -35,6 +35,14 @@ class BasicBlockEdge(object): self.target = target self.back_edge = back_edge + def __eq__(self, value): + if not isinstance(value, BasicBlockEdge): + return False + return (self.type, self.source, self.target, self.back_edge) == (value.type, value.source, value.target, value.back_edge) + + def __hash__(self): + return hash((self.type, self.source, self.target, self.back_edge)) + def __repr__(self): if self.type == BranchType.UnresolvedBranch: return "<%s>" % BranchType(self.type).name -- cgit v1.3.1