1# (C) Copyright 2017, 2019 by Rocky Bernstein
2#
3#  This program is free software; you can redistribute it and/or
4#  modify it under the terms of the GNU General Public License
5#  as published by the Free Software Foundation; either version 2
6#  of the License, or (at your option) any later version.
7#
8#  This program is distributed in the hope that it will be useful,
9#  but WITHOUT ANY WARRANTY; without even the implied warranty of
10#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11#  GNU General Public License for more details.
12#
13#  You should have received a copy of the GNU General Public License
14#  along with this program; if not, write to the Free Software
15#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16"""
17CPython 2.1 bytecode opcodes
18
19This is similar to the opcode portion in Python 2.1's dis.py library.
20"""
21
22import xdis.opcodes.opcode_22 as opcode_22
23from xdis.opcodes.base import (
24    extended_format_ATTR,
25    extended_format_MAKE_FUNCTION_older,
26    extended_format_RETURN_VALUE,
27    finalize_opcodes,
28    format_extended_arg,
29    init_opdata,
30    rm_op,
31    update_pj2,
32)
33
34version = 2.1
35python_implementation = "CPython"
36
37l = locals()
38init_opdata(l, opcode_22, version)
39
40# 2.1 bytecodes changes from 2.2
41rm_op(l, "BINARY_FLOOR_DIVIDE", 26)
42rm_op(l, "BINARY_TRUE_DIVIDE", 27)
43rm_op(l, "INPLACE_FLOOR_DIVIDE", 28)
44rm_op(l, "INPLACE_TRUE_DIVIDE", 29)
45rm_op(l, "GET_ITER", 68)
46rm_op(l, "YIELD_VALUE", 86)
47rm_op(l, "FOR_ITER", 93)
48
49update_pj2(globals(), l)
50
51finalize_opcodes(l)
52
53opcode_arg_fmt = {
54    "EXTENDED_ARG": format_extended_arg
55}
56
57opcode_extended_fmt = {
58    "LOAD_ATTR": extended_format_ATTR,
59    "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older,
60    "RETURN_VALUE": extended_format_RETURN_VALUE,
61    "STORE_ATTR": extended_format_ATTR,
62}
63