mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-10-07 18:23:42 +00:00
2.6 genexpr. Some not quite right.
This commit is contained in:
parent
d7f7748000
commit
4b0b7f76dc
BIN
test/bytecode_2.6/08_for_if_for.pyc
Normal file
BIN
test/bytecode_2.6/08_for_if_for.pyc
Normal file
Binary file not shown.
7
test/simple_source/comprehension/08_for_if_for.py
Normal file
7
test/simple_source/comprehension/08_for_if_for.py
Normal file
@ -0,0 +1,7 @@
|
||||
# from 2.6.9 ast
|
||||
# Should see genexpr
|
||||
rv = '%s(%s' % (node.__class__.__name__, ', '.join(
|
||||
('%s=%s' % field for field in fields)
|
||||
if annotate_fields else
|
||||
(b for a, b in fields)
|
||||
))
|
@ -74,6 +74,7 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
jb_cf_pop ::= JUMP_BACK come_froms POP_TOP
|
||||
ja_cf_pop ::= JUMP_ABSOLUTE come_from_pop
|
||||
jf_cf_pop ::= JUMP_FORWARD come_from_pop
|
||||
|
||||
_ifstmts_jump ::= c_stmts_opt jf_pop COME_FROM
|
||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM come_from_pop
|
||||
@ -133,6 +134,8 @@ class Python26Parser(Python2Parser):
|
||||
setup_loop_lf ::= SETUP_LOOP LOAD_FAST
|
||||
genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK POP_BLOCK COME_FROM
|
||||
genexpr_func ::= setup_loop_lf FOR_ITER designator comp_iter JUMP_BACK come_from_pop JUMP_BACK POP_BLOCK COME_FROM
|
||||
genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 COME_FROM
|
||||
|
||||
'''
|
||||
|
||||
def p_ret26(self, args):
|
||||
@ -153,7 +156,10 @@ class Python26Parser(Python2Parser):
|
||||
except_suite ::= c_stmts_opt jmp_abs new_block
|
||||
'''
|
||||
|
||||
|
||||
def p_misc(self, args):
|
||||
'''
|
||||
conditional ::= expr jmp_false expr jf_cf_pop expr
|
||||
'''
|
||||
|
||||
class Python26ParserSingle(Python2Parser, PythonParserSingle):
|
||||
pass
|
||||
|
@ -1045,6 +1045,12 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
# FIXME: clean this up
|
||||
if self.version > 3.0 and node == 'dictcomp':
|
||||
cn = node[1]
|
||||
elif self.version < 2.7 and node == 'genexpr':
|
||||
if node[0] == 'LOAD_GENEXPR':
|
||||
cn = node[0]
|
||||
elif node[0] == 'load_closure':
|
||||
cn = node[1]
|
||||
|
||||
elif self.version > 3.0 and node == 'genexpr':
|
||||
if node[0] == 'load_genexpr':
|
||||
load_genexpr = node[0]
|
||||
|
Loading…
Reference in New Issue
Block a user