diff --git a/test/bytecode_2.7_run/01_ifelse_listcomp.pyc-notyet b/test/bytecode_2.7_run/01_ifelse_listcomp.pyc similarity index 100% rename from test/bytecode_2.7_run/01_ifelse_listcomp.pyc-notyet rename to test/bytecode_2.7_run/01_ifelse_listcomp.pyc diff --git a/test/bytecode_2.7_run/15_mixed_expressions.pyc-notyet b/test/bytecode_2.7_run/15_mixed_expressions.pyc similarity index 100% rename from test/bytecode_2.7_run/15_mixed_expressions.pyc-notyet rename to test/bytecode_2.7_run/15_mixed_expressions.pyc diff --git a/test/bytecode_3.5/11_return_val.pyc b/test/bytecode_3.5/11_return_val.pyc-notyet similarity index 100% rename from test/bytecode_3.5/11_return_val.pyc rename to test/bytecode_3.5/11_return_val.pyc-notyet diff --git a/test/bytecode_3.6/01_extended_arg.pyc b/test/bytecode_3.6/01_extended_arg.pyc-notyet similarity index 100% rename from test/bytecode_3.6/01_extended_arg.pyc rename to test/bytecode_3.6/01_extended_arg.pyc-notyet diff --git a/uncompyle6/parsers/reducecheck/or_check.py b/uncompyle6/parsers/reducecheck/or_check.py index 5e0c7d85..c76d0735 100644 --- a/uncompyle6/parsers/reducecheck/or_check.py +++ b/uncompyle6/parsers/reducecheck/or_check.py @@ -3,9 +3,14 @@ ASSERT_OPS = frozenset(["LOAD_ASSERT", "RAISE_VARARGS_1"]) def or_check(self, lhs, n, rule, ast, tokens, first, last): rhs = rule[1] - if rhs in (("expr_jt", "expr"), - ("expr_jitop", "expr", "COME_FROM"), - ("expr_jit", "expr", "\\e_come_from_opt")): + + # print("XXX", first, last, rule) + # for t in range(first, last): print(tokens[t]) + # print("="*40) + + if rhs[0:2] in (("expr_jt", "expr"), + ("expr_jitop", "expr"), + ("expr_jit", "expr")): if tokens[last] in ASSERT_OPS or tokens[last-1] in ASSERT_OPS: return True @@ -22,28 +27,36 @@ def or_check(self, lhs, n, rule, ast, tokens, first, last): first_offset = tokens[first].off2int() expr_jt = ast[0] + if expr_jt == "expr_jitop": jump_true = expr_jt[1] else: jump_true = expr_jt[1][0] jmp_true_target = jump_true.attr - jmp_true_target < first_offset + + last_token = tokens[last] + last_token_offset = last_token.off2int() if jmp_true_target < first_offset: return False + elif jmp_true_target < last_token_offset: + return True - jmp_false = tokens[last] # If the jmp is backwards - if jmp_false == "POP_JUMP_IF_FALSE": - jmp_false_offset = jmp_false.off2int() - if jmp_false.attr < jmp_false_offset: + if last_token == "POP_JUMP_IF_FALSE": + if last_token.attr < last_token_offset: # For a backwards loop, well compare to the instruction *after* # then POP_JUMP... - jmp_false = tokens[last + 1] + last_token = tokens[last + 1] return not ( - (jmp_false_offset <= jmp_true_target <= jmp_false_offset + 2) + (last_token_offset <= jmp_true_target <= last_token_offset + 2) or jmp_true_target < tokens[first].off2int() ) + elif last_token == "JUMP_FORWARD" and expr_jt.kind != "expr_jitop": + # "or" has to fall through to the next statement + # FIXME: use instructions for all of this + return True + return False