diff options
| author | Ajax <commial@gmail.com> | 2016-01-25 13:22:50 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2016-01-26 17:09:18 +0100 |
| commit | 2a3cca15ca50ae20a56f12fc92f9c8f26909092b (patch) | |
| tree | ea22df71947d5fca2cb0e92b73db7d5977350aab | |
| parent | 1a49c715e3b60b758e051fd4f30c371d646acadb (diff) | |
| download | miasm-2a3cca15ca50ae20a56f12fc92f9c8f26909092b.tar.gz miasm-2a3cca15ca50ae20a56f12fc92f9c8f26909092b.zip | |
BasicBlocks.pendings can be a set (creds @serpilliere)
| -rw-r--r-- | miasm2/core/asmbloc.py | 10 | ||||
| -rw-r--r-- | test/core/asmbloc.py | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py index a929058b..7390536b 100644 --- a/miasm2/core/asmbloc.py +++ b/miasm2/core/asmbloc.py @@ -596,7 +596,7 @@ class BasicBlocks(DiGraph): super(BasicBlocks, self).__init__(*args, **kwargs) # Edges -> constraint self.edges2constraint = {} - # Expected asm_label -> list( (src, dst), constraint ) + # Expected asm_label -> set( (src, dst), constraint ) self._pendings = {} # Label2block built on the fly self._label2block = {} @@ -684,7 +684,7 @@ class BasicBlocks(DiGraph): to_add = self.BasicBlocksPending(waiter=block, constraint=constraint.c_t) self._pendings.setdefault(constraint.label, - list()).append(to_add) + set()).add(to_add) else: # Block is already in known nodes self.add_edge(block, dst, constraint.c_t) @@ -778,7 +778,7 @@ class BasicBlocks(DiGraph): # Helpers @property def pendings(self): - """Dictionnary of label -> list(BasicBlocksPending instance) indicating + """Dictionnary of label -> set(BasicBlocksPending instance) indicating which label are missing in the current instance. A label is missing if a block which is already in nodes has constraints with him (thanks to its .bto) and the corresponding block is not yet in @@ -814,8 +814,8 @@ class BasicBlocks(DiGraph): if dst is None: # Missing destination, add to pendings self._pendings.setdefault(constraint.label, - list()).append(self.BasicBlocksPending(block, - constraint.c_t)) + set()).add(self.BasicBlocksPending(block, + constraint.c_t)) continue edge = (block, dst) edges.append(edge) diff --git a/test/core/asmbloc.py b/test/core/asmbloc.py index 5fe26308..26d935b1 100644 --- a/test/core/asmbloc.py +++ b/test/core/asmbloc.py @@ -181,7 +181,7 @@ assert len(blocks) == 7 assert len(blocks.pendings) == 1 assert my_block_dst.label in blocks.pendings assert len(blocks.pendings[my_block_dst.label]) == 1 -pending = blocks.pendings[my_block_dst.label][0] +pending = list(blocks.pendings[my_block_dst.label])[0] assert isinstance(pending, blocks.BasicBlocksPending) assert pending.waiter == my_block_src assert pending.constraint == asm_constraint.c_to |