summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2021-11-05 22:11:51 -0400
committerPeter LaFosse <peter@vector35.com>2021-11-05 22:12:03 -0400
commit719ec9860158123d229dd729993834c66b13d8c9 (patch)
tree6f5d37c61eca79f8d8682115cd6939e17bf68bdd /python/mediumlevelil.py
parentafe2b869b0bc8ea2b4969163899d495d46c85fef (diff)
Turn some apis back into Lists for ease of use, improve __repr__ for list and mapping containers
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 86927b0a..6c75e7cc 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -2683,29 +2683,25 @@ class MediumLevelILFunction:
_arch = self._arch
core.BNMediumLevelILSetCurrentAddress(self.handle, _arch.handle, value)
- @property
- def basic_blocks(self) -> Generator['MediumLevelILBasicBlock', None, None]:
- """list of MediumLevelILBasicBlock objects (read-only)"""
+ def _basic_block_list(self):
count = ctypes.c_ulonglong()
blocks = core.BNGetMediumLevelILBasicBlockList(self.handle, count)
assert blocks is not None, "core.BNGetMediumLevelILBasicBlockList returned None"
- view = None
- if self._source_function is not None:
- view = self._source_function.view
- try:
- for i in range(0, count.value):
- core_block = core.BNNewBasicBlockReference(blocks[i])
- assert core_block is not None
- yield MediumLevelILBasicBlock(core_block, self, view)
- finally:
- core.BNFreeBasicBlockList(blocks, count.value)
+ return (count, blocks)
+
+ def _instantiate_block(self, handle):
+ return MediumLevelILBasicBlock(handle, self, self.view)
+
+ @property
+ def basic_blocks(self) -> 'function.BasicBlockList':
+ """function.BasicBlockList of MediumLevelILBasicBlock objects (read-only)"""
+ return function.BasicBlockList(self)
@property
def instructions(self) -> Generator[MediumLevelILInstruction, None, None]:
"""A generator of mlil instructions of the current function"""
for block in self.basic_blocks:
- for i in block:
- yield i
+ yield from block
@property
def ssa_form(self) -> Optional['MediumLevelILFunction']:
@@ -3004,6 +3000,10 @@ class MediumLevelILFunction:
return self._arch
@property
+ def view(self) -> 'binaryview.BinaryView':
+ return self.source_function.view
+
+ @property
def source_function(self) -> 'function.Function':
return self._source_function