2.6 try statement (and below)

They may neeed arbitrary come_froms for each except clause
This commit is contained in:
rocky
2016-10-13 19:37:38 -04:00
parent 20ba165e4a
commit 5703ccd8b8
3 changed files with 27 additions and 15 deletions

View File

@@ -169,12 +169,19 @@ class Scanner26(scan.Scanner2):
oparg = None; pattr = None
if offset in jump_targets:
k = 0
for j in jump_targets[offset]:
tokens.append(Token('COME_FROM', None, repr(j),
offset="%s_%d" % (offset, k),
has_arg = True))
k += 1
jump_idx = 0
# We want to process COME_FROMs to the same offset to be in *descending*
# offset order so we have the larger range or biggest instruction interval
# last. (I think they are sorted in increasing order, but for safety
# we sort them). That way, specific COME_FROM tags will match up
# properly. For example, a "loop" with an "if" nested in it should have the
# "loop" tag last so the grammar rule matches that properly.
for jump_offset in sorted(jump_targets[offset], reverse=True):
tokens.append(Token(
'COME_FROM', None, repr(jump_offset),
offset="%s_%d" % (offset, jump_idx),
has_arg = True))
jump_idx += 1
has_arg = (op >= self.opc.HAVE_ARGUMENT)
if has_arg: