2.6- bug: while..and: stmt - on one line

If 2.6 or before POP_BLOCK after a JUMP_IF_FALSE does not
constitute a new statement. The POP_BLOCK is really part
of the JUMP_IF_FALSE. In Python 2.7+ it's a single op.
This commit is contained in:
rocky
2016-09-01 20:44:17 -04:00
parent 1d567d5d9a
commit f5eeed6759
4 changed files with 39 additions and 16 deletions

View File

@@ -71,12 +71,20 @@ class Scanner26(scan.Scanner2):
return
def disassemble(self, co, classname=None, code_objects={}, show_asm=None):
'''
Disassemble a code object, returning a list of 'Token'.
"""
Pick out tokens from an uncompyle6 code object, and transform them,
returning a list of uncompyle6 'Token's.
The main part of this procedure is modelled after
dis.disassemble().
'''
The tranformations are made to assist the deparsing grammar.
Specificially:
- various types of LOAD_CONST's are categorized in terms of what they load
- COME_FROM instructions are added to assist parsing control structures
- MAKE_FUNCTION and FUNCTION_CALLS append the number of positional arguments
Also, when we encounter certain tokens, we add them to a set which will cause custom
grammar rules. Specifically, variable arg tokens like MAKE_FUNCTION or BUILD_LIST
cause specific rules for the specific number of arguments they take.
"""
show_asm = self.show_asm if not show_asm else show_asm
# show_asm = 'both'
@@ -102,9 +110,6 @@ class Scanner26(scan.Scanner2):
self.build_lines_data(co, n)
self.build_prev_op(n)
# linestarts contains block code adresses (addr,block)
self.linestarts = list(self.opc.findlinestarts(co))
# class and names
if classname:
classname = '_' + classname.lstrip('_') + '__'