@@ -510,6 +510,8 @@ def create(
510
510
inst = core .BNGetLowLevelILByIndex (func .handle , expr_index )
511
511
assert inst is not None , "core.BNGetLowLevelILByIndex returned None"
512
512
core_inst = CoreLowLevelILInstruction .from_BNLowLevelILInstruction (inst )
513
+ if instr_index is None :
514
+ instr_index = func .get_instruction_index_for_expr (expr_index )
513
515
return ILInstruction [core_inst .operation ](func , expr_index , core_inst , instr_index ) # type: ignore
514
516
515
517
def copy_to (
@@ -6221,6 +6223,16 @@ def get_ssa_flag_value(self, flag_ssa: SSAFlag) -> 'variable.RegisterValue':
6221
6223
result = variable .RegisterValue .from_BNRegisterValue (value , self ._arch )
6222
6224
return result
6223
6225
6226
+ def get_instruction_index_for_expr (self , expr : ExpressionIndex ) -> Optional [InstructionIndex ]:
6227
+ result = core .BNGetLowLevelILInstructionForExpr (self .handle , expr )
6228
+ if result >= core .BNGetLowLevelILInstructionCount (self .handle ):
6229
+ return None
6230
+ return InstructionIndex (result )
6231
+
6232
+ def get_expr_index_for_instruction (self , instr : InstructionIndex ) -> ExpressionIndex :
6233
+ result = core .BNGetLowLevelILInstructionForExpr (self .handle , instr )
6234
+ return ExpressionIndex (result )
6235
+
6224
6236
def get_medium_level_il_instruction_index (self ,
6225
6237
instr : InstructionIndex ) -> Optional ['mediumlevelil.InstructionIndex' ]:
6226
6238
med_il = self .medium_level_il
0 commit comments