Skip to content

Commit 21a7b5e

Browse files
committed
Update type hints/docs for Python IL API changes
1 parent d6fe8b6 commit 21a7b5e

File tree

1 file changed

+84
-36
lines changed

1 file changed

+84
-36
lines changed

python/function.py

Lines changed: 84 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -976,21 +976,27 @@ def remove_auto_function_tags_of_type(self, tag_type: str):
976976
core.BNRemoveAutoFunctionTagsOfType(self.handle, tag_type.handle)
977977

978978
@property
979-
def low_level_il(self) -> 'lowlevelil.LowLevelILFunction':
979+
def low_level_il(self) -> Optional['lowlevelil.LowLevelILFunction']:
980980
"""
981-
returns LowLevelILFunction used to represent Function low level IL (read-only)
981+
returns LowLevelILFunction used to represent low level IL, or None if an error occurs while loading the IL
982+
(read-only)
983+
982984
983-
:rtype: lowlevelil.LowLevelILFunction
985+
.. note::
986+
This function causes low level IL to be generated if it has not been already. It is recommended to generate
987+
IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
984988
"""
985989
return self.llil
986990

987991
@property
988-
def llil(self) -> 'lowlevelil.LowLevelILFunction':
992+
def llil(self) -> Optional['lowlevelil.LowLevelILFunction']:
989993
"""
990-
returns LowLevelILFunction used to represent Function low level IL, or None if an error occurs while loading
991-
the IL (read-only)
994+
returns LowLevelILFunction used to represent low level IL, or None if an error occurs while loading the IL
995+
(read-only)
992996
993-
:rtype: lowlevelil.LowLevelILFunction
997+
.. note::
998+
This function causes low level IL to be generated if it has not been already. It is recommended to generate
999+
IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
9941000
"""
9951001
result = core.BNGetFunctionLowLevelIL(self.handle)
9961002
if not result:
@@ -999,19 +1005,26 @@ def llil(self) -> 'lowlevelil.LowLevelILFunction':
9991005

10001006
@property
10011007
def llil_if_available(self) -> Optional['lowlevelil.LowLevelILFunction']:
1002-
"""returns LowLevelILFunction used to represent Function low level IL, or None if not loaded (read-only)"""
1008+
"""
1009+
returns LowLevelILFunction used to represent low level IL, or None if not loaded or it cannot be generated
1010+
(read-only)
1011+
1012+
.. note:: This function can be used to check if low level IL is available without generating it.
1013+
"""
10031014
result = core.BNGetFunctionLowLevelILIfAvailable(self.handle)
10041015
if not result:
10051016
return None
10061017
return lowlevelil.LowLevelILFunction(self.arch, result, self)
10071018

10081019
@property
1009-
def lifted_il(self) -> 'lowlevelil.LowLevelILFunction':
1020+
def lifted_il(self) -> Optional['lowlevelil.LowLevelILFunction']:
10101021
"""
1011-
returns LowLevelILFunction used to represent Function lifted IL, or None if an error occurs while loading the IL
1022+
returns LowLevelILFunction used to represent lifted IL, or None if an error occurs while loading the IL
10121023
(read-only)
10131024
1014-
:rtype: lowlevelil.LowLevelILFunction
1025+
.. note::
1026+
This function causes lifted IL to be generated if it has not been already. It is recommended to generate IL
1027+
on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
10151028
"""
10161029
result = core.BNGetFunctionLiftedIL(self.handle)
10171030
if not result:
@@ -1020,28 +1033,38 @@ def lifted_il(self) -> 'lowlevelil.LowLevelILFunction':
10201033

10211034
@property
10221035
def lifted_il_if_available(self) -> Optional['lowlevelil.LowLevelILFunction']:
1023-
"""returns LowLevelILFunction used to represent lifted IL, or None if not loaded (read-only)"""
1036+
"""
1037+
returns LowLevelILFunction used to represent lifted IL, or None if not loaded or it cannot be generated
1038+
(read-only)
1039+
1040+
.. note:: This function can be used to check if lifted IL is available without generating it.
1041+
"""
10241042
result = core.BNGetFunctionLiftedILIfAvailable(self.handle)
10251043
if not result:
10261044
return None
10271045
return lowlevelil.LowLevelILFunction(self.arch, result, self)
10281046

10291047
@property
1030-
def medium_level_il(self) -> 'mediumlevelil.MediumLevelILFunction':
1048+
def medium_level_il(self) -> Optional['mediumlevelil.MediumLevelILFunction']:
10311049
"""
1032-
returns MediumLevelILFunction used to represent Function medium level IL (read-only)
1050+
returns MediumLevelILFunction used to represent medium level IL, or None if an error occurs while loading the IL
1051+
(read-only)
10331052
1034-
:rtype: mediumlevelil.MediumLevelILFunction
1053+
.. note::
1054+
This function causes medium level IL to be generated if it has not been already. It is recommended to
1055+
generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
10351056
"""
10361057
return self.mlil
10371058

10381059
@property
1039-
def mlil(self) -> 'mediumlevelil.MediumLevelILFunction':
1060+
def mlil(self) -> Optional['mediumlevelil.MediumLevelILFunction']:
10401061
"""
1041-
returns MediumLevelILFunction used to represent Function medium level IL, or None if an error occurs while
1042-
loading the IL (read-only)
1062+
returns MediumLevelILFunction used to represent medium level IL, or None if an error occurs while loading the IL
1063+
(read-only)
10431064
1044-
:rtype: mediumlevelil.MediumLevelILFunction
1065+
.. note::
1066+
This function causes medium level IL to be generated if it has not been already. It is recommended to
1067+
generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
10451068
"""
10461069
result = core.BNGetFunctionMediumLevelIL(self.handle)
10471070
if not result:
@@ -1050,58 +1073,78 @@ def mlil(self) -> 'mediumlevelil.MediumLevelILFunction':
10501073

10511074
@property
10521075
def mlil_if_available(self) -> Optional['mediumlevelil.MediumLevelILFunction']:
1053-
"""Function medium level IL, or None if not loaded (read-only)"""
1076+
"""
1077+
returns MediumLevelILFunction used to represent medium level IL, or None if not loaded or it cannot be generated
1078+
(read-only)
1079+
1080+
.. note:: This function can be used to check if medium level IL is available without generating it.
1081+
"""
10541082
result = core.BNGetFunctionMediumLevelILIfAvailable(self.handle)
10551083
if not result:
10561084
return None
10571085
return mediumlevelil.MediumLevelILFunction(self.arch, result, self)
10581086

10591087
@property
1060-
def mmlil(self) -> 'mediumlevelil.MediumLevelILFunction':
1088+
def mmlil(self) -> Optional['mediumlevelil.MediumLevelILFunction']:
10611089
"""
1062-
returns MediumLevelILFunction used to represent Function mapped medium level IL, or None if an error occurs
1063-
while loading the IL (read-only)
1090+
returns MediumLevelILFunction used to represent mapped medium level IL, or None if an error occurs while loading
1091+
the IL (read-only)
10641092
1065-
:rtype: mediumlevelil.MediumLevelILFunction
1093+
.. note::
1094+
This function causes mapped medium level IL to be generated if it has not been already. It is recommended to
1095+
generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
10661096
"""
10671097
result = core.BNGetFunctionMappedMediumLevelIL(self.handle)
10681098
if not result:
10691099
return None
10701100
return mediumlevelil.MediumLevelILFunction(self.arch, result, self)
10711101

10721102
@property
1073-
def mapped_medium_level_il(self) -> 'mediumlevelil.MediumLevelILFunction':
1103+
def mapped_medium_level_il(self) -> Optional['mediumlevelil.MediumLevelILFunction']:
10741104
"""
1075-
returns MediumLevelILFunction used to represent Function mapped medium level IL (read-only)
1105+
returns MediumLevelILFunction used to represent mapped medium level IL, or None if an error occurs while loading
1106+
the IL (read-only)
10761107
1077-
:rtype: mediumlevelil.MediumLevelILFunction
1108+
.. note::
1109+
This function causes mapped medium level IL to be generated if it has not been already. It is recommended to
1110+
generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
10781111
"""
10791112
return self.mmlil
10801113

10811114
@property
10821115
def mmlil_if_available(self) -> Optional['mediumlevelil.MediumLevelILFunction']:
1083-
"""Function mapped medium level IL, or None if not loaded (read-only)"""
1116+
"""
1117+
returns MediumLevelILFunction used to represent mapped medium level IL, or None if not loaded or it cannot be
1118+
generated (read-only)
1119+
1120+
.. note:: This function can be used to check if mapped medium level IL is available without generating it.
1121+
"""
10841122
result = core.BNGetFunctionMappedMediumLevelILIfAvailable(self.handle)
10851123
if not result:
10861124
return None
10871125
return mediumlevelil.MediumLevelILFunction(self.arch, result, self)
10881126

10891127
@property
1090-
def high_level_il(self) -> 'highlevelil.HighLevelILFunction':
1128+
def high_level_il(self) -> Optional['highlevelil.HighLevelILFunction']:
10911129
"""
1092-
returns HighLevelILFunction used to represent Function high level IL (read-only)
1130+
returns HighLevelILFunction used to represent high level IL, or None if an error occurs while loading the IL
1131+
(read-only)
10931132
1094-
:rtype: highlevelil.HighLevelILFunction
1133+
.. note::
1134+
This function causes high level IL to be generated if it has not been already. It is recommended to
1135+
generate IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
10951136
"""
10961137
return self.hlil
10971138

10981139
@property
1099-
def hlil(self) -> 'highlevelil.HighLevelILFunction':
1140+
def hlil(self) -> Optional['highlevelil.HighLevelILFunction']:
11001141
"""
1101-
returns HighLevelILFunction used to represent Function high level IL, or None if an error occurs while loading
1102-
the IL (read-only)
1142+
returns HighLevelILFunction used to represent high level IL, or None if an error occurs while loading the IL
1143+
(read-only)
11031144
1104-
:rtype: highlevelil.HighLevelILFunction
1145+
.. note::
1146+
This function causes high level IL to be generated if it has not been already. It is recommended to generate
1147+
IL on-demand to avoid excessive memory usage instead of generating IL for all functions at once.
11051148
"""
11061149
result = core.BNGetFunctionHighLevelIL(self.handle)
11071150
if not result:
@@ -1110,7 +1153,12 @@ def hlil(self) -> 'highlevelil.HighLevelILFunction':
11101153

11111154
@property
11121155
def hlil_if_available(self) -> Optional['highlevelil.HighLevelILFunction']:
1113-
"""Function high level IL, or None if not loaded (read-only)"""
1156+
"""
1157+
returns HighLevelILFunction used to represent high level IL, or None if not loaded or it cannot be generated
1158+
(read-only)
1159+
1160+
.. note:: This function can be used to check if high level IL is available without generating it.
1161+
"""
11141162
result = core.BNGetFunctionHighLevelILIfAvailable(self.handle)
11151163
if not result:
11161164
return None

0 commit comments

Comments
 (0)