From 11d55f727529de9bbdf88f776584b3cbb7667c20 Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Sun, 7 May 2017 20:10:38 +0200 Subject: IR: Make IRBlock immutable --- miasm2/arch/mips32/sem.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'miasm2/arch/mips32/sem.py') diff --git a/miasm2/arch/mips32/sem.py b/miasm2/arch/mips32/sem.py index bc050b38..645f9a4f 100644 --- a/miasm2/arch/mips32/sem.py +++ b/miasm2/arch/mips32/sem.py @@ -441,17 +441,14 @@ class ir_mips32l(IntermediateRepresentation): args = instr.args instr_ir, extra_ir = get_mnemo_expr(self, instr, *args) - for i, x in enumerate(instr_ir): - x = m2_expr.ExprAff(x.dst, x.src.replace_expr( - {self.pc: m2_expr.ExprInt(instr.offset + 4, 32)})) - instr_ir[i] = x - for irblock in extra_ir: - for irs in irblock.irs: - for i, x in enumerate(irs): - x = m2_expr.ExprAff(x.dst, x.src.replace_expr( - {self.pc: m2_expr.ExprInt(instr.offset + 4, 32)})) - irs[i] = x - return instr_ir, extra_ir + pc_fixed = {self.pc: m2_expr.ExprInt(instr.offset + 4, 32)} + + instr_ir = [m2_expr.ExprAff(expr.dst, expr.src.replace_expr(pc_fixed)) + for expr in instr_ir] + + new_extra_ir = [irblock.modify_exprs(mod_src=lambda expr: expr.replace_expr(pc_fixed)) + for irblock in extra_ir] + return instr_ir, new_extra_ir def get_next_instr(self, instr): return self.symbol_pool.getby_offset_create(instr.offset + 4) -- cgit 1.4.1