You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
setcomp_func -> set_comp ...
to match AST name more closely
This commit is contained in:
@@ -19,7 +19,7 @@ class Python27Parser(Python2Parser):
|
|||||||
lc_body ::= expr LIST_APPEND
|
lc_body ::= expr LIST_APPEND
|
||||||
for_iter ::= GET_ITER COME_FROM FOR_ITER
|
for_iter ::= GET_ITER COME_FROM FOR_ITER
|
||||||
|
|
||||||
stmt ::= setcomp_func
|
stmt ::= set_comp
|
||||||
|
|
||||||
|
|
||||||
# Dictionary and set comprehensions were added in Python 2.7
|
# Dictionary and set comprehensions were added in Python 2.7
|
||||||
@@ -30,7 +30,7 @@ class Python27Parser(Python2Parser):
|
|||||||
dictcomp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store
|
dictcomp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store
|
||||||
comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
|
comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
set_comp ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
comp_body ::= dict_comp_body
|
comp_body ::= dict_comp_body
|
||||||
|
@@ -50,13 +50,13 @@ class Python3Parser(PythonParser):
|
|||||||
jb_or_c ::= JUMP_BACK
|
jb_or_c ::= JUMP_BACK
|
||||||
jb_or_c ::= CONTINUE
|
jb_or_c ::= CONTINUE
|
||||||
|
|
||||||
stmt ::= setcomp_func
|
stmt ::= set_comp
|
||||||
|
|
||||||
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
set_comp ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
setcomp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
set_comp ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||||
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
|
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||||
|
|
||||||
comp_body ::= dict_comp_body
|
comp_body ::= dict_comp_body
|
||||||
comp_body ::= set_comp_body
|
comp_body ::= set_comp_body
|
||||||
|
@@ -676,7 +676,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
# skip over stmt return ret_expr
|
# skip over stmt return ret_expr
|
||||||
ast = ast[0][0][0]
|
ast = ast[0][0][0]
|
||||||
store = None
|
store = None
|
||||||
if ast in ['setcomp_func', 'dictcomp_func']:
|
if ast in ['set_comp', 'dictcomp_func']:
|
||||||
# Offset 0: BUILD_SET should have the span
|
# Offset 0: BUILD_SET should have the span
|
||||||
# of '{'
|
# of '{'
|
||||||
self.gen_source(ast, code_name, {})
|
self.gen_source(ast, code_name, {})
|
||||||
@@ -721,8 +721,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Python 2.7+ starts including set_comp_body
|
# Python 2.7+ starts including set_comp_body
|
||||||
# Python 3.5+ starts including setcomp_func
|
# Python 3.5+ starts including set_comp
|
||||||
assert n.kind in ('lc_body', 'comp_body', 'setcomp_func', 'set_comp_body'), ast
|
assert n.kind in ('lc_body', 'comp_body', 'set_comp', 'set_comp_body'), ast
|
||||||
assert store, "Couldn't find store in list/set comprehension"
|
assert store, "Couldn't find store in list/set comprehension"
|
||||||
|
|
||||||
old_name = self.name
|
old_name = self.name
|
||||||
@@ -865,8 +865,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
self.prune()
|
self.prune()
|
||||||
|
|
||||||
# FIXME: Not sure if below is general. Also, add dict_comp_func.
|
# FIXME: Not sure if below is general. Also, add dict_comp_func.
|
||||||
# 'setcomp_func': ("%|lambda %c: {%c for %c in %c%c}\n", 1, 3, 3, 1, 4)
|
# 'set_comp': ("%|lambda %c: {%c for %c in %c%c}\n", 1, 3, 3, 1, 4)
|
||||||
def n_setcomp_func(self, node):
|
def n_set_comp(self, node):
|
||||||
setcomp_start = len(self.f.getvalue())
|
setcomp_start = len(self.f.getvalue())
|
||||||
self.write(self.indent, "lambda ")
|
self.write(self.indent, "lambda ")
|
||||||
param_node = node[1]
|
param_node = node[1]
|
||||||
|
@@ -1296,7 +1296,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
ast = ast[0]
|
ast = ast[0]
|
||||||
|
|
||||||
store = None
|
store = None
|
||||||
if ast in ['setcomp_func', 'dictcomp_func']:
|
if ast in ['set_comp', 'dictcomp_func']:
|
||||||
for k in ast:
|
for k in ast:
|
||||||
if k == 'comp_iter':
|
if k == 'comp_iter':
|
||||||
n = k
|
n = k
|
||||||
@@ -1337,8 +1337,8 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
# Python 2.7+ starts including set_comp_body
|
# Python 2.7+ starts including set_comp_body
|
||||||
# Python 3.5+ starts including setcomp_func
|
# Python 3.5+ starts including set_comp
|
||||||
assert n.kind in ('lc_body', 'comp_body', 'setcomp_func', 'set_comp_body'), ast
|
assert n.kind in ('lc_body', 'comp_body', 'set_comp', 'set_comp_body'), ast
|
||||||
assert store, "Couldn't find store in list/set comprehension"
|
assert store, "Couldn't find store in list/set comprehension"
|
||||||
|
|
||||||
# A problem created with later Python code generation is that there
|
# A problem created with later Python code generation is that there
|
||||||
|
Reference in New Issue
Block a user