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 3.4 correct grammar for some looping constructs
This commit is contained in:
@@ -3,9 +3,11 @@ opcode module - potentially shared between dis and other modules which
|
|||||||
operate on bytecodes (e.g. peephole optimizers).
|
operate on bytecodes (e.g. peephole optimizers).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Note: this should look exactly like Python 3.4's opcode.py
|
||||||
|
|
||||||
__all__ = ["cmp_op", "hasconst", "hasname", "hasjrel", "hasjabs",
|
__all__ = ["cmp_op", "hasconst", "hasname", "hasjrel", "hasjabs",
|
||||||
"haslocal", "hascompare", "hasfree", "opname", "opmap",
|
"haslocal", "hascompare", "hasfree", "opname", "opmap",
|
||||||
"HAVE_ARGUMENT", "EXTENDED_ARG"]
|
"HAVE_ARGUMENT", "EXTENDED_ARG", "hasnargs"]
|
||||||
|
|
||||||
cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is',
|
cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is',
|
||||||
'is not', 'exception match', 'BAD')
|
'is not', 'exception match', 'BAD')
|
||||||
@@ -17,6 +19,7 @@ hasjabs = []
|
|||||||
haslocal = []
|
haslocal = []
|
||||||
hascompare = []
|
hascompare = []
|
||||||
hasfree = []
|
hasfree = []
|
||||||
|
hasnargs = []
|
||||||
|
|
||||||
opmap = {}
|
opmap = {}
|
||||||
opname = [''] * 256
|
opname = [''] * 256
|
||||||
@@ -83,10 +86,13 @@ def_op('BINARY_XOR', 65)
|
|||||||
def_op('BINARY_OR', 66)
|
def_op('BINARY_OR', 66)
|
||||||
def_op('INPLACE_POWER', 67)
|
def_op('INPLACE_POWER', 67)
|
||||||
def_op('GET_ITER', 68)
|
def_op('GET_ITER', 68)
|
||||||
|
|
||||||
|
## FIXME: no code generates this
|
||||||
def_op('STORE_LOCALS', 69)
|
def_op('STORE_LOCALS', 69)
|
||||||
|
|
||||||
def_op('PRINT_EXPR', 70)
|
def_op('PRINT_EXPR', 70)
|
||||||
def_op('LOAD_BUILD_CLASS', 71)
|
def_op('LOAD_BUILD_CLASS', 71)
|
||||||
|
def_op('YIELD_FROM', 72)
|
||||||
|
|
||||||
def_op('INPLACE_LSHIFT', 75)
|
def_op('INPLACE_LSHIFT', 75)
|
||||||
def_op('INPLACE_RSHIFT', 76)
|
def_op('INPLACE_RSHIFT', 76)
|
||||||
@@ -151,6 +157,7 @@ haslocal.append(126)
|
|||||||
|
|
||||||
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
|
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
|
||||||
def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8)
|
def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8)
|
||||||
|
hasnargs.append(131)
|
||||||
def_op('MAKE_FUNCTION', 132) # Number of args with default values
|
def_op('MAKE_FUNCTION', 132) # Number of args with default values
|
||||||
def_op('BUILD_SLICE', 133) # Number of items
|
def_op('BUILD_SLICE', 133) # Number of items
|
||||||
def_op('MAKE_CLOSURE', 134)
|
def_op('MAKE_CLOSURE', 134)
|
||||||
@@ -164,8 +171,11 @@ def_op('DELETE_DEREF', 138)
|
|||||||
hasfree.append(138)
|
hasfree.append(138)
|
||||||
|
|
||||||
def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8)
|
def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8)
|
||||||
|
hasnargs.append(140)
|
||||||
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
|
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
|
||||||
|
hasnargs.append(141)
|
||||||
def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
|
def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
|
||||||
|
hasnargs.append(142)
|
||||||
|
|
||||||
jrel_op('SETUP_WITH', 143)
|
jrel_op('SETUP_WITH', 143)
|
||||||
|
|
||||||
@@ -173,6 +183,9 @@ def_op('LIST_APPEND', 145)
|
|||||||
def_op('SET_ADD', 146)
|
def_op('SET_ADD', 146)
|
||||||
def_op('MAP_ADD', 147)
|
def_op('MAP_ADD', 147)
|
||||||
|
|
||||||
|
def_op('LOAD_CLASSDEREF', 148)
|
||||||
|
hasfree.append(148)
|
||||||
|
|
||||||
def_op('EXTENDED_ARG', 144)
|
def_op('EXTENDED_ARG', 144)
|
||||||
EXTENDED_ARG = 144
|
EXTENDED_ARG = 144
|
||||||
|
|
||||||
|
@@ -456,7 +456,7 @@ class Python3Parser(PythonParser):
|
|||||||
|
|
||||||
whilestmt ::= SETUP_LOOP
|
whilestmt ::= SETUP_LOOP
|
||||||
testexpr
|
testexpr
|
||||||
l_stmts_opt JUMP_BACK
|
l_stmts_opt JUMP_ABSOLUTE
|
||||||
POP_BLOCK COME_FROM
|
POP_BLOCK COME_FROM
|
||||||
|
|
||||||
whilestmt ::= SETUP_LOOP
|
whilestmt ::= SETUP_LOOP
|
||||||
@@ -481,7 +481,7 @@ class Python3Parser(PythonParser):
|
|||||||
_for ::= GET_ITER FOR_ITER
|
_for ::= GET_ITER FOR_ITER
|
||||||
_for ::= LOAD_CONST FOR_LOOP
|
_for ::= LOAD_CONST FOR_LOOP
|
||||||
|
|
||||||
for_block ::= l_stmts_opt JUMP_BACK
|
for_block ::= l_stmts_opt JUMP_ABSOLUTE
|
||||||
for_block ::= return_stmts _come_from
|
for_block ::= return_stmts _come_from
|
||||||
|
|
||||||
forstmt ::= SETUP_LOOP expr _for designator
|
forstmt ::= SETUP_LOOP expr _for designator
|
||||||
|
Reference in New Issue
Block a user