1# (C) Copyright 2017, 2021 by Rocky Bernstein
2"""
3CPython 2.5 bytecode opcodes
4
5This is a like Python 2.5's opcode.py with some additional classification
6of stack usage, and opererand formatting functions.
7"""
8
9import xdis.opcodes.opcode_24 as opcode_24
10from xdis.opcodes.base import (
11    def_op,
12    extended_format_ATTR,
13    extended_format_CALL_FUNCTION,
14    extended_format_MAKE_FUNCTION_older,
15    extended_format_RAISE_VARARGS_older,
16    extended_format_RETURN_VALUE,
17    finalize_opcodes,
18    format_CALL_FUNCTION_pos_name_encoded,
19    format_MAKE_FUNCTION_default_argc,
20    format_RAISE_VARARGS_older,
21    format_extended_arg,
22    init_opdata,
23    update_pj2,
24)
25
26version = 2.5
27python_implementation = "CPython"
28
29l = locals()
30init_opdata(l, opcode_24, version)
31
32# fmt: off
33# Bytecodes added in 2.5 from 2.4
34#          OP NAME            OPCODE POP PUSH
35#--------------------------------------------
36def_op(l, 'WITH_CLEANUP',      81,   4,  3)
37# fmt: on
38
39# FIXME remove (fix uncompyle6)
40update_pj2(globals(), l)
41
42opcode_arg_fmt = {
43    "CALL_FUNCTION": format_CALL_FUNCTION_pos_name_encoded,
44    "CALL_FUNCTION_KW": format_CALL_FUNCTION_pos_name_encoded,
45    "CALL_FUNCTION_VAR_KW": format_CALL_FUNCTION_pos_name_encoded,
46    "EXTENDED_ARG": format_extended_arg,
47    "MAKE_FUNCTION": format_MAKE_FUNCTION_default_argc,
48    "RAISE_VARARGS": format_RAISE_VARARGS_older,
49}
50
51opcode_extended_fmt = {
52    "CALL_FUNCTION": extended_format_CALL_FUNCTION,
53    "LOAD_ATTR": extended_format_ATTR,
54    "MAKE_FUNCTION": extended_format_MAKE_FUNCTION_older,
55    "RAISE_VARARGS": extended_format_RAISE_VARARGS_older,
56    "RETURN_VALUE": extended_format_RETURN_VALUE,
57    "STORE_ATTR": extended_format_ATTR,
58}
59finalize_opcodes(l)
60