diff options
| author | ajax <devnull@localhost> | 2014-06-12 18:40:55 +0200 |
|---|---|---|
| committer | ajax <devnull@localhost> | 2014-06-12 18:40:55 +0200 |
| commit | 0698cd3820a70182c362ba113849fe8ca5e0e032 (patch) | |
| tree | 5fd0cabf8bc3cb43a706b401906e2c49bdf127b1 /miasm2/expression/simplifications_cond.py | |
| parent | 8462e1b5b65b61e837e673229e1bae4dc78c7840 (diff) | |
| download | miasm-0698cd3820a70182c362ba113849fe8ca5e0e032.tar.gz miasm-0698cd3820a70182c362ba113849fe8ca5e0e032.zip | |
Simplifications_cond: Fix size issue, add constructor
I could have use a child class of ExprOp specific for conditions, but I prefer to keep a better modularity by just using "<s", "<u" as a new op I don't add the size issue in expression/expression.py (such as 'parity') because we don't want dependencies from this file to expression/simplifications_cond (for TOK_*)
Diffstat (limited to 'miasm2/expression/simplifications_cond.py')
| -rw-r--r-- | miasm2/expression/simplifications_cond.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/miasm2/expression/simplifications_cond.py b/miasm2/expression/simplifications_cond.py index 93f28162..8f41975b 100644 --- a/miasm2/expression/simplifications_cond.py +++ b/miasm2/expression/simplifications_cond.py @@ -34,6 +34,25 @@ jok1 = m2_expr.ExprId("jok1") jok2 = m2_expr.ExprId("jok2") jok3 = m2_expr.ExprId("jok3") +# Constructors + +def __ExprOp_cond(op, arg1, arg2): + "Return an ExprOp standing for arg1 op arg2 with size to 1" + ec = m2_expr.ExprOp(op, arg1, arg2) + ec._size = 1 + return ec + + +def ExprOp_inf_signed(arg1, arg2): + "Return an ExprOp standing for arg1 <s arg2" + return __ExprOp_cond(TOK_INF_SIGNED, arg1, arg2) + + +def ExprOp_inf_unsigned(arg1, arg2): + "Return an ExprOp standing for arg1 <s arg2" + return __ExprOp_cond(TOK_INF_UNSIGNED, arg1, arg2) + + # Catching conditions forms def __check_msb(e): @@ -83,7 +102,7 @@ def expr_simp_inf_signed(expr_simp, e): sub = expr_simp(r[jok1] - r[jok2]) if new_j3 == sub: - return m2_expr.ExprOp(TOK_INF_SIGNED, r[jok1], r[jok2]) + return ExprOp_inf_signed(r[jok1], r[jok2]) else: return e @@ -107,7 +126,7 @@ def expr_simp_inf_unsigned_inversed(expr_simp, e): sub = expr_simp(r[jok1] - r[jok2]) if new_j3 == sub: - return m2_expr.ExprOp(TOK_INF_UNSIGNED, r[jok1], r[jok2]) + return ExprOp_inf_unsigned(r[jok1], r[jok2]) else: return e |