ยปCore Development>Code coverage>Modules/_opcode.c

Python code coverage for Modules/_opcode.c

#countcontent
1n/a#include "Python.h"
2n/a#include "opcode.h"
3n/a
4n/a/*[clinic input]
5n/amodule _opcode
6n/a[clinic start generated code]*/
7n/a/*[clinic end generated code: output=da39a3ee5e6b4b0d input=117442e66eb376e6]*/
8n/a
9n/a#include "clinic/_opcode.c.h"
10n/a
11n/a/*[clinic input]
12n/a
13n/a_opcode.stack_effect -> int
14n/a
15n/a opcode: int
16n/a oparg: object = None
17n/a /
18n/a
19n/aCompute the stack effect of the opcode.
20n/a[clinic start generated code]*/
21n/a
22n/astatic int
23n/a_opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg)
24n/a/*[clinic end generated code: output=ad39467fa3ad22ce input=2d0a9ee53c0418f5]*/
25n/a{
26n/a int effect;
27n/a int oparg_int = 0;
28n/a if (HAS_ARG(opcode)) {
29n/a if (oparg == Py_None) {
30n/a PyErr_SetString(PyExc_ValueError,
31n/a "stack_effect: opcode requires oparg but oparg was not specified");
32n/a return -1;
33n/a }
34n/a oparg_int = (int)PyLong_AsLong(oparg);
35n/a if ((oparg_int == -1) && PyErr_Occurred())
36n/a return -1;
37n/a }
38n/a else if (oparg != Py_None) {
39n/a PyErr_SetString(PyExc_ValueError,
40n/a "stack_effect: opcode does not permit oparg but oparg was specified");
41n/a return -1;
42n/a }
43n/a effect = PyCompile_OpcodeStackEffect(opcode, oparg_int);
44n/a if (effect == PY_INVALID_STACK_EFFECT) {
45n/a PyErr_SetString(PyExc_ValueError,
46n/a "invalid opcode or oparg");
47n/a return -1;
48n/a }
49n/a return effect;
50n/a}
51n/a
52n/a
53n/a
54n/a
55n/astatic PyMethodDef
56n/aopcode_functions[] = {
57n/a _OPCODE_STACK_EFFECT_METHODDEF
58n/a {NULL, NULL, 0, NULL}
59n/a};
60n/a
61n/a
62n/astatic struct PyModuleDef opcodemodule = {
63n/a PyModuleDef_HEAD_INIT,
64n/a "_opcode",
65n/a "Opcode support module.",
66n/a -1,
67n/a opcode_functions,
68n/a NULL,
69n/a NULL,
70n/a NULL,
71n/a NULL
72n/a};
73n/a
74n/aPyMODINIT_FUNC
75n/aPyInit__opcode(void)
76n/a{
77n/a return PyModule_Create(&opcodemodule);
78n/a}