``translate`` clones an IL function and modifies its expressions as specified by a given ``expr_handler``, returning the updated IL function. :param expr_handler: Function to modify an expression and copy it to the new function. The function should have the following s
( self, expr_handler: Callable[['LowLevelILFunction', 'LowLevelILBasicBlock', 'LowLevelILInstruction'], ExpressionIndex] )
| 4127 | raise NotImplementedError(f"unknown expr operation {expr.operation} in copy_expr_to") |
| 4128 | |
| 4129 | def translate( |
| 4130 | self, expr_handler: Callable[['LowLevelILFunction', 'LowLevelILBasicBlock', 'LowLevelILInstruction'], ExpressionIndex] |
| 4131 | ) -> 'LowLevelILFunction': |
| 4132 | """ |
| 4133 | ``translate`` clones an IL function and modifies its expressions as specified by |
| 4134 | a given ``expr_handler``, returning the updated IL function. |
| 4135 | |
| 4136 | :param expr_handler: Function to modify an expression and copy it to the new function. |
| 4137 | The function should have the following signature: |
| 4138 | |
| 4139 | .. function:: expr_handler(new_func: LowLevelILFunction, old_block: LowLevelILBasicBlock, old_instr: LowLevelILInstruction) -> ExpressionIndex |
| 4140 | |
| 4141 | Where: |
| 4142 | - **new_func** (*LowLevelILFunction*): New function to receive translated instructions |
| 4143 | - **old_block** (*LowLevelILBasicBlock*): Original block containing old_instr |
| 4144 | - **old_instr** (*LowLevelILInstruction*): Original instruction |
| 4145 | - **returns** (*ExpressionIndex*): Expression index of newly created instruction in ``new_func`` |
| 4146 | :return: Cloned IL function with modifications |
| 4147 | """ |
| 4148 | |
| 4149 | propagated_func = LowLevelILFunction(self.arch, source_func=self.source_function) |
| 4150 | propagated_func.prepare_to_copy_function(self) |
| 4151 | for block in self.basic_blocks: |
| 4152 | propagated_func.prepare_to_copy_block(block) |
| 4153 | for instr_index in range(block.start, block.end): |
| 4154 | instr: LowLevelILInstruction = self[InstructionIndex(instr_index)] |
| 4155 | propagated_func.set_current_address(instr.address, block.arch) |
| 4156 | propagated_func.append(expr_handler(propagated_func, block, instr)) |
| 4157 | |
| 4158 | return propagated_func |
| 4159 | |
| 4160 | def set_expr_attributes(self, expr: InstructionOrExpression, value: ILInstructionAttributeSet): |
| 4161 | """ |
no test coverage detected