about summary refs log tree commit diff stats
path: root/miasm2
diff options
context:
space:
mode:
authorserpilliere <fabrice.desclaux@cea.fr>2015-02-21 21:09:07 +0100
committerserpilliere <fabrice.desclaux@cea.fr>2015-02-22 01:48:27 +0100
commitdd2da246f676ff827201c9eee3ae698081875bf7 (patch)
tree92f0b1839ac0398426ad0332cd973cf9b41ca8c9 /miasm2
parentf26427471fb9cda89b36b1d2609a9f58f1d79d68 (diff)
downloadmiasm-dd2da246f676ff827201c9eee3ae698081875bf7.tar.gz
miasm-dd2da246f676ff827201c9eee3ae698081875bf7.zip
Expression: remove code which uses expression modifications
Diffstat (limited to 'miasm2')
-rw-r--r--miasm2/expression/expression_helper.py6
-rw-r--r--miasm2/ir/ir.py9
-rw-r--r--miasm2/ir/translators/C.py2
3 files changed, 9 insertions, 8 deletions
diff --git a/miasm2/expression/expression_helper.py b/miasm2/expression/expression_helper.py
index 825cad60..3555530a 100644
--- a/miasm2/expression/expression_helper.py
+++ b/miasm2/expression/expression_helper.py
@@ -64,9 +64,11 @@ def merge_sliceto_slice(args):
     final_sources = []
     sorted_s = []
     for x in sources_int.values():
+        x = list(x)
         # mask int
         v = x[0].arg & ((1 << (x[2] - x[1])) - 1)
-        x[0].arg = v
+        x[0] = m2_expr.ExprInt_from(x[0], v)
+        x = tuple(x)
         sorted_s.append((x[1], x))
     sorted_s.sort()
     while sorted_s:
@@ -81,7 +83,7 @@ def merge_sliceto_slice(args):
             a = m2_expr.mod_size2uint[size](
                 (int(out[0].arg) << (out[1] - s_start)) +
                  int(sorted_s[-1][1][0].arg))
-            out[0].arg = a
+            out[0] = m2_expr.ExprInt(a)
             sorted_s.pop()
             out[1] = s_start
         out[0] = m2_expr.ExprInt_fromsize(size, out[0].arg)
diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py
index 73a38242..3a8cbb14 100644
--- a/miasm2/ir/ir.py
+++ b/miasm2/ir/ir.py
@@ -55,12 +55,12 @@ class irbloc(object):
         """Find and replace the IRDst affectation's source by @value"""
         dst = None
         for ir in self.irs:
-            for i in ir:
-                if isinstance(i.dst, m2_expr.ExprId) and i.dst.name == "IRDst":
+            for i, expr in enumerate(ir):
+                if isinstance(expr.dst, m2_expr.ExprId) and expr.dst.name == "IRDst":
                     if dst is not None:
                         raise ValueError('Multiple destinations!')
                     dst = value
-                    i.src = value
+                    ir[i] = m2_expr.ExprAff(expr.dst, value)
         self._dst = value
 
     dst = property(get_dst, set_dst)
@@ -296,8 +296,7 @@ class ir(object):
         for b in self.blocs.values():
             for ir in b.irs:
                 for i, r in enumerate(ir):
-                    ir[i].src = expr_simp(r.src)
-                    ir[i].dst = expr_simp(r.dst)
+                    ir[i] = m2_expr.ExprAff(expr_simp(r.dst), expr_simp(r.src))
 
     def replace_expr_in_ir(self, bloc, rep):
         for irs in bloc.irs:
diff --git a/miasm2/ir/translators/C.py b/miasm2/ir/translators/C.py
index 007f8378..feb7539b 100644
--- a/miasm2/ir/translators/C.py
+++ b/miasm2/ir/translators/C.py
@@ -50,7 +50,7 @@ class TranslatorC(Translator):
 
     @classmethod
     def from_ExprMem(cls, expr):
-        return "MEM_LOOKUP_%.2d(vm_mngr, %s)" % (expr._size,
+        return "MEM_LOOKUP_%.2d(vm_mngr, %s)" % (expr.size,
                                                  cls.from_expr(expr.arg))
 
     @classmethod