/src/cpython/Modules/clinic/_opcode.c.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
6 | | # include "pycore_gc.h" // PyGC_Head |
7 | | # include "pycore_runtime.h" // _Py_ID() |
8 | | #endif |
9 | | #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
10 | | |
11 | | PyDoc_STRVAR(_opcode_stack_effect__doc__, |
12 | | "stack_effect($module, opcode, oparg=None, /, *, jump=None)\n" |
13 | | "--\n" |
14 | | "\n" |
15 | | "Compute the stack effect of the opcode."); |
16 | | |
17 | | #define _OPCODE_STACK_EFFECT_METHODDEF \ |
18 | | {"stack_effect", _PyCFunction_CAST(_opcode_stack_effect), METH_FASTCALL|METH_KEYWORDS, _opcode_stack_effect__doc__}, |
19 | | |
20 | | static int |
21 | | _opcode_stack_effect_impl(PyObject *module, int opcode, PyObject *oparg, |
22 | | PyObject *jump); |
23 | | |
24 | | static PyObject * |
25 | | _opcode_stack_effect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
26 | 0 | { |
27 | 0 | PyObject *return_value = NULL; |
28 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
29 | |
|
30 | 0 | #define NUM_KEYWORDS 1 |
31 | 0 | static struct { |
32 | 0 | PyGC_Head _this_is_not_used; |
33 | 0 | PyObject_VAR_HEAD |
34 | 0 | Py_hash_t ob_hash; |
35 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
36 | 0 | } _kwtuple = { |
37 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
38 | 0 | .ob_hash = -1, |
39 | 0 | .ob_item = { &_Py_ID(jump), }, |
40 | 0 | }; |
41 | 0 | #undef NUM_KEYWORDS |
42 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
43 | |
|
44 | | #else // !Py_BUILD_CORE |
45 | | # define KWTUPLE NULL |
46 | | #endif // !Py_BUILD_CORE |
47 | |
|
48 | 0 | static const char * const _keywords[] = {"", "", "jump", NULL}; |
49 | 0 | static _PyArg_Parser _parser = { |
50 | 0 | .keywords = _keywords, |
51 | 0 | .fname = "stack_effect", |
52 | 0 | .kwtuple = KWTUPLE, |
53 | 0 | }; |
54 | 0 | #undef KWTUPLE |
55 | 0 | PyObject *argsbuf[3]; |
56 | 0 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
57 | 0 | int opcode; |
58 | 0 | PyObject *oparg = Py_None; |
59 | 0 | PyObject *jump = Py_None; |
60 | 0 | int _return_value; |
61 | |
|
62 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
63 | 0 | /*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
64 | 0 | if (!args) { |
65 | 0 | goto exit; |
66 | 0 | } |
67 | 0 | opcode = PyLong_AsInt(args[0]); |
68 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
69 | 0 | goto exit; |
70 | 0 | } |
71 | 0 | if (nargs < 2) { |
72 | 0 | goto skip_optional_posonly; |
73 | 0 | } |
74 | 0 | noptargs--; |
75 | 0 | oparg = args[1]; |
76 | 0 | skip_optional_posonly: |
77 | 0 | if (!noptargs) { |
78 | 0 | goto skip_optional_kwonly; |
79 | 0 | } |
80 | 0 | jump = args[2]; |
81 | 0 | skip_optional_kwonly: |
82 | 0 | _return_value = _opcode_stack_effect_impl(module, opcode, oparg, jump); |
83 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
84 | 0 | goto exit; |
85 | 0 | } |
86 | 0 | return_value = PyLong_FromLong((long)_return_value); |
87 | |
|
88 | 0 | exit: |
89 | 0 | return return_value; |
90 | 0 | } |
91 | | |
92 | | PyDoc_STRVAR(_opcode_is_valid__doc__, |
93 | | "is_valid($module, /, opcode)\n" |
94 | | "--\n" |
95 | | "\n" |
96 | | "Return True if opcode is valid, False otherwise."); |
97 | | |
98 | | #define _OPCODE_IS_VALID_METHODDEF \ |
99 | | {"is_valid", _PyCFunction_CAST(_opcode_is_valid), METH_FASTCALL|METH_KEYWORDS, _opcode_is_valid__doc__}, |
100 | | |
101 | | static int |
102 | | _opcode_is_valid_impl(PyObject *module, int opcode); |
103 | | |
104 | | static PyObject * |
105 | | _opcode_is_valid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
106 | 0 | { |
107 | 0 | PyObject *return_value = NULL; |
108 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
109 | |
|
110 | 0 | #define NUM_KEYWORDS 1 |
111 | 0 | static struct { |
112 | 0 | PyGC_Head _this_is_not_used; |
113 | 0 | PyObject_VAR_HEAD |
114 | 0 | Py_hash_t ob_hash; |
115 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
116 | 0 | } _kwtuple = { |
117 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
118 | 0 | .ob_hash = -1, |
119 | 0 | .ob_item = { &_Py_ID(opcode), }, |
120 | 0 | }; |
121 | 0 | #undef NUM_KEYWORDS |
122 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
123 | |
|
124 | | #else // !Py_BUILD_CORE |
125 | | # define KWTUPLE NULL |
126 | | #endif // !Py_BUILD_CORE |
127 | |
|
128 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
129 | 0 | static _PyArg_Parser _parser = { |
130 | 0 | .keywords = _keywords, |
131 | 0 | .fname = "is_valid", |
132 | 0 | .kwtuple = KWTUPLE, |
133 | 0 | }; |
134 | 0 | #undef KWTUPLE |
135 | 0 | PyObject *argsbuf[1]; |
136 | 0 | int opcode; |
137 | 0 | int _return_value; |
138 | |
|
139 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
140 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
141 | 0 | if (!args) { |
142 | 0 | goto exit; |
143 | 0 | } |
144 | 0 | opcode = PyLong_AsInt(args[0]); |
145 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
146 | 0 | goto exit; |
147 | 0 | } |
148 | 0 | _return_value = _opcode_is_valid_impl(module, opcode); |
149 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
150 | 0 | goto exit; |
151 | 0 | } |
152 | 0 | return_value = PyBool_FromLong((long)_return_value); |
153 | |
|
154 | 0 | exit: |
155 | 0 | return return_value; |
156 | 0 | } |
157 | | |
158 | | PyDoc_STRVAR(_opcode_has_arg__doc__, |
159 | | "has_arg($module, /, opcode)\n" |
160 | | "--\n" |
161 | | "\n" |
162 | | "Return True if the opcode uses its oparg, False otherwise."); |
163 | | |
164 | | #define _OPCODE_HAS_ARG_METHODDEF \ |
165 | | {"has_arg", _PyCFunction_CAST(_opcode_has_arg), METH_FASTCALL|METH_KEYWORDS, _opcode_has_arg__doc__}, |
166 | | |
167 | | static int |
168 | | _opcode_has_arg_impl(PyObject *module, int opcode); |
169 | | |
170 | | static PyObject * |
171 | | _opcode_has_arg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
172 | 0 | { |
173 | 0 | PyObject *return_value = NULL; |
174 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
175 | |
|
176 | 0 | #define NUM_KEYWORDS 1 |
177 | 0 | static struct { |
178 | 0 | PyGC_Head _this_is_not_used; |
179 | 0 | PyObject_VAR_HEAD |
180 | 0 | Py_hash_t ob_hash; |
181 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
182 | 0 | } _kwtuple = { |
183 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
184 | 0 | .ob_hash = -1, |
185 | 0 | .ob_item = { &_Py_ID(opcode), }, |
186 | 0 | }; |
187 | 0 | #undef NUM_KEYWORDS |
188 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
189 | |
|
190 | | #else // !Py_BUILD_CORE |
191 | | # define KWTUPLE NULL |
192 | | #endif // !Py_BUILD_CORE |
193 | |
|
194 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
195 | 0 | static _PyArg_Parser _parser = { |
196 | 0 | .keywords = _keywords, |
197 | 0 | .fname = "has_arg", |
198 | 0 | .kwtuple = KWTUPLE, |
199 | 0 | }; |
200 | 0 | #undef KWTUPLE |
201 | 0 | PyObject *argsbuf[1]; |
202 | 0 | int opcode; |
203 | 0 | int _return_value; |
204 | |
|
205 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
206 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
207 | 0 | if (!args) { |
208 | 0 | goto exit; |
209 | 0 | } |
210 | 0 | opcode = PyLong_AsInt(args[0]); |
211 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
212 | 0 | goto exit; |
213 | 0 | } |
214 | 0 | _return_value = _opcode_has_arg_impl(module, opcode); |
215 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
216 | 0 | goto exit; |
217 | 0 | } |
218 | 0 | return_value = PyBool_FromLong((long)_return_value); |
219 | |
|
220 | 0 | exit: |
221 | 0 | return return_value; |
222 | 0 | } |
223 | | |
224 | | PyDoc_STRVAR(_opcode_has_const__doc__, |
225 | | "has_const($module, /, opcode)\n" |
226 | | "--\n" |
227 | | "\n" |
228 | | "Return True if the opcode accesses a constant, False otherwise."); |
229 | | |
230 | | #define _OPCODE_HAS_CONST_METHODDEF \ |
231 | | {"has_const", _PyCFunction_CAST(_opcode_has_const), METH_FASTCALL|METH_KEYWORDS, _opcode_has_const__doc__}, |
232 | | |
233 | | static int |
234 | | _opcode_has_const_impl(PyObject *module, int opcode); |
235 | | |
236 | | static PyObject * |
237 | | _opcode_has_const(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
238 | 0 | { |
239 | 0 | PyObject *return_value = NULL; |
240 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
241 | |
|
242 | 0 | #define NUM_KEYWORDS 1 |
243 | 0 | static struct { |
244 | 0 | PyGC_Head _this_is_not_used; |
245 | 0 | PyObject_VAR_HEAD |
246 | 0 | Py_hash_t ob_hash; |
247 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
248 | 0 | } _kwtuple = { |
249 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
250 | 0 | .ob_hash = -1, |
251 | 0 | .ob_item = { &_Py_ID(opcode), }, |
252 | 0 | }; |
253 | 0 | #undef NUM_KEYWORDS |
254 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
255 | |
|
256 | | #else // !Py_BUILD_CORE |
257 | | # define KWTUPLE NULL |
258 | | #endif // !Py_BUILD_CORE |
259 | |
|
260 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
261 | 0 | static _PyArg_Parser _parser = { |
262 | 0 | .keywords = _keywords, |
263 | 0 | .fname = "has_const", |
264 | 0 | .kwtuple = KWTUPLE, |
265 | 0 | }; |
266 | 0 | #undef KWTUPLE |
267 | 0 | PyObject *argsbuf[1]; |
268 | 0 | int opcode; |
269 | 0 | int _return_value; |
270 | |
|
271 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
272 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
273 | 0 | if (!args) { |
274 | 0 | goto exit; |
275 | 0 | } |
276 | 0 | opcode = PyLong_AsInt(args[0]); |
277 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
278 | 0 | goto exit; |
279 | 0 | } |
280 | 0 | _return_value = _opcode_has_const_impl(module, opcode); |
281 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
282 | 0 | goto exit; |
283 | 0 | } |
284 | 0 | return_value = PyBool_FromLong((long)_return_value); |
285 | |
|
286 | 0 | exit: |
287 | 0 | return return_value; |
288 | 0 | } |
289 | | |
290 | | PyDoc_STRVAR(_opcode_has_name__doc__, |
291 | | "has_name($module, /, opcode)\n" |
292 | | "--\n" |
293 | | "\n" |
294 | | "Return True if the opcode accesses an attribute by name, False otherwise."); |
295 | | |
296 | | #define _OPCODE_HAS_NAME_METHODDEF \ |
297 | | {"has_name", _PyCFunction_CAST(_opcode_has_name), METH_FASTCALL|METH_KEYWORDS, _opcode_has_name__doc__}, |
298 | | |
299 | | static int |
300 | | _opcode_has_name_impl(PyObject *module, int opcode); |
301 | | |
302 | | static PyObject * |
303 | | _opcode_has_name(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
304 | 0 | { |
305 | 0 | PyObject *return_value = NULL; |
306 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
307 | |
|
308 | 0 | #define NUM_KEYWORDS 1 |
309 | 0 | static struct { |
310 | 0 | PyGC_Head _this_is_not_used; |
311 | 0 | PyObject_VAR_HEAD |
312 | 0 | Py_hash_t ob_hash; |
313 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
314 | 0 | } _kwtuple = { |
315 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
316 | 0 | .ob_hash = -1, |
317 | 0 | .ob_item = { &_Py_ID(opcode), }, |
318 | 0 | }; |
319 | 0 | #undef NUM_KEYWORDS |
320 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
321 | |
|
322 | | #else // !Py_BUILD_CORE |
323 | | # define KWTUPLE NULL |
324 | | #endif // !Py_BUILD_CORE |
325 | |
|
326 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
327 | 0 | static _PyArg_Parser _parser = { |
328 | 0 | .keywords = _keywords, |
329 | 0 | .fname = "has_name", |
330 | 0 | .kwtuple = KWTUPLE, |
331 | 0 | }; |
332 | 0 | #undef KWTUPLE |
333 | 0 | PyObject *argsbuf[1]; |
334 | 0 | int opcode; |
335 | 0 | int _return_value; |
336 | |
|
337 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
338 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
339 | 0 | if (!args) { |
340 | 0 | goto exit; |
341 | 0 | } |
342 | 0 | opcode = PyLong_AsInt(args[0]); |
343 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
344 | 0 | goto exit; |
345 | 0 | } |
346 | 0 | _return_value = _opcode_has_name_impl(module, opcode); |
347 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
348 | 0 | goto exit; |
349 | 0 | } |
350 | 0 | return_value = PyBool_FromLong((long)_return_value); |
351 | |
|
352 | 0 | exit: |
353 | 0 | return return_value; |
354 | 0 | } |
355 | | |
356 | | PyDoc_STRVAR(_opcode_has_jump__doc__, |
357 | | "has_jump($module, /, opcode)\n" |
358 | | "--\n" |
359 | | "\n" |
360 | | "Return True if the opcode has a jump target, False otherwise."); |
361 | | |
362 | | #define _OPCODE_HAS_JUMP_METHODDEF \ |
363 | | {"has_jump", _PyCFunction_CAST(_opcode_has_jump), METH_FASTCALL|METH_KEYWORDS, _opcode_has_jump__doc__}, |
364 | | |
365 | | static int |
366 | | _opcode_has_jump_impl(PyObject *module, int opcode); |
367 | | |
368 | | static PyObject * |
369 | | _opcode_has_jump(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
370 | 0 | { |
371 | 0 | PyObject *return_value = NULL; |
372 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
373 | |
|
374 | 0 | #define NUM_KEYWORDS 1 |
375 | 0 | static struct { |
376 | 0 | PyGC_Head _this_is_not_used; |
377 | 0 | PyObject_VAR_HEAD |
378 | 0 | Py_hash_t ob_hash; |
379 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
380 | 0 | } _kwtuple = { |
381 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
382 | 0 | .ob_hash = -1, |
383 | 0 | .ob_item = { &_Py_ID(opcode), }, |
384 | 0 | }; |
385 | 0 | #undef NUM_KEYWORDS |
386 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
387 | |
|
388 | | #else // !Py_BUILD_CORE |
389 | | # define KWTUPLE NULL |
390 | | #endif // !Py_BUILD_CORE |
391 | |
|
392 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
393 | 0 | static _PyArg_Parser _parser = { |
394 | 0 | .keywords = _keywords, |
395 | 0 | .fname = "has_jump", |
396 | 0 | .kwtuple = KWTUPLE, |
397 | 0 | }; |
398 | 0 | #undef KWTUPLE |
399 | 0 | PyObject *argsbuf[1]; |
400 | 0 | int opcode; |
401 | 0 | int _return_value; |
402 | |
|
403 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
404 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
405 | 0 | if (!args) { |
406 | 0 | goto exit; |
407 | 0 | } |
408 | 0 | opcode = PyLong_AsInt(args[0]); |
409 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
410 | 0 | goto exit; |
411 | 0 | } |
412 | 0 | _return_value = _opcode_has_jump_impl(module, opcode); |
413 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
414 | 0 | goto exit; |
415 | 0 | } |
416 | 0 | return_value = PyBool_FromLong((long)_return_value); |
417 | |
|
418 | 0 | exit: |
419 | 0 | return return_value; |
420 | 0 | } |
421 | | |
422 | | PyDoc_STRVAR(_opcode_has_free__doc__, |
423 | | "has_free($module, /, opcode)\n" |
424 | | "--\n" |
425 | | "\n" |
426 | | "Return True if the opcode accesses a free variable, False otherwise.\n" |
427 | | "\n" |
428 | | "Note that \'free\' in this context refers to names in the current scope\n" |
429 | | "that are referenced by inner scopes or names in outer scopes that are\n" |
430 | | "referenced from this scope. It does not include references to global\n" |
431 | | "or builtin scopes."); |
432 | | |
433 | | #define _OPCODE_HAS_FREE_METHODDEF \ |
434 | | {"has_free", _PyCFunction_CAST(_opcode_has_free), METH_FASTCALL|METH_KEYWORDS, _opcode_has_free__doc__}, |
435 | | |
436 | | static int |
437 | | _opcode_has_free_impl(PyObject *module, int opcode); |
438 | | |
439 | | static PyObject * |
440 | | _opcode_has_free(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
441 | 0 | { |
442 | 0 | PyObject *return_value = NULL; |
443 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
444 | |
|
445 | 0 | #define NUM_KEYWORDS 1 |
446 | 0 | static struct { |
447 | 0 | PyGC_Head _this_is_not_used; |
448 | 0 | PyObject_VAR_HEAD |
449 | 0 | Py_hash_t ob_hash; |
450 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
451 | 0 | } _kwtuple = { |
452 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
453 | 0 | .ob_hash = -1, |
454 | 0 | .ob_item = { &_Py_ID(opcode), }, |
455 | 0 | }; |
456 | 0 | #undef NUM_KEYWORDS |
457 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
458 | |
|
459 | | #else // !Py_BUILD_CORE |
460 | | # define KWTUPLE NULL |
461 | | #endif // !Py_BUILD_CORE |
462 | |
|
463 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
464 | 0 | static _PyArg_Parser _parser = { |
465 | 0 | .keywords = _keywords, |
466 | 0 | .fname = "has_free", |
467 | 0 | .kwtuple = KWTUPLE, |
468 | 0 | }; |
469 | 0 | #undef KWTUPLE |
470 | 0 | PyObject *argsbuf[1]; |
471 | 0 | int opcode; |
472 | 0 | int _return_value; |
473 | |
|
474 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
475 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
476 | 0 | if (!args) { |
477 | 0 | goto exit; |
478 | 0 | } |
479 | 0 | opcode = PyLong_AsInt(args[0]); |
480 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
481 | 0 | goto exit; |
482 | 0 | } |
483 | 0 | _return_value = _opcode_has_free_impl(module, opcode); |
484 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
485 | 0 | goto exit; |
486 | 0 | } |
487 | 0 | return_value = PyBool_FromLong((long)_return_value); |
488 | |
|
489 | 0 | exit: |
490 | 0 | return return_value; |
491 | 0 | } |
492 | | |
493 | | PyDoc_STRVAR(_opcode_has_local__doc__, |
494 | | "has_local($module, /, opcode)\n" |
495 | | "--\n" |
496 | | "\n" |
497 | | "Return True if the opcode accesses a local variable, False otherwise."); |
498 | | |
499 | | #define _OPCODE_HAS_LOCAL_METHODDEF \ |
500 | | {"has_local", _PyCFunction_CAST(_opcode_has_local), METH_FASTCALL|METH_KEYWORDS, _opcode_has_local__doc__}, |
501 | | |
502 | | static int |
503 | | _opcode_has_local_impl(PyObject *module, int opcode); |
504 | | |
505 | | static PyObject * |
506 | | _opcode_has_local(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
507 | 0 | { |
508 | 0 | PyObject *return_value = NULL; |
509 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
510 | |
|
511 | 0 | #define NUM_KEYWORDS 1 |
512 | 0 | static struct { |
513 | 0 | PyGC_Head _this_is_not_used; |
514 | 0 | PyObject_VAR_HEAD |
515 | 0 | Py_hash_t ob_hash; |
516 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
517 | 0 | } _kwtuple = { |
518 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
519 | 0 | .ob_hash = -1, |
520 | 0 | .ob_item = { &_Py_ID(opcode), }, |
521 | 0 | }; |
522 | 0 | #undef NUM_KEYWORDS |
523 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
524 | |
|
525 | | #else // !Py_BUILD_CORE |
526 | | # define KWTUPLE NULL |
527 | | #endif // !Py_BUILD_CORE |
528 | |
|
529 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
530 | 0 | static _PyArg_Parser _parser = { |
531 | 0 | .keywords = _keywords, |
532 | 0 | .fname = "has_local", |
533 | 0 | .kwtuple = KWTUPLE, |
534 | 0 | }; |
535 | 0 | #undef KWTUPLE |
536 | 0 | PyObject *argsbuf[1]; |
537 | 0 | int opcode; |
538 | 0 | int _return_value; |
539 | |
|
540 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
541 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
542 | 0 | if (!args) { |
543 | 0 | goto exit; |
544 | 0 | } |
545 | 0 | opcode = PyLong_AsInt(args[0]); |
546 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
547 | 0 | goto exit; |
548 | 0 | } |
549 | 0 | _return_value = _opcode_has_local_impl(module, opcode); |
550 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
551 | 0 | goto exit; |
552 | 0 | } |
553 | 0 | return_value = PyBool_FromLong((long)_return_value); |
554 | |
|
555 | 0 | exit: |
556 | 0 | return return_value; |
557 | 0 | } |
558 | | |
559 | | PyDoc_STRVAR(_opcode_has_exc__doc__, |
560 | | "has_exc($module, /, opcode)\n" |
561 | | "--\n" |
562 | | "\n" |
563 | | "Return True if the opcode sets an exception handler, False otherwise."); |
564 | | |
565 | | #define _OPCODE_HAS_EXC_METHODDEF \ |
566 | | {"has_exc", _PyCFunction_CAST(_opcode_has_exc), METH_FASTCALL|METH_KEYWORDS, _opcode_has_exc__doc__}, |
567 | | |
568 | | static int |
569 | | _opcode_has_exc_impl(PyObject *module, int opcode); |
570 | | |
571 | | static PyObject * |
572 | | _opcode_has_exc(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
573 | 0 | { |
574 | 0 | PyObject *return_value = NULL; |
575 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
576 | |
|
577 | 0 | #define NUM_KEYWORDS 1 |
578 | 0 | static struct { |
579 | 0 | PyGC_Head _this_is_not_used; |
580 | 0 | PyObject_VAR_HEAD |
581 | 0 | Py_hash_t ob_hash; |
582 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
583 | 0 | } _kwtuple = { |
584 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
585 | 0 | .ob_hash = -1, |
586 | 0 | .ob_item = { &_Py_ID(opcode), }, |
587 | 0 | }; |
588 | 0 | #undef NUM_KEYWORDS |
589 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
590 | |
|
591 | | #else // !Py_BUILD_CORE |
592 | | # define KWTUPLE NULL |
593 | | #endif // !Py_BUILD_CORE |
594 | |
|
595 | 0 | static const char * const _keywords[] = {"opcode", NULL}; |
596 | 0 | static _PyArg_Parser _parser = { |
597 | 0 | .keywords = _keywords, |
598 | 0 | .fname = "has_exc", |
599 | 0 | .kwtuple = KWTUPLE, |
600 | 0 | }; |
601 | 0 | #undef KWTUPLE |
602 | 0 | PyObject *argsbuf[1]; |
603 | 0 | int opcode; |
604 | 0 | int _return_value; |
605 | |
|
606 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
607 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
608 | 0 | if (!args) { |
609 | 0 | goto exit; |
610 | 0 | } |
611 | 0 | opcode = PyLong_AsInt(args[0]); |
612 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
613 | 0 | goto exit; |
614 | 0 | } |
615 | 0 | _return_value = _opcode_has_exc_impl(module, opcode); |
616 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
617 | 0 | goto exit; |
618 | 0 | } |
619 | 0 | return_value = PyBool_FromLong((long)_return_value); |
620 | |
|
621 | 0 | exit: |
622 | 0 | return return_value; |
623 | 0 | } |
624 | | |
625 | | PyDoc_STRVAR(_opcode_get_specialization_stats__doc__, |
626 | | "get_specialization_stats($module, /)\n" |
627 | | "--\n" |
628 | | "\n" |
629 | | "Return the specialization stats"); |
630 | | |
631 | | #define _OPCODE_GET_SPECIALIZATION_STATS_METHODDEF \ |
632 | | {"get_specialization_stats", (PyCFunction)_opcode_get_specialization_stats, METH_NOARGS, _opcode_get_specialization_stats__doc__}, |
633 | | |
634 | | static PyObject * |
635 | | _opcode_get_specialization_stats_impl(PyObject *module); |
636 | | |
637 | | static PyObject * |
638 | | _opcode_get_specialization_stats(PyObject *module, PyObject *Py_UNUSED(ignored)) |
639 | 0 | { |
640 | 0 | return _opcode_get_specialization_stats_impl(module); |
641 | 0 | } |
642 | | |
643 | | PyDoc_STRVAR(_opcode_get_nb_ops__doc__, |
644 | | "get_nb_ops($module, /)\n" |
645 | | "--\n" |
646 | | "\n" |
647 | | "Return array of symbols of binary ops.\n" |
648 | | "\n" |
649 | | "Indexed by the BINARY_OP oparg value."); |
650 | | |
651 | | #define _OPCODE_GET_NB_OPS_METHODDEF \ |
652 | | {"get_nb_ops", (PyCFunction)_opcode_get_nb_ops, METH_NOARGS, _opcode_get_nb_ops__doc__}, |
653 | | |
654 | | static PyObject * |
655 | | _opcode_get_nb_ops_impl(PyObject *module); |
656 | | |
657 | | static PyObject * |
658 | | _opcode_get_nb_ops(PyObject *module, PyObject *Py_UNUSED(ignored)) |
659 | 0 | { |
660 | 0 | return _opcode_get_nb_ops_impl(module); |
661 | 0 | } |
662 | | |
663 | | PyDoc_STRVAR(_opcode_get_intrinsic1_descs__doc__, |
664 | | "get_intrinsic1_descs($module, /)\n" |
665 | | "--\n" |
666 | | "\n" |
667 | | "Return a list of names of the unary intrinsics."); |
668 | | |
669 | | #define _OPCODE_GET_INTRINSIC1_DESCS_METHODDEF \ |
670 | | {"get_intrinsic1_descs", (PyCFunction)_opcode_get_intrinsic1_descs, METH_NOARGS, _opcode_get_intrinsic1_descs__doc__}, |
671 | | |
672 | | static PyObject * |
673 | | _opcode_get_intrinsic1_descs_impl(PyObject *module); |
674 | | |
675 | | static PyObject * |
676 | | _opcode_get_intrinsic1_descs(PyObject *module, PyObject *Py_UNUSED(ignored)) |
677 | 0 | { |
678 | 0 | return _opcode_get_intrinsic1_descs_impl(module); |
679 | 0 | } |
680 | | |
681 | | PyDoc_STRVAR(_opcode_get_intrinsic2_descs__doc__, |
682 | | "get_intrinsic2_descs($module, /)\n" |
683 | | "--\n" |
684 | | "\n" |
685 | | "Return a list of names of the binary intrinsics."); |
686 | | |
687 | | #define _OPCODE_GET_INTRINSIC2_DESCS_METHODDEF \ |
688 | | {"get_intrinsic2_descs", (PyCFunction)_opcode_get_intrinsic2_descs, METH_NOARGS, _opcode_get_intrinsic2_descs__doc__}, |
689 | | |
690 | | static PyObject * |
691 | | _opcode_get_intrinsic2_descs_impl(PyObject *module); |
692 | | |
693 | | static PyObject * |
694 | | _opcode_get_intrinsic2_descs(PyObject *module, PyObject *Py_UNUSED(ignored)) |
695 | 0 | { |
696 | 0 | return _opcode_get_intrinsic2_descs_impl(module); |
697 | 0 | } |
698 | | |
699 | | PyDoc_STRVAR(_opcode_get_special_method_names__doc__, |
700 | | "get_special_method_names($module, /)\n" |
701 | | "--\n" |
702 | | "\n" |
703 | | "Return a list of special method names."); |
704 | | |
705 | | #define _OPCODE_GET_SPECIAL_METHOD_NAMES_METHODDEF \ |
706 | | {"get_special_method_names", (PyCFunction)_opcode_get_special_method_names, METH_NOARGS, _opcode_get_special_method_names__doc__}, |
707 | | |
708 | | static PyObject * |
709 | | _opcode_get_special_method_names_impl(PyObject *module); |
710 | | |
711 | | static PyObject * |
712 | | _opcode_get_special_method_names(PyObject *module, PyObject *Py_UNUSED(ignored)) |
713 | 0 | { |
714 | 0 | return _opcode_get_special_method_names_impl(module); |
715 | 0 | } |
716 | | |
717 | | PyDoc_STRVAR(_opcode_get_executor__doc__, |
718 | | "get_executor($module, /, code, offset)\n" |
719 | | "--\n" |
720 | | "\n" |
721 | | "Return the executor object at offset in code if exists, None otherwise."); |
722 | | |
723 | | #define _OPCODE_GET_EXECUTOR_METHODDEF \ |
724 | | {"get_executor", _PyCFunction_CAST(_opcode_get_executor), METH_FASTCALL|METH_KEYWORDS, _opcode_get_executor__doc__}, |
725 | | |
726 | | static PyObject * |
727 | | _opcode_get_executor_impl(PyObject *module, PyObject *code, int offset); |
728 | | |
729 | | static PyObject * |
730 | | _opcode_get_executor(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
731 | 0 | { |
732 | 0 | PyObject *return_value = NULL; |
733 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
734 | |
|
735 | 0 | #define NUM_KEYWORDS 2 |
736 | 0 | static struct { |
737 | 0 | PyGC_Head _this_is_not_used; |
738 | 0 | PyObject_VAR_HEAD |
739 | 0 | Py_hash_t ob_hash; |
740 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
741 | 0 | } _kwtuple = { |
742 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
743 | 0 | .ob_hash = -1, |
744 | 0 | .ob_item = { &_Py_ID(code), &_Py_ID(offset), }, |
745 | 0 | }; |
746 | 0 | #undef NUM_KEYWORDS |
747 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
748 | |
|
749 | | #else // !Py_BUILD_CORE |
750 | | # define KWTUPLE NULL |
751 | | #endif // !Py_BUILD_CORE |
752 | |
|
753 | 0 | static const char * const _keywords[] = {"code", "offset", NULL}; |
754 | 0 | static _PyArg_Parser _parser = { |
755 | 0 | .keywords = _keywords, |
756 | 0 | .fname = "get_executor", |
757 | 0 | .kwtuple = KWTUPLE, |
758 | 0 | }; |
759 | 0 | #undef KWTUPLE |
760 | 0 | PyObject *argsbuf[2]; |
761 | 0 | PyObject *code; |
762 | 0 | int offset; |
763 | |
|
764 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
765 | 0 | /*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
766 | 0 | if (!args) { |
767 | 0 | goto exit; |
768 | 0 | } |
769 | 0 | code = args[0]; |
770 | 0 | offset = PyLong_AsInt(args[1]); |
771 | 0 | if (offset == -1 && PyErr_Occurred()) { |
772 | 0 | goto exit; |
773 | 0 | } |
774 | 0 | return_value = _opcode_get_executor_impl(module, code, offset); |
775 | |
|
776 | 0 | exit: |
777 | 0 | return return_value; |
778 | 0 | } |
779 | | /*[clinic end generated code: output=a11f02989c3175d7 input=a9049054013a1b77]*/ |