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(_PyInstructionSequence *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 PyObject *ob_item[NUM_KEYWORDS];
64 } _kwtuple = {
65 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
66 .ob_item = { &_Py_ID(label), },
67 };
68 #undef NUM_KEYWORDS
69 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
70
71 #else // !Py_BUILD_CORE
72 # define KWTUPLE NULL
73 #endif // !Py_BUILD_CORE
74
75 static const char * const _keywords[] = {"label", NULL};
76 static _PyArg_Parser _parser = {
77 .keywords = _keywords,
78 .fname = "use_label",
79 .kwtuple = KWTUPLE,
80 };
81 #undef KWTUPLE
82 PyObject *argsbuf[1];
83 int label;
84
85 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
86 if (!args) {
87 goto exit;
88 }
89 label = PyLong_AsInt(args[0]);
90 if (label == -1 && PyErr_Occurred()) {
91 goto exit;
92 }
93 return_value = InstructionSequenceType_use_label_impl(self, label);
94
95 exit:
96 return return_value;
97 }
98
99 PyDoc_STRVAR(InstructionSequenceType_addop__doc__,
100 "addop($self, /, opcode, oparg, lineno, col_offset, end_lineno,\n"
101 " end_col_offset)\n"
102 "--\n"
103 "\n"
104 "Append an instruction.");
105
106 #define INSTRUCTIONSEQUENCETYPE_ADDOP_METHODDEF \
107 {"addop", _PyCFunction_CAST(InstructionSequenceType_addop), METH_FASTCALL|METH_KEYWORDS, InstructionSequenceType_addop__doc__},
108
109 static PyObject *
110 InstructionSequenceType_addop_impl(_PyInstructionSequence *self, int opcode,
111 int oparg, int lineno, int col_offset,
112 int end_lineno, int end_col_offset);
113
114 static PyObject *
115 InstructionSequenceType_addop(_PyInstructionSequence *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
116 {
117 PyObject *return_value = NULL;
118 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
119
120 #define NUM_KEYWORDS 6
121 static struct {
122 PyGC_Head _this_is_not_used;
123 PyObject_VAR_HEAD
124 PyObject *ob_item[NUM_KEYWORDS];
125 } _kwtuple = {
126 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
127 .ob_item = { &_Py_ID(opcode), &_Py_ID(oparg), &_Py_ID(lineno), &_Py_ID(col_offset), &_Py_ID(end_lineno), &_Py_ID(end_col_offset), },
128 };
129 #undef NUM_KEYWORDS
130 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
131
132 #else // !Py_BUILD_CORE
133 # define KWTUPLE NULL
134 #endif // !Py_BUILD_CORE
135
136 static const char * const _keywords[] = {"opcode", "oparg", "lineno", "col_offset", "end_lineno", "end_col_offset", NULL};
137 static _PyArg_Parser _parser = {
138 .keywords = _keywords,
139 .fname = "addop",
140 .kwtuple = KWTUPLE,
141 };
142 #undef KWTUPLE
143 PyObject *argsbuf[6];
144 int opcode;
145 int oparg;
146 int lineno;
147 int col_offset;
148 int end_lineno;
149 int end_col_offset;
150
151 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 6, 6, 0, argsbuf);
152 if (!args) {
153 goto exit;
154 }
155 opcode = PyLong_AsInt(args[0]);
156 if (opcode == -1 && PyErr_Occurred()) {
157 goto exit;
158 }
159 oparg = PyLong_AsInt(args[1]);
160 if (oparg == -1 && PyErr_Occurred()) {
161 goto exit;
162 }
163 lineno = PyLong_AsInt(args[2]);
164 if (lineno == -1 && PyErr_Occurred()) {
165 goto exit;
166 }
167 col_offset = PyLong_AsInt(args[3]);
168 if (col_offset == -1 && PyErr_Occurred()) {
169 goto exit;
170 }
171 end_lineno = PyLong_AsInt(args[4]);
172 if (end_lineno == -1 && PyErr_Occurred()) {
173 goto exit;
174 }
175 end_col_offset = PyLong_AsInt(args[5]);
176 if (end_col_offset == -1 && PyErr_Occurred()) {
177 goto exit;
178 }
179 return_value = InstructionSequenceType_addop_impl(self, opcode, oparg, lineno, col_offset, end_lineno, end_col_offset);
180
181 exit:
182 return return_value;
183 }
184
185 PyDoc_STRVAR(InstructionSequenceType_new_label__doc__,
186 "new_label($self, /)\n"
187 "--\n"
188 "\n"
189 "Return a new label.");
190
191 #define INSTRUCTIONSEQUENCETYPE_NEW_LABEL_METHODDEF \
192 {"new_label", (PyCFunction)InstructionSequenceType_new_label, METH_NOARGS, InstructionSequenceType_new_label__doc__},
193
194 static int
195 InstructionSequenceType_new_label_impl(_PyInstructionSequence *self);
196
197 static PyObject *
198 InstructionSequenceType_new_label(_PyInstructionSequence *self, PyObject *Py_UNUSED(ignored))
199 {
200 PyObject *return_value = NULL;
201 int _return_value;
202
203 _return_value = InstructionSequenceType_new_label_impl(self);
204 if ((_return_value == -1) && PyErr_Occurred()) {
205 goto exit;
206 }
207 return_value = PyLong_FromLong((long)_return_value);
208
209 exit:
210 return return_value;
211 }
212
213 PyDoc_STRVAR(InstructionSequenceType_add_nested__doc__,
214 "add_nested($self, /, nested)\n"
215 "--\n"
216 "\n"
217 "Add a nested sequence.");
218
219 #define INSTRUCTIONSEQUENCETYPE_ADD_NESTED_METHODDEF \
220 {"add_nested", _PyCFunction_CAST(InstructionSequenceType_add_nested), METH_FASTCALL|METH_KEYWORDS, InstructionSequenceType_add_nested__doc__},
221
222 static PyObject *
223 InstructionSequenceType_add_nested_impl(_PyInstructionSequence *self,
224 PyObject *nested);
225
226 static PyObject *
227 InstructionSequenceType_add_nested(_PyInstructionSequence *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
228 {
229 PyObject *return_value = NULL;
230 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
231
232 #define NUM_KEYWORDS 1
233 static struct {
234 PyGC_Head _this_is_not_used;
235 PyObject_VAR_HEAD
236 PyObject *ob_item[NUM_KEYWORDS];
237 } _kwtuple = {
238 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
239 .ob_item = { &_Py_ID(nested), },
240 };
241 #undef NUM_KEYWORDS
242 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
243
244 #else // !Py_BUILD_CORE
245 # define KWTUPLE NULL
246 #endif // !Py_BUILD_CORE
247
248 static const char * const _keywords[] = {"nested", NULL};
249 static _PyArg_Parser _parser = {
250 .keywords = _keywords,
251 .fname = "add_nested",
252 .kwtuple = KWTUPLE,
253 };
254 #undef KWTUPLE
255 PyObject *argsbuf[1];
256 PyObject *nested;
257
258 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
259 if (!args) {
260 goto exit;
261 }
262 nested = args[0];
263 return_value = InstructionSequenceType_add_nested_impl(self, nested);
264
265 exit:
266 return return_value;
267 }
268
269 PyDoc_STRVAR(InstructionSequenceType_get_nested__doc__,
270 "get_nested($self, /)\n"
271 "--\n"
272 "\n"
273 "Add a nested sequence.");
274
275 #define INSTRUCTIONSEQUENCETYPE_GET_NESTED_METHODDEF \
276 {"get_nested", (PyCFunction)InstructionSequenceType_get_nested, METH_NOARGS, InstructionSequenceType_get_nested__doc__},
277
278 static PyObject *
279 InstructionSequenceType_get_nested_impl(_PyInstructionSequence *self);
280
281 static PyObject *
282 InstructionSequenceType_get_nested(_PyInstructionSequence *self, PyObject *Py_UNUSED(ignored))
283 {
284 return InstructionSequenceType_get_nested_impl(self);
285 }
286
287 PyDoc_STRVAR(InstructionSequenceType_get_instructions__doc__,
288 "get_instructions($self, /)\n"
289 "--\n"
290 "\n"
291 "Return the instructions as a list of tuples or labels.");
292
293 #define INSTRUCTIONSEQUENCETYPE_GET_INSTRUCTIONS_METHODDEF \
294 {"get_instructions", (PyCFunction)InstructionSequenceType_get_instructions, METH_NOARGS, InstructionSequenceType_get_instructions__doc__},
295
296 static PyObject *
297 InstructionSequenceType_get_instructions_impl(_PyInstructionSequence *self);
298
299 static PyObject *
300 InstructionSequenceType_get_instructions(_PyInstructionSequence *self, PyObject *Py_UNUSED(ignored))
301 {
302 return InstructionSequenceType_get_instructions_impl(self);
303 }
304 /*[clinic end generated code: output=8809d7aa11d9b2bb input=a9049054013a1b77]*/