diff options
Diffstat (limited to 'miasm2/expression')
| -rw-r--r-- | miasm2/expression/expression.py | 20 | ||||
| -rw-r--r-- | miasm2/expression/simplifications_cond.py | 21 |
2 files changed, 20 insertions, 21 deletions
diff --git a/miasm2/expression/expression.py b/miasm2/expression/expression.py index bf27218b..8ea855b5 100644 --- a/miasm2/expression/expression.py +++ b/miasm2/expression/expression.py @@ -1400,7 +1400,7 @@ def match_expr(expr, pattern, tks, result=None): # We need to use a copy of result to not override it myresult = dict(result) for sub_expr, sub_pattern in zip(permut, pattern.args): - ret = MatchExpr(sub_expr, sub_pattern, tks, myresult) + ret = match_expr(sub_expr, sub_pattern, tks, myresult) # If the current permutation do not match EVERY terms if ret is False: good = False @@ -1420,23 +1420,23 @@ def match_expr(expr, pattern, tks, result=None): return False if expr.size != pattern.size: return False - return MatchExpr(expr.arg, pattern.arg, tks, result) + return match_expr(expr.arg, pattern.arg, tks, result) elif expr.is_slice(): if not pattern.is_slice(): return False if expr.start != pattern.start or expr.stop != pattern.stop: return False - return MatchExpr(expr.arg, pattern.arg, tks, result) + return match_expr(expr.arg, pattern.arg, tks, result) elif expr.is_cond(): if not pattern.is_cond(): return False - if MatchExpr(expr.cond, pattern.cond, tks, result) is False: + if match_expr(expr.cond, pattern.cond, tks, result) is False: return False - if MatchExpr(expr.src1, pattern.src1, tks, result) is False: + if match_expr(expr.src1, pattern.src1, tks, result) is False: return False - if MatchExpr(expr.src2, pattern.src2, tks, result) is False: + if match_expr(expr.src2, pattern.src2, tks, result) is False: return False return result @@ -1444,21 +1444,21 @@ def match_expr(expr, pattern, tks, result=None): if not pattern.is_compose(): return False for sub_expr, sub_pattern in zip(expr.args, pattern.args): - if MatchExpr(sub_expr, sub_pattern, tks, result) is False: + if match_expr(sub_expr, sub_pattern, tks, result) is False: return False return result elif expr.is_aff(): if not pattern.is_aff(): return False - if MatchExpr(expr.src, pattern.src, tks, result) is False: + if match_expr(expr.src, pattern.src, tks, result) is False: return False - if MatchExpr(expr.dst, pattern.dst, tks, result) is False: + if match_expr(expr.dst, pattern.dst, tks, result) is False: return False return result else: - raise NotImplementedError("MatchExpr: Unknown type: %s" % type(expr)) + raise NotImplementedError("match_expr: Unknown type: %s" % type(expr)) def MatchExpr(expr, pattern, tks, result=None): diff --git a/miasm2/expression/simplifications_cond.py b/miasm2/expression/simplifications_cond.py index 0d194d9a..3054d92b 100644 --- a/miasm2/expression/simplifications_cond.py +++ b/miasm2/expression/simplifications_cond.py @@ -62,12 +62,12 @@ def __check_msb(e): return arg -def __MatchExprWrap(e, to_match, jok_list): - "Wrapper around MatchExpr to canonize pattern" +def __match_expr_wrap(e, to_match, jok_list): + "Wrapper around match_expr to canonize pattern" to_match = to_match.canonize() - r = m2_expr.MatchExpr(e, to_match, jok_list) + r = m2_expr.match_expr(e, to_match, jok_list) if r is False: return False @@ -82,10 +82,9 @@ def expr_simp_inf_signed(expr_simp, e): arg = __check_msb(e) if arg is False: return e - # We want jok3 = jok1 - jok2 to_match = jok3 ^ ((jok1 ^ jok2) & (jok3 ^ jok1)) - r = __MatchExprWrap(arg, + r = __match_expr_wrap(arg, to_match, [jok1, jok2, jok3]) @@ -109,7 +108,7 @@ def expr_simp_inf_unsigned_inversed(expr_simp, e): # We want jok3 = jok1 - jok2 to_match = jok3 ^ ((jok1 ^ jok2) & (jok3 ^ jok1)) ^ jok1 ^ jok2 - r = __MatchExprWrap(arg, + r = __match_expr_wrap(arg, to_match, [jok1, jok2, jok3]) @@ -129,14 +128,14 @@ def expr_simp_inverse(expr_simp, e): (x <s y) ^ ((x ^ y) [31:32]) == x <u y""" to_match = (ExprOp_inf_unsigned(jok1, jok2) ^ jok_small) - r = __MatchExprWrap(e, + r = __match_expr_wrap(e, to_match, [jok1, jok2, jok_small]) # Check for 2 symetric cases if r is False: to_match = (ExprOp_inf_signed(jok1, jok2) ^ jok_small) - r = __MatchExprWrap(e, + r = __match_expr_wrap(e, to_match, [jok1, jok2, jok_small]) @@ -170,9 +169,9 @@ def expr_simp_equal(expr_simp, e): """(x - y)?(0:1) == (x == y)""" to_match = m2_expr.ExprCond(jok1 + jok2, m2_expr.ExprInt(0, 1), m2_expr.ExprInt(1, 1)) - r = __MatchExprWrap(e, - to_match, - [jok1, jok2]) + r = __match_expr_wrap(e, + to_match, + [jok1, jok2]) if r is False: return e |