diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-07-04 15:19:29 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-07-19 13:17:49 +0200 |
| commit | a7e3b1b6237c94e932fcf2f2f9f268f04c7b34c7 (patch) | |
| tree | 36daa35a0e1725f748d967745e15b641095a3137 | |
| parent | a5925ddba272cb9ca85ebc22d906a306dab56147 (diff) | |
| download | miasm-a7e3b1b6237c94e932fcf2f2f9f268f04c7b34c7.tar.gz miasm-a7e3b1b6237c94e932fcf2f2f9f268f04c7b34c7.zip | |
Expression: fix slice assignment
| -rw-r--r-- | miasm2/expression/expression.py | 4 | ||||
| -rw-r--r-- | test/expression/expression.py | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/miasm2/expression/expression.py b/miasm2/expression/expression.py index 3cf37070..11400e9e 100644 --- a/miasm2/expression/expression.py +++ b/miasm2/expression/expression.py @@ -715,7 +715,9 @@ class ExprAff(Expr): return self.__class__, state def __new__(cls, dst, src): - if isinstance(dst, ExprSlice): + if dst.is_slice() and dst.arg.size == src.size: + new_dst, new_src = dst.arg, src + elif dst.is_slice(): # Complete the source with missing slice parts new_dst = dst.arg rest = [(ExprSlice(dst.arg, r[0], r[1]), r[0], r[1]) diff --git a/test/expression/expression.py b/test/expression/expression.py index 6bb6d94c..b998d4a5 100644 --- a/test/expression/expression.py +++ b/test/expression/expression.py @@ -65,3 +65,8 @@ for expr in [ ]: print repr(expr) assert expr == eval(repr(expr)) + + +aff = ExprAff(A[0:32], cst1) + +assert aff.dst == A and aff.src == cst1 |