diff --git a/uncompyle6/parsers/reducecheck/ifstmts_jump.py b/uncompyle6/parsers/reducecheck/ifstmts_jump.py index 28761d3e..d5446905 100644 --- a/uncompyle6/parsers/reducecheck/ifstmts_jump.py +++ b/uncompyle6/parsers/reducecheck/ifstmts_jump.py @@ -9,12 +9,6 @@ def ifstmts_jump(self, lhs, n, rule, ast, tokens, first, last): return False come_froms = ast[-1] - # Make sure all of the "come froms" offset at the - # end of the "if" come from somewhere inside the "if". - # Since the come_froms are ordered so that lowest - # offset COME_FROM is last, it is sufficient to test - # just the last one. - # This is complicated, but note that the JUMP_IF instruction comes immediately # *before* _ifstmts_jump so that's what we have to test # the COME_FROM against. This can be complicated by intervening @@ -28,31 +22,30 @@ def ifstmts_jump(self, lhs, n, rule, ast, tokens, first, last): "COME_FROM", ): pop_jump_index -= 1 - come_froms = ast[-1] # FIXME: something is fishy when and EXTENDED ARG is needed before the # pop_jump_index instruction to get the argment. In this case, the # _ifsmtst_jump can jump to a spot beyond the come_froms. # That is going on in the non-EXTENDED_ARG case is that the POP_JUMP_IF # jumps to a JUMP_(FORWARD) which is changed into an EXTENDED_ARG POP_JUMP_IF - # to the jumped forwareded address + # to the jumped forwarded address if tokens[pop_jump_index].attr > 256: return False + pop_jump_offset = tokens[pop_jump_index].off2int(prefer_last=False) if isinstance(come_froms, Token): if ( - tokens[pop_jump_index].attr < tokens[pop_jump_index].offset - and ast[0] != "pass" + tokens[pop_jump_index].attr < pop_jump_offset and ast[0] != "pass" ): # This is a jump backwards to a loop. All bets are off here when there the # unless statement is "pass" which has no instructions associated with it. return False return ( come_froms.attr is not None - and tokens[pop_jump_index].offset > come_froms.attr + and pop_jump_offset > come_froms.attr ) elif len(come_froms) == 0: return False else: - return tokens[pop_jump_index].offset > come_froms[-1].attr + return pop_jump_offset > come_froms[-1].attr