| 21 | |
| 22 | |
| 23 | class Scanner27(Scanner2): |
| 24 | def __init__(self, show_asm=False, is_pypy=False): |
| 25 | super(Scanner27, self).__init__((2, 7), show_asm, is_pypy) |
| 26 | |
| 27 | # opcodes that start statements |
| 28 | self.statement_opcodes = frozenset( |
| 29 | self.statement_opcodes |
| 30 | | set( |
| 31 | [ |
| 32 | # New in 2.7 |
| 33 | self.opc.SETUP_WITH, |
| 34 | self.opc.STORE_SLICE_0, |
| 35 | self.opc.STORE_SLICE_1, |
| 36 | self.opc.STORE_SLICE_2, |
| 37 | self.opc.STORE_SLICE_3, |
| 38 | self.opc.DELETE_SLICE_0, |
| 39 | self.opc.DELETE_SLICE_1, |
| 40 | self.opc.DELETE_SLICE_2, |
| 41 | self.opc.DELETE_SLICE_3, |
| 42 | ] |
| 43 | ) |
| 44 | ) |
| 45 | |
| 46 | # opcodes which expect a variable number pushed values and whose |
| 47 | # count is in the opcode. For parsing we generally change the |
| 48 | # opcode name to include that number. |
| 49 | varargs_ops = set( |
| 50 | [ |
| 51 | self.opc.BUILD_LIST, |
| 52 | self.opc.BUILD_TUPLE, |
| 53 | self.opc.BUILD_SLICE, |
| 54 | self.opc.UNPACK_SEQUENCE, |
| 55 | self.opc.MAKE_FUNCTION, |
| 56 | self.opc.CALL_FUNCTION, |
| 57 | self.opc.MAKE_CLOSURE, |
| 58 | self.opc.CALL_FUNCTION_VAR, |
| 59 | self.opc.CALL_FUNCTION_KW, |
| 60 | self.opc.CALL_FUNCTION_VAR_KW, |
| 61 | self.opc.DUP_TOPX, |
| 62 | self.opc.RAISE_VARARGS, |
| 63 | # New in Python 2.7 |
| 64 | self.opc.BUILD_SET, |
| 65 | self.opc.BUILD_MAP, |
| 66 | ] |
| 67 | ) |
| 68 | |
| 69 | if is_pypy: |
| 70 | varargs_ops.add(self.opc.CALL_METHOD) |
| 71 | self.varargs_ops = frozenset(varargs_ops) |
| 72 | |
| 73 | # "setup" opcodes |
| 74 | self.setup_ops = frozenset( |
| 75 | [ |
| 76 | self.opc.SETUP_EXCEPT, |
| 77 | self.opc.SETUP_FINALLY, |
| 78 | # New in 2.7 |
| 79 | self.opc.SETUP_WITH, |
| 80 | ] |