summaryrefslogtreecommitdiff
path: root/python/function.py
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2021-11-23 08:53:36 -0500
committerPeter LaFosse <peter@vector35.com>2021-11-29 09:25:27 -0500
commit9700dad7db37f5898afbbea82ba2fbf465217bf6 (patch)
treeb17cf8e01b30282c7b7f1b91a62cfa417255d783 /python/function.py
parent7145eaf90190f114449610948d6fa0ddf2191771 (diff)
Fix type hints for BasicBlockList
Diffstat (limited to 'python/function.py')
-rw-r--r--python/function.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/python/function.py b/python/function.py
index 41b5ac82..152450e8 100644
--- a/python/function.py
+++ b/python/function.py
@@ -170,7 +170,7 @@ class VariableReferenceSource:
class BasicBlockList:
- def __init__(self, function:'Function'):
+ def __init__(self, function:Union['Function', 'lowlevelil.LowLevelILFunction', 'mediumlevelil.MediumLevelILFunction', 'highlevelil.HighLevelILFunction']):
self._count, self._blocks = function._basic_block_list()
self._function = function
self._n = 0
@@ -218,6 +218,43 @@ class BasicBlockList:
raise ValueError("BasicBlockList.__getitem__ supports argument of type integer or slice only")
+
+class LowLevelILBasicBlockList(BasicBlockList):
+
+ def __repr__(self):
+ return f"<LowLevelILBasicBlockList {len(self)} BasicBlocks: {list(self)}>"
+
+ def __getitem__(self, i:Union[int, slice]) -> Union['lowlevelil.LowLevelILBasicBlock', List['lowlevelil.LowLevelILBasicBlock']]:
+ return BasicBlockList.__getitem__(self, i) # type: ignore
+
+ def __next__(self) -> 'lowlevelil.LowLevelILBasicBlock':
+ return BasicBlockList.__next__(self) # type: ignore
+
+
+class MediumLevelILBasicBlockList(BasicBlockList):
+
+ def __repr__(self):
+ return f"<MediumLevelILBasicBlockList {len(self)} BasicBlocks: {list(self)}>"
+
+ def __getitem__(self, i:Union[int, slice]) -> Union['mediumlevelil.MediumLevelILBasicBlock', List['mediumlevelil.MediumLevelILBasicBlock']]:
+ return BasicBlockList.__getitem__(self, i) # type: ignore
+
+ def __next__(self) -> 'mediumlevelil.MediumLevelILBasicBlock':
+ return BasicBlockList.__next__(self) # type: ignore
+
+
+class HighLevelILBasicBlockList(BasicBlockList):
+
+ def __repr__(self):
+ return f"<HighLevelILBasicBlockList {len(self)} BasicBlocks: {list(self)}>"
+
+ def __getitem__(self, i:Union[int, slice]) -> Union['highlevelil.HighLevelILBasicBlock', List['highlevelil.HighLevelILBasicBlock']]:
+ return BasicBlockList.__getitem__(self, i) # type: ignore
+
+ def __next__(self) -> 'highlevelil.HighLevelILBasicBlock':
+ return BasicBlockList.__next__(self) # type: ignore
+
+
class TagList:
def __init__(self, function:'Function'):
self._count = ctypes.c_ulonglong()