You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Python 2.4 generator expressions and gen_comp_body
This commit is contained in:
@@ -27,6 +27,9 @@ class Python24Parser(Python25Parser):
|
||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_TOP POP_BLOCK COME_FROM
|
||||
|
||||
call_stmt ::= yield
|
||||
|
||||
# Python 2.5+ adds POP_TOP
|
||||
gen_comp_body ::= expr YIELD_VALUE
|
||||
'''
|
||||
|
||||
class Python24ParserSingle(Python25Parser, PythonParserSingle):
|
||||
|
@@ -36,6 +36,9 @@ class Scanner2(scan.Scanner):
|
||||
scan.Scanner.__init__(self, version, show_asm)
|
||||
self.pop_jump_if = frozenset([self.opc.PJIF, self.opc.PJIT])
|
||||
self.jump_forward = frozenset([self.opc.JA, self.opc.JF])
|
||||
# This is the 2.5+ default
|
||||
# For <2.5 it is <generator expression>
|
||||
self.genexpr_name = '<genexpr>';
|
||||
|
||||
def disassemble(self, co, classname=None, code_objects={}, show_asm=None):
|
||||
"""
|
||||
@@ -143,7 +146,7 @@ class Scanner2(scan.Scanner):
|
||||
if const.co_name == '<lambda>':
|
||||
assert opname == 'LOAD_CONST'
|
||||
opname = 'LOAD_LAMBDA'
|
||||
elif const.co_name == '<genexpr>':
|
||||
elif const.co_name == self.genexpr_name:
|
||||
opname = 'LOAD_GENEXPR'
|
||||
elif const.co_name == '<dictcomp>':
|
||||
opname = 'LOAD_DICTCOMP'
|
||||
|
@@ -65,4 +65,5 @@ class Scanner24(scan.Scanner25):
|
||||
# Python 2.7 has POP_JUMP_IF_{TRUE,FALSE}_OR_POP but < 2.7 doesn't
|
||||
# Add an empty set make processing more uniform.
|
||||
self.pop_jump_if_or_pop = frozenset([])
|
||||
self.genexpr_name = '<generator expression>';
|
||||
return
|
||||
|
@@ -199,7 +199,7 @@ class Scanner26(scan.Scanner2):
|
||||
if const.co_name == '<lambda>':
|
||||
assert op_name == 'LOAD_CONST'
|
||||
op_name = 'LOAD_LAMBDA'
|
||||
elif const.co_name == '<genexpr>':
|
||||
elif const.co_name == self.genexpr_name:
|
||||
op_name = 'LOAD_GENEXPR'
|
||||
elif const.co_name == '<dictcomp>':
|
||||
op_name = 'LOAD_DICTCOMP'
|
||||
|
Reference in New Issue
Block a user