Debian Codegraph @

Python/clinic/instruction_sequence.c.h

raw
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 {
23 PyObject *return_value = NULL;
24 PyTypeObject *base_tp = &_PyInstructionSequence_Type;
25
26 if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
27 !_PyArg_NoPositional("InstructionSequenceType", args)) {
28 goto exit;
29 }
30 if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
31 !_PyArg_NoKeywords("InstructionSequenceType", kwargs)) {
32 goto exit;
33 }
34 return_value = inst_seq_new_impl(type);
35
36 exit:
37 return return_value;
38 }
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 {
56 PyObject *return_value = NULL;
57 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
58
59 #define NUM_KEYWORDS 1
60 static struct {
61 PyGC_Head _this_is_not_used;
62 PyObject_VAR_HEAD
63 Py_hash_t ob_hash;
64 PyObject *ob_item[NUM_KEYWORDS];
65 } _kwtuple = {
66 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
67 .ob_hash = -1,
68 .ob_item = { &_Py_ID(label), },
69 };
70 #undef NUM_KEYWORDS
71 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
72
73 #else // !Py_BUILD_CORE
74 # define KWTUPLE NULL
75 #endif // !Py_BUILD_CORE
76
77 static const char * const _keywords[] = {"label", NULL};
78 static _PyArg_Parser _parser = {
79 .keywords = _keywords,
80 .fname = "use_label",
81 .kwtuple = KWTUPLE,
82 };
83 #undef KWTUPLE
84 PyObject *argsbuf[1];
85 int label;
86
87 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
88 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
89 if (!args) {
90 goto exit;
91 }
92 label = PyLong_AsInt(args[0]);
93 if (label == -1 && PyErr_Occurred()) {
94 goto exit;
95 }
96 return_value = InstructionSequenceType_use_label_impl((_PyInstructionSequence *)self, label);
97
98 exit:
99 return return_value;
100 }
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 {
120 PyObject *return_value = NULL;
121 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
122
123 #define NUM_KEYWORDS 6
124 static struct {
125 PyGC_Head _this_is_not_used;
126 PyObject_VAR_HEAD
127 Py_hash_t ob_hash;
128 PyObject *ob_item[NUM_KEYWORDS];
129 } _kwtuple = {
130 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
131 .ob_hash = -1,
132 .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 };
134 #undef NUM_KEYWORDS
135 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
136
137 #else // !Py_BUILD_CORE
138 # define KWTUPLE NULL
139 #endif // !Py_BUILD_CORE
140
141 static const char * const _keywords[] = {"opcode", "oparg", "lineno", "col_offset", "end_lineno", "end_col_offset", NULL};
142 static _PyArg_Parser _parser = {
143 .keywords = _keywords,
144 .fname = "addop",
145 .kwtuple = KWTUPLE,
146 };
147 #undef KWTUPLE
148 PyObject *argsbuf[6];
149 int opcode;
150 int oparg;
151 int lineno;
152 int col_offset;
153 int end_lineno;
154 int end_col_offset;
155
156 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
157 /*minpos*/ 6, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
158 if (!args) {
159 goto exit;
160 }
161 opcode = PyLong_AsInt(args[0]);
162 if (opcode == -1 && PyErr_Occurred()) {
163 goto exit;
164 }
165 oparg = PyLong_AsInt(args[1]);
166 if (oparg == -1 && PyErr_Occurred()) {
167 goto exit;
168 }
169 lineno = PyLong_AsInt(args[2]);
170 if (lineno == -1 && PyErr_Occurred()) {
171 goto exit;
172 }
173 col_offset = PyLong_AsInt(args[3]);
174 if (col_offset == -1 && PyErr_Occurred()) {
175 goto exit;
176 }
177 end_lineno = PyLong_AsInt(args[4]);
178 if (end_lineno == -1 && PyErr_Occurred()) {
179 goto exit;
180 }
181 end_col_offset = PyLong_AsInt(args[5]);
182 if (end_col_offset == -1 && PyErr_Occurred()) {
183 goto exit;
184 }
185 return_value = InstructionSequenceType_addop_impl((_PyInstructionSequence *)self, opcode, oparg, lineno, col_offset, end_lineno, end_col_offset);
186
187 exit:
188 return return_value;
189 }
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 {
206 PyObject *return_value = NULL;
207 int _return_value;
208
209 _return_value = InstructionSequenceType_new_label_impl((_PyInstructionSequence *)self);
210 if ((_return_value == -1) && PyErr_Occurred()) {
211 goto exit;
212 }
213 return_value = PyLong_FromLong((long)_return_value);
214
215 exit:
216 return return_value;
217 }
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 {
235 PyObject *return_value = NULL;
236 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
237
238 #define NUM_KEYWORDS 1
239 static struct {
240 PyGC_Head _this_is_not_used;
241 PyObject_VAR_HEAD
242 Py_hash_t ob_hash;
243 PyObject *ob_item[NUM_KEYWORDS];
244 } _kwtuple = {
245 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
246 .ob_hash = -1,
247 .ob_item = { &_Py_ID(nested), },
248 };
249 #undef NUM_KEYWORDS
250 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
251
252 #else // !Py_BUILD_CORE
253 # define KWTUPLE NULL
254 #endif // !Py_BUILD_CORE
255
256 static const char * const _keywords[] = {"nested", NULL};
257 static _PyArg_Parser _parser = {
258 .keywords = _keywords,
259 .fname = "add_nested",
260 .kwtuple = KWTUPLE,
261 };
262 #undef KWTUPLE
263 PyObject *argsbuf[1];
264 PyObject *nested;
265
266 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
267 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
268 if (!args) {
269 goto exit;
270 }
271 nested = args[0];
272 return_value = InstructionSequenceType_add_nested_impl((_PyInstructionSequence *)self, nested);
273
274 exit:
275 return return_value;
276 }
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 {
293 return InstructionSequenceType_get_nested_impl((_PyInstructionSequence *)self);
294 }
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 {
311 return InstructionSequenceType_get_instructions_impl((_PyInstructionSequence *)self);
312 }
313 /*[clinic end generated code: output=c80501a59a1a1103 input=a9049054013a1b77]*/