1# (C) Copyright 2019-2021 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.1 and 1.2 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_13 as opcode_13
27from xdis.opcodes.base import (
28    extended_format_CALL_FUNCTION,
29    extended_format_RAISE_VARARGS_older,
30    extended_format_RETURN_VALUE,
31    format_RAISE_VARARGS_older,
32    init_opdata,
33    finalize_opcodes,
34    format_extended_arg,
35    # Although these aren't used here, they are exported
36    update_pj2,
37)
38
39version = 1.1  # 1.2 is the same
40python_implementation = "CPython"
41
42l = locals()
43init_opdata(l, opcode_13, version)
44
45update_pj2(globals(), l)
46
47opcode_arg_fmt = {
48    "EXTENDED_ARG": format_extended_arg,
49    "RAISE_VARARGS": format_RAISE_VARARGS_older,
50}
51
52finalize_opcodes(l)
53
54opcode_extended_fmt = {
55    "CALL_FUNCTION": extended_format_CALL_FUNCTION,
56    "RAISE_VARARGS": extended_format_RAISE_VARARGS_older,
57    "RETURN_VALUE": extended_format_RETURN_VALUE,
58}
59
60findlinestarts = opcode_13.findlinestarts
61