From 6baf0bc2f3058efd5e0b33e128729f5b1e6f7f2d Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Thu, 13 Mar 2025 15:07:31 -0400 Subject: Python: Add ILSourceLocation to these functions too --- python/mediumlevelil.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'python') diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index c7379023..6bcf9807 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -5193,17 +5193,26 @@ class MediumLevelILFunction: """ return self.expr(MediumLevelILOperation.MLIL_FCMP_UO, a, b, size=size, source_location=loc) - def goto(self, label: MediumLevelILLabel) -> ExpressionIndex: + def goto( + self, label: MediumLevelILLabel, loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``goto`` returns a goto expression which jumps to the provided MediumLevelILLabel. :param MediumLevelILLabel label: Label to jump to + :param ILSourceLocation loc: location of returned expression :return: the ExpressionIndex that jumps to the provided label :rtype: ExpressionIndex """ - return ExpressionIndex(core.BNMediumLevelILGoto(self.handle, label.handle)) + if loc is not None: + return ExpressionIndex(core.BNMediumLevelILGotoWithLocation(self.handle, label.handle, loc.address, loc.source_operand)) + else: + return ExpressionIndex(core.BNMediumLevelILGoto(self.handle, label.handle)) - def if_expr(self, operand: ExpressionIndex, t: MediumLevelILLabel, f: MediumLevelILLabel) -> ExpressionIndex: + def if_expr( + self, operand: ExpressionIndex, t: MediumLevelILLabel, f: MediumLevelILLabel, label: MediumLevelILLabel, + loc: Optional['ILSourceLocation'] = None + ) -> ExpressionIndex: """ ``if_expr`` returns the ``if`` expression which depending on condition ``operand`` jumps to the MediumLevelILLabel ``t`` when the condition expression ``operand`` is non-zero and ``f`` when it's zero. @@ -5211,10 +5220,14 @@ class MediumLevelILFunction: :param ExpressionIndex operand: comparison expression to evaluate. :param MediumLevelILLabel t: Label for the true branch :param MediumLevelILLabel f: Label for the false branch + :param ILSourceLocation loc: location of returned expression :return: the ExpressionIndex for the if expression :rtype: ExpressionIndex """ - return ExpressionIndex(core.BNMediumLevelILIf(self.handle, operand, t.handle, f.handle)) + if loc is not None: + return ExpressionIndex(core.BNMediumLevelILIfWithLocation(self.handle, operand, t.handle, f.handle, loc.address, loc.source_operand)) + else: + return ExpressionIndex(core.BNMediumLevelILIf(self.handle, operand, t.handle, f.handle)) def mark_label(self, label: MediumLevelILLabel) -> None: """ -- cgit v1.3.1