You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
DRY and limit STORE_LOCALS
This commit is contained in:
@@ -186,8 +186,9 @@ class Python27Parser(Python2Parser):
|
|||||||
return not (jmp_target == tokens[last].offset or
|
return not (jmp_target == tokens[last].offset or
|
||||||
tokens[last].pattr == jmp_false.pattr)
|
tokens[last].pattr == jmp_false.pattr)
|
||||||
elif rule[0] == ('conditional_true'):
|
elif rule[0] == ('conditional_true'):
|
||||||
# FIXME: the below is a hack. script is probably never used in a boolean
|
# FIXME: the below is a hack: "subscript" was probably never used
|
||||||
# What we really need is to look for precence of dead code.
|
# in a boolean which got eliminated. What we really need is to
|
||||||
|
# look for precence of dead code.
|
||||||
if ast[0] == 'expr':
|
if ast[0] == 'expr':
|
||||||
a = ast[0]
|
a = ast[0]
|
||||||
else:
|
else:
|
||||||
|
@@ -1103,10 +1103,6 @@ class Python30Parser(Python3Parser):
|
|||||||
|
|
||||||
def p_30(self, args):
|
def p_30(self, args):
|
||||||
"""
|
"""
|
||||||
# Store locals is only in Python 3.0 to 3.3
|
|
||||||
stmt ::= store_locals
|
|
||||||
store_locals ::= LOAD_FAST STORE_LOCALS
|
|
||||||
|
|
||||||
jmp_true ::= JUMP_IF_TRUE_OR_POP POP_TOP
|
jmp_true ::= JUMP_IF_TRUE_OR_POP POP_TOP
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD POP_TOP COME_FROM
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD POP_TOP COME_FROM
|
||||||
"""
|
"""
|
||||||
|
@@ -11,9 +11,6 @@ class Python30Parser(Python31Parser):
|
|||||||
|
|
||||||
def p_30(self, args):
|
def p_30(self, args):
|
||||||
"""
|
"""
|
||||||
# Store locals is only in Python 3.0 to 3.3
|
|
||||||
stmt ::= store_locals
|
|
||||||
store_locals ::= LOAD_FAST STORE_LOCALS
|
|
||||||
|
|
||||||
# FIXME: combine with parse3.2
|
# FIXME: combine with parse3.2
|
||||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK
|
||||||
|
@@ -26,6 +26,13 @@ class Python33Parser(Python32Parser):
|
|||||||
jump_excepts come_from_except_clauses
|
jump_excepts come_from_except_clauses
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def p_30to33(self, args):
|
||||||
|
"""
|
||||||
|
# Store locals is only in Python 3.0 to 3.3
|
||||||
|
stmt ::= store_locals
|
||||||
|
store_locals ::= LOAD_FAST STORE_LOCALS
|
||||||
|
"""
|
||||||
|
|
||||||
def customize_grammar_rules(self, tokens, customize):
|
def customize_grammar_rules(self, tokens, customize):
|
||||||
self.remove_rules("""
|
self.remove_rules("""
|
||||||
# 3.3+ adds POP_BLOCKS
|
# 3.3+ adds POP_BLOCKS
|
||||||
|
Reference in New Issue
Block a user