1# (C) Copyright 2018-2020 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 1.3 bytecode opcodes
18
19This is used in bytecode disassembly. This is similar to the
20opcodes in Python's dis.py library.
21"""
22
23# This is used from outside this module
24from xdis.cross_dis import findlabels
25
26import xdis.opcodes.opcode_14 as opcode_14
27from xdis.opcodes.base import (
28    def_op,
29    extended_format_RAISE_VARARGS_older,
30    extended_format_RETURN_VALUE,
31    finalize_opcodes,
32    format_RAISE_VARARGS_older,
33    format_extended_arg,
34    init_opdata,
35    rm_op,
36    # Although these aren't used here, they are exported
37    update_pj2,
38)
39
40version = 1.3
41python_implementation = "CPython"
42
43l = locals()
44init_opdata(l, opcode_14, version)
45
46# 1.3 - 1.4 bytecodes differences
47rm_op(l, "BINARY_POWER", 19)
48def_op(l, "LOAD_GLOBALS", 84)
49
50update_pj2(globals(), l)
51
52opcode_arg_fmt = {
53    "EXTENDED_ARG": format_extended_arg,
54    "RAISE_VARARGS": format_RAISE_VARARGS_older,
55}
56
57finalize_opcodes(l)
58
59opcode_extended_fmt = {
60    "RAISE_VARARGS": extended_format_RAISE_VARARGS_older,
61    "RETURN_VALUE": extended_format_RETURN_VALUE,
62}
63
64findlinestarts = opcode_14.findlinestarts
65