Skip to content

Commit 6baf0bc

Browse files
committed
Python: Add ILSourceLocation to these functions too
1 parent 1675348 commit 6baf0bc

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

python/mediumlevelil.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5193,28 +5193,41 @@ def float_compare_unordered(
51935193
"""
51945194
return self.expr(MediumLevelILOperation.MLIL_FCMP_UO, a, b, size=size, source_location=loc)
51955195

5196-
def goto(self, label: MediumLevelILLabel) -> ExpressionIndex:
5196+
def goto(
5197+
self, label: MediumLevelILLabel, loc: Optional['ILSourceLocation'] = None
5198+
) -> ExpressionIndex:
51975199
"""
51985200
``goto`` returns a goto expression which jumps to the provided MediumLevelILLabel.
51995201
52005202
:param MediumLevelILLabel label: Label to jump to
5203+
:param ILSourceLocation loc: location of returned expression
52015204
:return: the ExpressionIndex that jumps to the provided label
52025205
:rtype: ExpressionIndex
52035206
"""
5204-
return ExpressionIndex(core.BNMediumLevelILGoto(self.handle, label.handle))
5207+
if loc is not None:
5208+
return ExpressionIndex(core.BNMediumLevelILGotoWithLocation(self.handle, label.handle, loc.address, loc.source_operand))
5209+
else:
5210+
return ExpressionIndex(core.BNMediumLevelILGoto(self.handle, label.handle))
52055211

5206-
def if_expr(self, operand: ExpressionIndex, t: MediumLevelILLabel, f: MediumLevelILLabel) -> ExpressionIndex:
5212+
def if_expr(
5213+
self, operand: ExpressionIndex, t: MediumLevelILLabel, f: MediumLevelILLabel, label: MediumLevelILLabel,
5214+
loc: Optional['ILSourceLocation'] = None
5215+
) -> ExpressionIndex:
52075216
"""
52085217
``if_expr`` returns the ``if`` expression which depending on condition ``operand`` jumps to the MediumLevelILLabel
52095218
``t`` when the condition expression ``operand`` is non-zero and ``f`` when it's zero.
52105219
52115220
:param ExpressionIndex operand: comparison expression to evaluate.
52125221
:param MediumLevelILLabel t: Label for the true branch
52135222
:param MediumLevelILLabel f: Label for the false branch
5223+
:param ILSourceLocation loc: location of returned expression
52145224
:return: the ExpressionIndex for the if expression
52155225
:rtype: ExpressionIndex
52165226
"""
5217-
return ExpressionIndex(core.BNMediumLevelILIf(self.handle, operand, t.handle, f.handle))
5227+
if loc is not None:
5228+
return ExpressionIndex(core.BNMediumLevelILIfWithLocation(self.handle, operand, t.handle, f.handle, loc.address, loc.source_operand))
5229+
else:
5230+
return ExpressionIndex(core.BNMediumLevelILIf(self.handle, operand, t.handle, f.handle))
52185231

52195232
def mark_label(self, label: MediumLevelILLabel) -> None:
52205233
"""

0 commit comments

Comments
 (0)