From 778c8d600336f6995d8fa866cf3855d55591e082 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 9 Jan 2020 04:39:27 -0500 Subject: [PATCH] Forgot to add this file. --- uncompyle6/parsers/reducecheck/or_check.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 uncompyle6/parsers/reducecheck/or_check.py diff --git a/uncompyle6/parsers/reducecheck/or_check.py b/uncompyle6/parsers/reducecheck/or_check.py new file mode 100644 index 00000000..3fea3eb9 --- /dev/null +++ b/uncompyle6/parsers/reducecheck/or_check.py @@ -0,0 +1,21 @@ +# Copyright (c) 2020 Rocky Bernstein + + +def or_check(self, lhs, n, rule, ast, tokens, first, last): + if rule == ("or", ("expr", "jmp_true", "expr")): + jmp_true_target = ast[1][0].attr + jmp_false = tokens[last] + # If the jmp is backwards + if jmp_false == "POP_JUMP_IF_FALSE": + if jmp_false.attr < jmp_false.off2int(): + # For a backwards loop, well compare to the instruction *after* + # then POP_JUMP... + jmp_false = tokens[last+1] + return not (jmp_true_target == jmp_false.off2int() or + jmp_true_target < tokens[first].off2int()) + return tokens[last] in ( + "LOAD_ASSERT", + "RAISE_VARARGS_1", + ) + + return False