• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(_opcode_stack_effect__doc__,
6 "stack_effect($module, opcode, oparg=None, /, *, jump=None)\n"
7 "--\n"
8 "\n"
9 "Compute the stack effect of the opcode.");
10 
11 #define _OPCODE_STACK_EFFECT_METHODDEF    \
12     {"stack_effect", (PyCFunction)(void(*)(void))_opcode_stack_effect, METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__},
13 
14 static int
15 _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg,
16                           PyObject *jump);
17 
18 static PyObject *
_opcode_stack_effect(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)19 _opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
20 {
21     PyObject *return_value = NULL;
22     static const char * const _keywords[] = {"", "", "jump", NULL};
23     static _PyArg_Parser _parser = {NULL, _keywords, "stack_effect", 0};
24     PyObject *argsbuf[3];
25     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
26     int opcode;
27     PyObject *oparg = Py_None;
28     PyObject *jump = Py_None;
29     int _return_value;
30 
31     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
32     if (!args) {
33         goto exit;
34     }
35     if (PyFloat_Check(args[0])) {
36         PyErr_SetString(PyExc_TypeError,
37                         "integer argument expected, got float" );
38         goto exit;
39     }
40     opcode = _PyLong_AsInt(args[0]);
41     if (opcode == -1 && PyErr_Occurred()) {
42         goto exit;
43     }
44     if (nargs < 2) {
45         goto skip_optional_posonly;
46     }
47     noptargs--;
48     oparg = args[1];
49 skip_optional_posonly:
50     if (!noptargs) {
51         goto skip_optional_kwonly;
52     }
53     jump = args[2];
54 skip_optional_kwonly:
55     _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump);
56     if ((_return_value == -1) && PyErr_Occurred()) {
57         goto exit;
58     }
59     return_value = PyLong_FromLong((long)_return_value);
60 
61 exit:
62     return return_value;
63 }
64 /*[clinic end generated code: output=7bc08f2835b2cf89 input=a9049054013a1b77]*/
65