@@ -510,6 +510,8 @@ def create(
510510 inst = core .BNGetLowLevelILByIndex (func .handle , expr_index )
511511 assert inst is not None , "core.BNGetLowLevelILByIndex returned None"
512512 core_inst = CoreLowLevelILInstruction .from_BNLowLevelILInstruction (inst )
513+ if instr_index is None :
514+ instr_index = func .get_instruction_index_for_expr (expr_index )
513515 return ILInstruction [core_inst .operation ](func , expr_index , core_inst , instr_index ) # type: ignore
514516
515517 def copy_to (
@@ -6221,6 +6223,16 @@ def get_ssa_flag_value(self, flag_ssa: SSAFlag) -> 'variable.RegisterValue':
62216223 result = variable .RegisterValue .from_BNRegisterValue (value , self ._arch )
62226224 return result
62236225
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+
62246236 def get_medium_level_il_instruction_index (self ,
62256237 instr : InstructionIndex ) -> Optional ['mediumlevelil.InstructionIndex' ]:
62266238 med_il = self .medium_level_il
0 commit comments