summaryrefslogtreecommitdiff
path: root/python/highlevelil.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/highlevelil.py
parentafe2b869b0bc8ea2b4969163899d495d46c85fef (diff)
Turn some apis back into Lists for ease of use, improve __repr__ for list and mapping containers
Diffstat (limited to 'python/highlevelil.py')
-rw-r--r--python/highlevelil.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py
index 8c8b1958..44985fd4 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -2171,31 +2171,25 @@ class HighLevelILFunction:
def root(self, value:HighLevelILInstruction) -> None:
core.BNSetHighLevelILRootExpr(value.expr_index)
- @property
- def basic_blocks(self) -> Generator['HighLevelILBasicBlock', None, None]:
- """list of HighLevelILBasicBlock objects (read-only)"""
+ def _basic_block_list(self):
count = ctypes.c_ulonglong()
blocks = core.BNGetHighLevelILBasicBlockList(self.handle, count)
assert blocks is not None, "core.BNGetHighLevelILBasicBlockList returned None"
+ return (count, blocks)
- view = None
- if self._source_function is not None:
- view = self._source_function.view
+ def _instantiate_block(self, handle):
+ return HighLevelILBasicBlock(handle, self, self.view)
- try:
- for i in range(0, count.value):
- core_block = core.BNNewBasicBlockReference(blocks[i])
- assert core_block is not None, "core.BNNewBasicBlockReference is None"
- yield HighLevelILBasicBlock(core_block, self, view)
- finally:
- core.BNFreeBasicBlockList(blocks, count.value)
+ @property
+ def basic_blocks(self) -> 'function.BasicBlockList':
+ """function.BasicBlockList of HighLevelILBasicBlock objects (read-only)"""
+ return function.BasicBlockList(self)
@property
def instructions(self) -> Generator[HighLevelILInstruction, None, None]:
"""A generator of hlil 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) -> 'HighLevelILFunction':
@@ -2218,6 +2212,10 @@ class HighLevelILFunction:
return self._arch
@property
+ def view(self) -> 'binaryview.BinaryView':
+ return self.source_function.view
+
+ @property
def source_function(self) -> 'function.Function':
assert self._source_function is not None
return self._source_function