/src/cpython/Python/clinic/instruction_sequence.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_NoKeywords() |
10 | | |
11 | | PyDoc_STRVAR(inst_seq_new__doc__, |
12 | | "InstructionSequenceType()\n" |
13 | | "--\n" |
14 | | "\n" |
15 | | "Create a new InstructionSequence object."); |
16 | | |
17 | | static PyObject * |
18 | | inst_seq_new_impl(PyTypeObject *type); |
19 | | |
20 | | static PyObject * |
21 | | inst_seq_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
22 | 0 | { |
23 | 0 | PyObject *return_value = NULL; |
24 | 0 | PyTypeObject *base_tp = &_PyInstructionSequence_Type; |
25 | |
|
26 | 0 | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
27 | 0 | !_PyArg_NoPositional("InstructionSequenceType", args)) { |
28 | 0 | goto exit; |
29 | 0 | } |
30 | 0 | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
31 | 0 | !_PyArg_NoKeywords("InstructionSequenceType", kwargs)) { |
32 | 0 | goto exit; |
33 | 0 | } |
34 | 0 | return_value = inst_seq_new_impl(type); |
35 | |
|
36 | 0 | exit: |
37 | 0 | return return_value; |
38 | 0 | } |
39 | | |
40 | | PyDoc_STRVAR(InstructionSequenceType_use_label__doc__, |
41 | | "use_label($self, /, label)\n" |
42 | | "--\n" |
43 | | "\n" |
44 | | "Place label at current location."); |
45 | | |
46 | | #define INSTRUCTIONSEQUENCETYPE_USE_LABEL_METHODDEF \ |
47 | | {"use_label", _PyCFunction_CAST(InstructionSequenceType_use_label), METH_FASTCALL|METH_KEYWORDS, InstructionSequenceType_use_label__doc__}, |
48 | | |
49 | | static PyObject * |
50 | | InstructionSequenceType_use_label_impl(_PyInstructionSequence *self, |
51 | | int label); |
52 | | |
53 | | static PyObject * |
54 | | InstructionSequenceType_use_label(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
55 | 0 | { |
56 | 0 | PyObject *return_value = NULL; |
57 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
58 | |
|
59 | 0 | #define NUM_KEYWORDS 1 |
60 | 0 | static struct { |
61 | 0 | PyGC_Head _this_is_not_used; |
62 | 0 | PyObject_VAR_HEAD |
63 | 0 | Py_hash_t ob_hash; |
64 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
65 | 0 | } _kwtuple = { |
66 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
67 | 0 | .ob_hash = -1, |
68 | 0 | .ob_item = { &_Py_ID(label), }, |
69 | 0 | }; |
70 | 0 | #undef NUM_KEYWORDS |
71 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
72 | |
|
73 | | #else // !Py_BUILD_CORE |
74 | | # define KWTUPLE NULL |
75 | | #endif // !Py_BUILD_CORE |
76 | |
|
77 | 0 | static const char * const _keywords[] = {"label", NULL}; |
78 | 0 | static _PyArg_Parser _parser = { |
79 | 0 | .keywords = _keywords, |
80 | 0 | .fname = "use_label", |
81 | 0 | .kwtuple = KWTUPLE, |
82 | 0 | }; |
83 | 0 | #undef KWTUPLE |
84 | 0 | PyObject *argsbuf[1]; |
85 | 0 | int label; |
86 | |
|
87 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
88 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
89 | 0 | if (!args) { |
90 | 0 | goto exit; |
91 | 0 | } |
92 | 0 | label = PyLong_AsInt(args[0]); |
93 | 0 | if (label == -1 && PyErr_Occurred()) { |
94 | 0 | goto exit; |
95 | 0 | } |
96 | 0 | return_value = InstructionSequenceType_use_label_impl((_PyInstructionSequence *)self, label); |
97 | |
|
98 | 0 | exit: |
99 | 0 | return return_value; |
100 | 0 | } |
101 | | |
102 | | PyDoc_STRVAR(InstructionSequenceType_addop__doc__, |
103 | | "addop($self, /, opcode, oparg, lineno, col_offset, end_lineno,\n" |
104 | | " end_col_offset)\n" |
105 | | "--\n" |
106 | | "\n" |
107 | | "Append an instruction."); |
108 | | |
109 | | #define INSTRUCTIONSEQUENCETYPE_ADDOP_METHODDEF \ |
110 | | {"addop", _PyCFunction_CAST(InstructionSequenceType_addop), METH_FASTCALL|METH_KEYWORDS, InstructionSequenceType_addop__doc__}, |
111 | | |
112 | | static PyObject * |
113 | | InstructionSequenceType_addop_impl(_PyInstructionSequence *self, int opcode, |
114 | | int oparg, int lineno, int col_offset, |
115 | | int end_lineno, int end_col_offset); |
116 | | |
117 | | static PyObject * |
118 | | InstructionSequenceType_addop(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
119 | 0 | { |
120 | 0 | PyObject *return_value = NULL; |
121 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
122 | |
|
123 | 0 | #define NUM_KEYWORDS 6 |
124 | 0 | static struct { |
125 | 0 | PyGC_Head _this_is_not_used; |
126 | 0 | PyObject_VAR_HEAD |
127 | 0 | Py_hash_t ob_hash; |
128 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
129 | 0 | } _kwtuple = { |
130 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
131 | 0 | .ob_hash = -1, |
132 | 0 | .ob_item = { &_Py_ID(opcode), &_Py_ID(oparg), &_Py_ID(lineno), &_Py_ID(col_offset), &_Py_ID(end_lineno), &_Py_ID(end_col_offset), }, |
133 | 0 | }; |
134 | 0 | #undef NUM_KEYWORDS |
135 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
136 | |
|
137 | | #else // !Py_BUILD_CORE |
138 | | # define KWTUPLE NULL |
139 | | #endif // !Py_BUILD_CORE |
140 | |
|
141 | 0 | static const char * const _keywords[] = {"opcode", "oparg", "lineno", "col_offset", "end_lineno", "end_col_offset", NULL}; |
142 | 0 | static _PyArg_Parser _parser = { |
143 | 0 | .keywords = _keywords, |
144 | 0 | .fname = "addop", |
145 | 0 | .kwtuple = KWTUPLE, |
146 | 0 | }; |
147 | 0 | #undef KWTUPLE |
148 | 0 | PyObject *argsbuf[6]; |
149 | 0 | int opcode; |
150 | 0 | int oparg; |
151 | 0 | int lineno; |
152 | 0 | int col_offset; |
153 | 0 | int end_lineno; |
154 | 0 | int end_col_offset; |
155 | |
|
156 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
157 | 0 | /*minpos*/ 6, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
158 | 0 | if (!args) { |
159 | 0 | goto exit; |
160 | 0 | } |
161 | 0 | opcode = PyLong_AsInt(args[0]); |
162 | 0 | if (opcode == -1 && PyErr_Occurred()) { |
163 | 0 | goto exit; |
164 | 0 | } |
165 | 0 | oparg = PyLong_AsInt(args[1]); |
166 | 0 | if (oparg == -1 && PyErr_Occurred()) { |
167 | 0 | goto exit; |
168 | 0 | } |
169 | 0 | lineno = PyLong_AsInt(args[2]); |
170 | 0 | if (lineno == -1 && PyErr_Occurred()) { |
171 | 0 | goto exit; |
172 | 0 | } |
173 | 0 | col_offset = PyLong_AsInt(args[3]); |
174 | 0 | if (col_offset == -1 && PyErr_Occurred()) { |
175 | 0 | goto exit; |
176 | 0 | } |
177 | 0 | end_lineno = PyLong_AsInt(args[4]); |
178 | 0 | if (end_lineno == -1 && PyErr_Occurred()) { |
179 | 0 | goto exit; |
180 | 0 | } |
181 | 0 | end_col_offset = PyLong_AsInt(args[5]); |
182 | 0 | if (end_col_offset == -1 && PyErr_Occurred()) { |
183 | 0 | goto exit; |
184 | 0 | } |
185 | 0 | return_value = InstructionSequenceType_addop_impl((_PyInstructionSequence *)self, opcode, oparg, lineno, col_offset, end_lineno, end_col_offset); |
186 | |
|
187 | 0 | exit: |
188 | 0 | return return_value; |
189 | 0 | } |
190 | | |
191 | | PyDoc_STRVAR(InstructionSequenceType_new_label__doc__, |
192 | | "new_label($self, /)\n" |
193 | | "--\n" |
194 | | "\n" |
195 | | "Return a new label."); |
196 | | |
197 | | #define INSTRUCTIONSEQUENCETYPE_NEW_LABEL_METHODDEF \ |
198 | | {"new_label", (PyCFunction)InstructionSequenceType_new_label, METH_NOARGS, InstructionSequenceType_new_label__doc__}, |
199 | | |
200 | | static int |
201 | | InstructionSequenceType_new_label_impl(_PyInstructionSequence *self); |
202 | | |
203 | | static PyObject * |
204 | | InstructionSequenceType_new_label(PyObject *self, PyObject *Py_UNUSED(ignored)) |
205 | 0 | { |
206 | 0 | PyObject *return_value = NULL; |
207 | 0 | int _return_value; |
208 | |
|
209 | 0 | _return_value = InstructionSequenceType_new_label_impl((_PyInstructionSequence *)self); |
210 | 0 | if ((_return_value == -1) && PyErr_Occurred()) { |
211 | 0 | goto exit; |
212 | 0 | } |
213 | 0 | return_value = PyLong_FromLong((long)_return_value); |
214 | |
|
215 | 0 | exit: |
216 | 0 | return return_value; |
217 | 0 | } |
218 | | |
219 | | PyDoc_STRVAR(InstructionSequenceType_add_nested__doc__, |
220 | | "add_nested($self, /, nested)\n" |
221 | | "--\n" |
222 | | "\n" |
223 | | "Add a nested sequence."); |
224 | | |
225 | | #define INSTRUCTIONSEQUENCETYPE_ADD_NESTED_METHODDEF \ |
226 | | {"add_nested", _PyCFunction_CAST(InstructionSequenceType_add_nested), METH_FASTCALL|METH_KEYWORDS, InstructionSequenceType_add_nested__doc__}, |
227 | | |
228 | | static PyObject * |
229 | | InstructionSequenceType_add_nested_impl(_PyInstructionSequence *self, |
230 | | PyObject *nested); |
231 | | |
232 | | static PyObject * |
233 | | InstructionSequenceType_add_nested(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
234 | 0 | { |
235 | 0 | PyObject *return_value = NULL; |
236 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
237 | |
|
238 | 0 | #define NUM_KEYWORDS 1 |
239 | 0 | static struct { |
240 | 0 | PyGC_Head _this_is_not_used; |
241 | 0 | PyObject_VAR_HEAD |
242 | 0 | Py_hash_t ob_hash; |
243 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
244 | 0 | } _kwtuple = { |
245 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
246 | 0 | .ob_hash = -1, |
247 | 0 | .ob_item = { &_Py_ID(nested), }, |
248 | 0 | }; |
249 | 0 | #undef NUM_KEYWORDS |
250 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
251 | |
|
252 | | #else // !Py_BUILD_CORE |
253 | | # define KWTUPLE NULL |
254 | | #endif // !Py_BUILD_CORE |
255 | |
|
256 | 0 | static const char * const _keywords[] = {"nested", NULL}; |
257 | 0 | static _PyArg_Parser _parser = { |
258 | 0 | .keywords = _keywords, |
259 | 0 | .fname = "add_nested", |
260 | 0 | .kwtuple = KWTUPLE, |
261 | 0 | }; |
262 | 0 | #undef KWTUPLE |
263 | 0 | PyObject *argsbuf[1]; |
264 | 0 | PyObject *nested; |
265 | |
|
266 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
267 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
268 | 0 | if (!args) { |
269 | 0 | goto exit; |
270 | 0 | } |
271 | 0 | nested = args[0]; |
272 | 0 | return_value = InstructionSequenceType_add_nested_impl((_PyInstructionSequence *)self, nested); |
273 | |
|
274 | 0 | exit: |
275 | 0 | return return_value; |
276 | 0 | } |
277 | | |
278 | | PyDoc_STRVAR(InstructionSequenceType_get_nested__doc__, |
279 | | "get_nested($self, /)\n" |
280 | | "--\n" |
281 | | "\n" |
282 | | "Add a nested sequence."); |
283 | | |
284 | | #define INSTRUCTIONSEQUENCETYPE_GET_NESTED_METHODDEF \ |
285 | | {"get_nested", (PyCFunction)InstructionSequenceType_get_nested, METH_NOARGS, InstructionSequenceType_get_nested__doc__}, |
286 | | |
287 | | static PyObject * |
288 | | InstructionSequenceType_get_nested_impl(_PyInstructionSequence *self); |
289 | | |
290 | | static PyObject * |
291 | | InstructionSequenceType_get_nested(PyObject *self, PyObject *Py_UNUSED(ignored)) |
292 | 0 | { |
293 | 0 | return InstructionSequenceType_get_nested_impl((_PyInstructionSequence *)self); |
294 | 0 | } |
295 | | |
296 | | PyDoc_STRVAR(InstructionSequenceType_get_instructions__doc__, |
297 | | "get_instructions($self, /)\n" |
298 | | "--\n" |
299 | | "\n" |
300 | | "Return the instructions as a list of tuples or labels."); |
301 | | |
302 | | #define INSTRUCTIONSEQUENCETYPE_GET_INSTRUCTIONS_METHODDEF \ |
303 | | {"get_instructions", (PyCFunction)InstructionSequenceType_get_instructions, METH_NOARGS, InstructionSequenceType_get_instructions__doc__}, |
304 | | |
305 | | static PyObject * |
306 | | InstructionSequenceType_get_instructions_impl(_PyInstructionSequence *self); |
307 | | |
308 | | static PyObject * |
309 | | InstructionSequenceType_get_instructions(PyObject *self, PyObject *Py_UNUSED(ignored)) |
310 | 0 | { |
311 | 0 | return InstructionSequenceType_get_instructions_impl((_PyInstructionSequence *)self); |
312 | 0 | } |
313 | | /*[clinic end generated code: output=c80501a59a1a1103 input=a9049054013a1b77]*/ |