about summary refs log tree commit diff stats
path: root/miasm2/core/sembuilder.py
diff options
context:
space:
mode:
authorserpilliere <fabrice.desclaux@cea.fr>2015-02-21 20:51:31 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2016-11-04 16:45:46 +0100
commit8e8a60b5d55db6209d05577d038ed3b4dc961b60 (patch)
tree2cb6c1b7133d073897abe2e072662369ec60ee57 /miasm2/core/sembuilder.py
parenta15e0faca425c6e2591448e510bf14f1c3f04e14 (diff)
downloadmiasm-8e8a60b5d55db6209d05577d038ed3b4dc961b60.tar.gz
miasm-8e8a60b5d55db6209d05577d038ed3b4dc961b60.zip
Expression: Use singleton pattern for Expression
Start the transformation of Expression into immutable.

Multiple problems were present in Expression class. One of them was
comparison done through hash, which could generate collisions. The
attributes is_simp/is_canon where linked to the instance, and could not
survive to expression simplification.
Diffstat (limited to 'miasm2/core/sembuilder.py')
-rw-r--r--miasm2/core/sembuilder.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/miasm2/core/sembuilder.py b/miasm2/core/sembuilder.py
index ce327ce1..7f80b64e 100644
--- a/miasm2/core/sembuilder.py
+++ b/miasm2/core/sembuilder.py
@@ -16,7 +16,7 @@ class MiasmTransformer(ast.NodeTransformer):
     X if Y else Z -> ExprCond(Y, X, Z)
     'X'(Y)        -> ExprOp('X', Y)
     ('X' % Y)(Z)  -> ExprOp('X' % Y, Z)
-    {a, b}        -> ExprCompose([a, 0, a.size], [b, a.size, a.size + b.size])
+    {a, b}        -> ExprCompose([(a, 0, a.size), (b, a.size, a.size + b.size)])
     """
 
     # Parsers
@@ -95,7 +95,7 @@ class MiasmTransformer(ast.NodeTransformer):
         return call
 
     def visit_Set(self, node):
-        "{a, b} -> ExprCompose([a, 0, a.size], [b, a.size, a.size + b.size])"
+        "{a, b} -> ExprCompose([(a, 0, a.size)], (b, a.size, a.size + b.size)])"
         if len(node.elts) == 0:
             return node
 
@@ -109,7 +109,7 @@ class MiasmTransformer(ast.NodeTransformer):
                                   right=ast.Attribute(value=elt,
                                                       attr='size',
                                                       ctx=ast.Load()))
-            new_elts.append(ast.List(elts=[elt, index, new_index],
+            new_elts.append(ast.Tuple(elts=[elt, index, new_index],
                                      ctx=ast.Load()))
             index = new_index
         return ast.Call(func=ast.Name(id='ExprCompose',