blob: 1403143d06b9cf1f3257ad762c241e2c01f87ed3 [file] [log] [blame]
Neal Norwitz897ff812005-12-11 21:18:22 +00001/* File automatically generated by Parser/asdl_c.py */
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002
3#include "Python.h"
4#include "Python-ast.h"
5
Martin v. Löwis577b5b92006-02-27 15:23:19 +00006PyTypeObject* AST_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +00007PyTypeObject *mod_type;
8static PyObject* ast2obj_mod(void*);
9PyTypeObject *Module_type;
10char *Module_fields[]={
11 "body",
12};
13PyTypeObject *Interactive_type;
14char *Interactive_fields[]={
15 "body",
16};
17PyTypeObject *Expression_type;
18char *Expression_fields[]={
19 "body",
20};
21PyTypeObject *Suite_type;
22char *Suite_fields[]={
23 "body",
24};
25PyTypeObject *stmt_type;
Martin v. Löwis577b5b92006-02-27 15:23:19 +000026char *stmt_attributes[] = {
27 "lineno",
28};
Martin v. Löwisbd260da2006-02-26 19:42:26 +000029static PyObject* ast2obj_stmt(void*);
30PyTypeObject *FunctionDef_type;
31char *FunctionDef_fields[]={
32 "name",
33 "args",
34 "body",
35 "decorators",
36};
37PyTypeObject *ClassDef_type;
38char *ClassDef_fields[]={
39 "name",
40 "bases",
41 "body",
42};
43PyTypeObject *Return_type;
44char *Return_fields[]={
45 "value",
46};
47PyTypeObject *Delete_type;
48char *Delete_fields[]={
49 "targets",
50};
51PyTypeObject *Assign_type;
52char *Assign_fields[]={
53 "targets",
54 "value",
55};
56PyTypeObject *AugAssign_type;
57char *AugAssign_fields[]={
58 "target",
59 "op",
60 "value",
61};
62PyTypeObject *Print_type;
63char *Print_fields[]={
64 "dest",
65 "values",
66 "nl",
67};
68PyTypeObject *For_type;
69char *For_fields[]={
70 "target",
71 "iter",
72 "body",
73 "orelse",
74};
75PyTypeObject *While_type;
76char *While_fields[]={
77 "test",
78 "body",
79 "orelse",
80};
81PyTypeObject *If_type;
82char *If_fields[]={
83 "test",
84 "body",
85 "orelse",
86};
Guido van Rossumc2e20742006-02-27 22:32:47 +000087PyTypeObject *With_type;
88char *With_fields[]={
89 "context_expr",
90 "optional_vars",
91 "body",
92};
Martin v. Löwisbd260da2006-02-26 19:42:26 +000093PyTypeObject *Raise_type;
94char *Raise_fields[]={
95 "type",
96 "inst",
97 "tback",
98};
99PyTypeObject *TryExcept_type;
100char *TryExcept_fields[]={
101 "body",
102 "handlers",
103 "orelse",
104};
105PyTypeObject *TryFinally_type;
106char *TryFinally_fields[]={
107 "body",
108 "finalbody",
109};
110PyTypeObject *Assert_type;
111char *Assert_fields[]={
112 "test",
113 "msg",
114};
115PyTypeObject *Import_type;
116char *Import_fields[]={
117 "names",
118};
119PyTypeObject *ImportFrom_type;
120char *ImportFrom_fields[]={
121 "module",
122 "names",
123};
124PyTypeObject *Exec_type;
125char *Exec_fields[]={
126 "body",
127 "globals",
128 "locals",
129};
130PyTypeObject *Global_type;
131char *Global_fields[]={
132 "names",
133};
134PyTypeObject *Expr_type;
135char *Expr_fields[]={
136 "value",
137};
138PyTypeObject *Pass_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000139PyTypeObject *Break_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000140PyTypeObject *Continue_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000141PyTypeObject *expr_type;
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000142char *expr_attributes[] = {
143 "lineno",
144};
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000145static PyObject* ast2obj_expr(void*);
146PyTypeObject *BoolOp_type;
147char *BoolOp_fields[]={
148 "op",
149 "values",
150};
151PyTypeObject *BinOp_type;
152char *BinOp_fields[]={
153 "left",
154 "op",
155 "right",
156};
157PyTypeObject *UnaryOp_type;
158char *UnaryOp_fields[]={
159 "op",
160 "operand",
161};
162PyTypeObject *Lambda_type;
163char *Lambda_fields[]={
164 "args",
165 "body",
166};
Thomas Woutersdca3b9c2006-02-27 00:24:13 +0000167PyTypeObject *IfExp_type;
168char *IfExp_fields[]={
169 "test",
170 "body",
171 "orelse",
172};
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000173PyTypeObject *Dict_type;
174char *Dict_fields[]={
175 "keys",
176 "values",
177};
178PyTypeObject *ListComp_type;
179char *ListComp_fields[]={
180 "elt",
181 "generators",
182};
183PyTypeObject *GeneratorExp_type;
184char *GeneratorExp_fields[]={
185 "elt",
186 "generators",
187};
188PyTypeObject *Yield_type;
189char *Yield_fields[]={
190 "value",
191};
192PyTypeObject *Compare_type;
193char *Compare_fields[]={
194 "left",
195 "ops",
196 "comparators",
197};
198PyTypeObject *Call_type;
199char *Call_fields[]={
200 "func",
201 "args",
202 "keywords",
203 "starargs",
204 "kwargs",
205};
206PyTypeObject *Repr_type;
207char *Repr_fields[]={
208 "value",
209};
210PyTypeObject *Num_type;
211char *Num_fields[]={
212 "n",
213};
214PyTypeObject *Str_type;
215char *Str_fields[]={
216 "s",
217};
218PyTypeObject *Attribute_type;
219char *Attribute_fields[]={
220 "value",
221 "attr",
222 "ctx",
223};
224PyTypeObject *Subscript_type;
225char *Subscript_fields[]={
226 "value",
227 "slice",
228 "ctx",
229};
230PyTypeObject *Name_type;
231char *Name_fields[]={
232 "id",
233 "ctx",
234};
235PyTypeObject *List_type;
236char *List_fields[]={
237 "elts",
238 "ctx",
239};
240PyTypeObject *Tuple_type;
241char *Tuple_fields[]={
242 "elts",
243 "ctx",
244};
245PyTypeObject *expr_context_type;
246static PyObject *Load_singleton, *Store_singleton, *Del_singleton,
247*AugLoad_singleton, *AugStore_singleton, *Param_singleton;
248static PyObject* ast2obj_expr_context(expr_context_ty);
249PyTypeObject *Load_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000250PyTypeObject *Store_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000251PyTypeObject *Del_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000252PyTypeObject *AugLoad_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000253PyTypeObject *AugStore_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000254PyTypeObject *Param_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000255PyTypeObject *slice_type;
256static PyObject* ast2obj_slice(void*);
257PyTypeObject *Ellipsis_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000258PyTypeObject *Slice_type;
259char *Slice_fields[]={
260 "lower",
261 "upper",
262 "step",
263};
264PyTypeObject *ExtSlice_type;
265char *ExtSlice_fields[]={
266 "dims",
267};
268PyTypeObject *Index_type;
269char *Index_fields[]={
270 "value",
271};
272PyTypeObject *boolop_type;
273static PyObject *And_singleton, *Or_singleton;
274static PyObject* ast2obj_boolop(boolop_ty);
275PyTypeObject *And_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000276PyTypeObject *Or_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000277PyTypeObject *operator_type;
278static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton,
279*Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton,
280*RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton,
281*FloorDiv_singleton;
282static PyObject* ast2obj_operator(operator_ty);
283PyTypeObject *Add_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000284PyTypeObject *Sub_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000285PyTypeObject *Mult_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000286PyTypeObject *Div_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000287PyTypeObject *Mod_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000288PyTypeObject *Pow_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000289PyTypeObject *LShift_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000290PyTypeObject *RShift_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000291PyTypeObject *BitOr_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000292PyTypeObject *BitXor_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000293PyTypeObject *BitAnd_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000294PyTypeObject *FloorDiv_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000295PyTypeObject *unaryop_type;
296static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton,
297*USub_singleton;
298static PyObject* ast2obj_unaryop(unaryop_ty);
299PyTypeObject *Invert_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000300PyTypeObject *Not_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000301PyTypeObject *UAdd_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000302PyTypeObject *USub_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000303PyTypeObject *cmpop_type;
304static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton,
305*Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton,
306*NotIn_singleton;
307static PyObject* ast2obj_cmpop(cmpop_ty);
308PyTypeObject *Eq_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000309PyTypeObject *NotEq_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000310PyTypeObject *Lt_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000311PyTypeObject *LtE_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000312PyTypeObject *Gt_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000313PyTypeObject *GtE_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000314PyTypeObject *Is_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000315PyTypeObject *IsNot_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000316PyTypeObject *In_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000317PyTypeObject *NotIn_type;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000318PyTypeObject *comprehension_type;
319static PyObject* ast2obj_comprehension(void*);
320char *comprehension_fields[]={
321 "target",
322 "iter",
323 "ifs",
324};
325PyTypeObject *excepthandler_type;
326static PyObject* ast2obj_excepthandler(void*);
327char *excepthandler_fields[]={
328 "type",
329 "name",
330 "body",
331};
332PyTypeObject *arguments_type;
333static PyObject* ast2obj_arguments(void*);
334char *arguments_fields[]={
335 "args",
336 "vararg",
337 "kwarg",
338 "defaults",
339};
340PyTypeObject *keyword_type;
341static PyObject* ast2obj_keyword(void*);
342char *keyword_fields[]={
343 "arg",
344 "value",
345};
346PyTypeObject *alias_type;
347static PyObject* ast2obj_alias(void*);
348char *alias_fields[]={
349 "name",
350 "asname",
351};
352
353
354static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields)
355{
356 PyObject *fnames, *result;
357 int i;
358 if (num_fields) {
359 fnames = PyTuple_New(num_fields);
360 if (!fnames) return NULL;
361 } else {
362 fnames = Py_None;
363 Py_INCREF(Py_None);
364 }
365 for(i=0; i < num_fields; i++) {
366 PyObject *field = PyString_FromString(fields[i]);
367 if (!field) {
368 Py_DECREF(fnames);
369 return NULL;
370 }
371 PyTuple_SET_ITEM(fnames, i, field);
372 }
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000373 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
374 type, base, "_fields", fnames, "__module__", "_ast");
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000375 Py_DECREF(fnames);
376 return (PyTypeObject*)result;
377}
378
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000379static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
380{
381 int i;
382 PyObject *s, *l = PyList_New(num_fields);
383 if (!l) return 0;
384 for(i=0; i < num_fields; i++) {
385 s = PyString_FromString(attrs[i]);
386 if (!s) {
387 Py_DECREF(l);
388 return 0;
389 }
390 PyList_SET_ITEM(l, i, s);
391 }
392 return PyObject_SetAttrString((PyObject*)type, "_attributes", l) >=0;
393}
394
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000395static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
396{
397 int i, n = asdl_seq_LEN(seq);
398 PyObject *result = PyList_New(n);
399 PyObject *value;
400 if (!result)
401 return NULL;
402 for (i = 0; i < n; i++) {
403 value = func(asdl_seq_GET(seq, i));
404 if (!value) {
405 Py_DECREF(result);
406 return NULL;
407 }
408 PyList_SET_ITEM(result, i, value);
409 }
410 return result;
411}
412
413static PyObject* ast2obj_object(void *o)
414{
415 if (!o)
416 o = Py_None;
417 Py_INCREF((PyObject*)o);
418 return (PyObject*)o;
419}
420#define ast2obj_identifier ast2obj_object
421#define ast2obj_string ast2obj_object
422static PyObject* ast2obj_bool(bool b)
423{
424 return PyBool_FromLong(b);
425}
426
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000427static PyObject* ast2obj_int(bool b)
428{
429 return PyInt_FromLong(b);
430}
431
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000432static int initialized;
433static int init_types(void)
434{
435 if (initialized) return 1;
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000436 AST_type = make_type("AST", &PyBaseObject_Type, NULL, 0);
437 mod_type = make_type("mod", AST_type, NULL, 0);
438 if (!mod_type) return 0;
439 if (!add_attributes(mod_type, NULL, 0)) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000440 Module_type = make_type("Module", mod_type, Module_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000441 if (!Module_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000442 Interactive_type = make_type("Interactive", mod_type,
443 Interactive_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000444 if (!Interactive_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000445 Expression_type = make_type("Expression", mod_type, Expression_fields,
446 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000447 if (!Expression_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000448 Suite_type = make_type("Suite", mod_type, Suite_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000449 if (!Suite_type) return 0;
450 stmt_type = make_type("stmt", AST_type, NULL, 0);
451 if (!stmt_type) return 0;
452 if (!add_attributes(stmt_type, stmt_attributes, 1)) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000453 FunctionDef_type = make_type("FunctionDef", stmt_type,
454 FunctionDef_fields, 4);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000455 if (!FunctionDef_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000456 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000457 if (!ClassDef_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000458 Return_type = make_type("Return", stmt_type, Return_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000459 if (!Return_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000460 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000461 if (!Delete_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000462 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000463 if (!Assign_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000464 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000465 if (!AugAssign_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000466 Print_type = make_type("Print", stmt_type, Print_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000467 if (!Print_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000468 For_type = make_type("For", stmt_type, For_fields, 4);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000469 if (!For_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000470 While_type = make_type("While", stmt_type, While_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000471 if (!While_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000472 If_type = make_type("If", stmt_type, If_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000473 if (!If_type) return 0;
Guido van Rossumc2e20742006-02-27 22:32:47 +0000474 With_type = make_type("With", stmt_type, With_fields, 3);
475 if (!With_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000476 Raise_type = make_type("Raise", stmt_type, Raise_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000477 if (!Raise_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000478 TryExcept_type = make_type("TryExcept", stmt_type, TryExcept_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000479 if (!TryExcept_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000480 TryFinally_type = make_type("TryFinally", stmt_type, TryFinally_fields,
481 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000482 if (!TryFinally_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000483 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000484 if (!Assert_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000485 Import_type = make_type("Import", stmt_type, Import_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000486 if (!Import_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000487 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields,
488 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000489 if (!ImportFrom_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000490 Exec_type = make_type("Exec", stmt_type, Exec_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000491 if (!Exec_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000492 Global_type = make_type("Global", stmt_type, Global_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000493 if (!Global_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000494 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000495 if (!Expr_type) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000496 Pass_type = make_type("Pass", stmt_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000497 if (!Pass_type) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000498 Break_type = make_type("Break", stmt_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000499 if (!Break_type) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000500 Continue_type = make_type("Continue", stmt_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000501 if (!Continue_type) return 0;
502 expr_type = make_type("expr", AST_type, NULL, 0);
503 if (!expr_type) return 0;
504 if (!add_attributes(expr_type, expr_attributes, 1)) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000505 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000506 if (!BoolOp_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000507 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000508 if (!BinOp_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000509 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000510 if (!UnaryOp_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000511 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000512 if (!Lambda_type) return 0;
Thomas Woutersdca3b9c2006-02-27 00:24:13 +0000513 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000514 if (!IfExp_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000515 Dict_type = make_type("Dict", expr_type, Dict_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000516 if (!Dict_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000517 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000518 if (!ListComp_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000519 GeneratorExp_type = make_type("GeneratorExp", expr_type,
520 GeneratorExp_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000521 if (!GeneratorExp_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000522 Yield_type = make_type("Yield", expr_type, Yield_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000523 if (!Yield_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000524 Compare_type = make_type("Compare", expr_type, Compare_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000525 if (!Compare_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000526 Call_type = make_type("Call", expr_type, Call_fields, 5);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000527 if (!Call_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000528 Repr_type = make_type("Repr", expr_type, Repr_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000529 if (!Repr_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000530 Num_type = make_type("Num", expr_type, Num_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000531 if (!Num_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000532 Str_type = make_type("Str", expr_type, Str_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000533 if (!Str_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000534 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000535 if (!Attribute_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000536 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000537 if (!Subscript_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000538 Name_type = make_type("Name", expr_type, Name_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000539 if (!Name_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000540 List_type = make_type("List", expr_type, List_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000541 if (!List_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000542 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000543 if (!Tuple_type) return 0;
544 expr_context_type = make_type("expr_context", AST_type, NULL, 0);
545 if (!expr_context_type) return 0;
546 if (!add_attributes(expr_context_type, NULL, 0)) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000547 Load_type = make_type("Load", expr_context_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000548 if (!Load_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000549 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000550 if (!Load_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000551 Store_type = make_type("Store", expr_context_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000552 if (!Store_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000553 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000554 if (!Store_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000555 Del_type = make_type("Del", expr_context_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000556 if (!Del_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000557 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000558 if (!Del_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000559 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000560 if (!AugLoad_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000561 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000562 if (!AugLoad_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000563 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000564 if (!AugStore_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000565 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000566 if (!AugStore_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000567 Param_type = make_type("Param", expr_context_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000568 if (!Param_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000569 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000570 if (!Param_singleton) return 0;
571 slice_type = make_type("slice", AST_type, NULL, 0);
572 if (!slice_type) return 0;
573 if (!add_attributes(slice_type, NULL, 0)) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000574 Ellipsis_type = make_type("Ellipsis", slice_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000575 if (!Ellipsis_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000576 Slice_type = make_type("Slice", slice_type, Slice_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000577 if (!Slice_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000578 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000579 if (!ExtSlice_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000580 Index_type = make_type("Index", slice_type, Index_fields, 1);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000581 if (!Index_type) return 0;
582 boolop_type = make_type("boolop", AST_type, NULL, 0);
583 if (!boolop_type) return 0;
584 if (!add_attributes(boolop_type, NULL, 0)) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000585 And_type = make_type("And", boolop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000586 if (!And_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000587 And_singleton = PyType_GenericNew(And_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000588 if (!And_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000589 Or_type = make_type("Or", boolop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000590 if (!Or_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000591 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000592 if (!Or_singleton) return 0;
593 operator_type = make_type("operator", AST_type, NULL, 0);
594 if (!operator_type) return 0;
595 if (!add_attributes(operator_type, NULL, 0)) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000596 Add_type = make_type("Add", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000597 if (!Add_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000598 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000599 if (!Add_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000600 Sub_type = make_type("Sub", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000601 if (!Sub_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000602 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000603 if (!Sub_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000604 Mult_type = make_type("Mult", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000605 if (!Mult_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000606 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000607 if (!Mult_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000608 Div_type = make_type("Div", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000609 if (!Div_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000610 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000611 if (!Div_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000612 Mod_type = make_type("Mod", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000613 if (!Mod_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000614 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000615 if (!Mod_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000616 Pow_type = make_type("Pow", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000617 if (!Pow_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000618 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000619 if (!Pow_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000620 LShift_type = make_type("LShift", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000621 if (!LShift_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000622 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000623 if (!LShift_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000624 RShift_type = make_type("RShift", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000625 if (!RShift_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000626 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000627 if (!RShift_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000628 BitOr_type = make_type("BitOr", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000629 if (!BitOr_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000630 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000631 if (!BitOr_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000632 BitXor_type = make_type("BitXor", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000633 if (!BitXor_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000634 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000635 if (!BitXor_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000636 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000637 if (!BitAnd_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000638 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000639 if (!BitAnd_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000640 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000641 if (!FloorDiv_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000642 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000643 if (!FloorDiv_singleton) return 0;
644 unaryop_type = make_type("unaryop", AST_type, NULL, 0);
645 if (!unaryop_type) return 0;
646 if (!add_attributes(unaryop_type, NULL, 0)) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000647 Invert_type = make_type("Invert", unaryop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000648 if (!Invert_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000649 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000650 if (!Invert_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000651 Not_type = make_type("Not", unaryop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000652 if (!Not_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000653 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000654 if (!Not_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000655 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000656 if (!UAdd_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000657 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000658 if (!UAdd_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000659 USub_type = make_type("USub", unaryop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000660 if (!USub_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000661 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000662 if (!USub_singleton) return 0;
663 cmpop_type = make_type("cmpop", AST_type, NULL, 0);
664 if (!cmpop_type) return 0;
665 if (!add_attributes(cmpop_type, NULL, 0)) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000666 Eq_type = make_type("Eq", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000667 if (!Eq_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000668 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000669 if (!Eq_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000670 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000671 if (!NotEq_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000672 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000673 if (!NotEq_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000674 Lt_type = make_type("Lt", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000675 if (!Lt_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000676 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000677 if (!Lt_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000678 LtE_type = make_type("LtE", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000679 if (!LtE_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000680 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000681 if (!LtE_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000682 Gt_type = make_type("Gt", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000683 if (!Gt_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000684 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000685 if (!Gt_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000686 GtE_type = make_type("GtE", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000687 if (!GtE_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000688 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000689 if (!GtE_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000690 Is_type = make_type("Is", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000691 if (!Is_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000692 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000693 if (!Is_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000694 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000695 if (!IsNot_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000696 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000697 if (!IsNot_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000698 In_type = make_type("In", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000699 if (!In_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000700 In_singleton = PyType_GenericNew(In_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000701 if (!In_singleton) return 0;
Martin v. Löwis8d0701d2006-02-26 23:40:20 +0000702 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000703 if (!NotIn_type) return 0;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000704 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000705 if (!NotIn_singleton) return 0;
706 comprehension_type = make_type("comprehension", AST_type,
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000707 comprehension_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000708 if (!comprehension_type) return 0;
709 excepthandler_type = make_type("excepthandler", AST_type,
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000710 excepthandler_fields, 3);
Martin v. Löwis577b5b92006-02-27 15:23:19 +0000711 if (!excepthandler_type) return 0;
712 arguments_type = make_type("arguments", AST_type, arguments_fields, 4);
713 if (!arguments_type) return 0;
714 keyword_type = make_type("keyword", AST_type, keyword_fields, 2);
715 if (!keyword_type) return 0;
716 alias_type = make_type("alias", AST_type, alias_fields, 2);
717 if (!alias_type) return 0;
718 initialized = 1;
719 return 1;
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000720}
Neal Norwitz7b5a6042005-11-13 19:14:20 +0000721
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000722mod_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000723Module(asdl_seq * body, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000724{
725 mod_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000726 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000727 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000728 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000729 return NULL;
730 }
731 p->kind = Module_kind;
732 p->v.Module.body = body;
733 return p;
734}
735
736mod_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000737Interactive(asdl_seq * body, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000738{
739 mod_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000740 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000741 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000742 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000743 return NULL;
744 }
745 p->kind = Interactive_kind;
746 p->v.Interactive.body = body;
747 return p;
748}
749
750mod_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000751Expression(expr_ty body, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000752{
753 mod_ty p;
754 if (!body) {
755 PyErr_SetString(PyExc_ValueError,
756 "field body is required for Expression");
757 return NULL;
758 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000759 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000760 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000761 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000762 return NULL;
763 }
764 p->kind = Expression_kind;
765 p->v.Expression.body = body;
766 return p;
767}
768
769mod_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000770Suite(asdl_seq * body, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000771{
772 mod_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000773 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000774 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000775 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000776 return NULL;
777 }
778 p->kind = Suite_kind;
779 p->v.Suite.body = body;
780 return p;
781}
782
783stmt_ty
784FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000785 decorators, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000786{
787 stmt_ty p;
788 if (!name) {
789 PyErr_SetString(PyExc_ValueError,
790 "field name is required for FunctionDef");
791 return NULL;
792 }
793 if (!args) {
794 PyErr_SetString(PyExc_ValueError,
795 "field args is required for FunctionDef");
796 return NULL;
797 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000798 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000799 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000800 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000801 return NULL;
802 }
803 p->kind = FunctionDef_kind;
804 p->v.FunctionDef.name = name;
805 p->v.FunctionDef.args = args;
806 p->v.FunctionDef.body = body;
807 p->v.FunctionDef.decorators = decorators;
808 p->lineno = lineno;
809 return p;
810}
811
812stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000813ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno,
814 PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000815{
816 stmt_ty p;
817 if (!name) {
818 PyErr_SetString(PyExc_ValueError,
819 "field name is required for ClassDef");
820 return NULL;
821 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000822 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000823 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000824 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000825 return NULL;
826 }
827 p->kind = ClassDef_kind;
828 p->v.ClassDef.name = name;
829 p->v.ClassDef.bases = bases;
830 p->v.ClassDef.body = body;
831 p->lineno = lineno;
832 return p;
833}
834
835stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000836Return(expr_ty value, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000837{
838 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000839 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000840 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000841 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000842 return NULL;
843 }
844 p->kind = Return_kind;
845 p->v.Return.value = value;
846 p->lineno = lineno;
847 return p;
848}
849
850stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000851Delete(asdl_seq * targets, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000852{
853 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000854 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000855 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000856 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000857 return NULL;
858 }
859 p->kind = Delete_kind;
860 p->v.Delete.targets = targets;
861 p->lineno = lineno;
862 return p;
863}
864
865stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000866Assign(asdl_seq * targets, expr_ty value, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000867{
868 stmt_ty p;
869 if (!value) {
870 PyErr_SetString(PyExc_ValueError,
871 "field value is required for Assign");
872 return NULL;
873 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000874 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000875 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000876 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000877 return NULL;
878 }
879 p->kind = Assign_kind;
880 p->v.Assign.targets = targets;
881 p->v.Assign.value = value;
882 p->lineno = lineno;
883 return p;
884}
885
886stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000887AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, PyArena
888 *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000889{
890 stmt_ty p;
891 if (!target) {
892 PyErr_SetString(PyExc_ValueError,
893 "field target is required for AugAssign");
894 return NULL;
895 }
896 if (!op) {
897 PyErr_SetString(PyExc_ValueError,
898 "field op is required for AugAssign");
899 return NULL;
900 }
901 if (!value) {
902 PyErr_SetString(PyExc_ValueError,
903 "field value is required for AugAssign");
904 return NULL;
905 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000906 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000907 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000908 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000909 return NULL;
910 }
911 p->kind = AugAssign_kind;
912 p->v.AugAssign.target = target;
913 p->v.AugAssign.op = op;
914 p->v.AugAssign.value = value;
915 p->lineno = lineno;
916 return p;
917}
918
919stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000920Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000921{
922 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000923 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000924 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000925 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000926 return NULL;
927 }
928 p->kind = Print_kind;
929 p->v.Print.dest = dest;
930 p->v.Print.values = values;
931 p->v.Print.nl = nl;
932 p->lineno = lineno;
933 return p;
934}
935
936stmt_ty
937For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000938 lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000939{
940 stmt_ty p;
941 if (!target) {
942 PyErr_SetString(PyExc_ValueError,
943 "field target is required for For");
944 return NULL;
945 }
946 if (!iter) {
947 PyErr_SetString(PyExc_ValueError,
948 "field iter is required for For");
949 return NULL;
950 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000951 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000952 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000953 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000954 return NULL;
955 }
956 p->kind = For_kind;
957 p->v.For.target = target;
958 p->v.For.iter = iter;
959 p->v.For.body = body;
960 p->v.For.orelse = orelse;
961 p->lineno = lineno;
962 return p;
963}
964
965stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000966While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, PyArena
967 *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000968{
969 stmt_ty p;
970 if (!test) {
971 PyErr_SetString(PyExc_ValueError,
972 "field test is required for While");
973 return NULL;
974 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000975 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000976 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000977 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000978 return NULL;
979 }
980 p->kind = While_kind;
981 p->v.While.test = test;
982 p->v.While.body = body;
983 p->v.While.orelse = orelse;
984 p->lineno = lineno;
985 return p;
986}
987
988stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000989If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000990{
991 stmt_ty p;
992 if (!test) {
993 PyErr_SetString(PyExc_ValueError,
994 "field test is required for If");
995 return NULL;
996 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000997 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000998 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +0000999 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001000 return NULL;
1001 }
1002 p->kind = If_kind;
1003 p->v.If.test = test;
1004 p->v.If.body = body;
1005 p->v.If.orelse = orelse;
1006 p->lineno = lineno;
1007 return p;
1008}
1009
1010stmt_ty
Guido van Rossumc2e20742006-02-27 22:32:47 +00001011With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int lineno,
1012 PyArena *arena)
1013{
1014 stmt_ty p;
1015 if (!context_expr) {
1016 PyErr_SetString(PyExc_ValueError,
1017 "field context_expr is required for With");
1018 return NULL;
1019 }
1020 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1021 if (!p) {
1022 PyErr_NoMemory();
1023 return NULL;
1024 }
1025 p->kind = With_kind;
1026 p->v.With.context_expr = context_expr;
1027 p->v.With.optional_vars = optional_vars;
1028 p->v.With.body = body;
1029 p->lineno = lineno;
1030 return p;
1031}
1032
1033stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001034Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001035{
1036 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001037 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001038 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001039 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001040 return NULL;
1041 }
1042 p->kind = Raise_kind;
1043 p->v.Raise.type = type;
1044 p->v.Raise.inst = inst;
1045 p->v.Raise.tback = tback;
1046 p->lineno = lineno;
1047 return p;
1048}
1049
1050stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001051TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno,
1052 PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001053{
1054 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001055 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001056 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001057 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001058 return NULL;
1059 }
1060 p->kind = TryExcept_kind;
1061 p->v.TryExcept.body = body;
1062 p->v.TryExcept.handlers = handlers;
1063 p->v.TryExcept.orelse = orelse;
1064 p->lineno = lineno;
1065 return p;
1066}
1067
1068stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001069TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001070{
1071 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001072 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001073 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001074 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001075 return NULL;
1076 }
1077 p->kind = TryFinally_kind;
1078 p->v.TryFinally.body = body;
1079 p->v.TryFinally.finalbody = finalbody;
1080 p->lineno = lineno;
1081 return p;
1082}
1083
1084stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001085Assert(expr_ty test, expr_ty msg, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001086{
1087 stmt_ty p;
1088 if (!test) {
1089 PyErr_SetString(PyExc_ValueError,
1090 "field test is required for Assert");
1091 return NULL;
1092 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001093 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001094 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001095 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001096 return NULL;
1097 }
1098 p->kind = Assert_kind;
1099 p->v.Assert.test = test;
1100 p->v.Assert.msg = msg;
1101 p->lineno = lineno;
1102 return p;
1103}
1104
1105stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001106Import(asdl_seq * names, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001107{
1108 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001109 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001110 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001111 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001112 return NULL;
1113 }
1114 p->kind = Import_kind;
1115 p->v.Import.names = names;
1116 p->lineno = lineno;
1117 return p;
1118}
1119
1120stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001121ImportFrom(identifier module, asdl_seq * names, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001122{
1123 stmt_ty p;
1124 if (!module) {
1125 PyErr_SetString(PyExc_ValueError,
1126 "field module is required for ImportFrom");
1127 return NULL;
1128 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001129 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001130 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001131 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001132 return NULL;
1133 }
1134 p->kind = ImportFrom_kind;
1135 p->v.ImportFrom.module = module;
1136 p->v.ImportFrom.names = names;
1137 p->lineno = lineno;
1138 return p;
1139}
1140
1141stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001142Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001143{
1144 stmt_ty p;
1145 if (!body) {
1146 PyErr_SetString(PyExc_ValueError,
1147 "field body is required for Exec");
1148 return NULL;
1149 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001150 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001151 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001152 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001153 return NULL;
1154 }
1155 p->kind = Exec_kind;
1156 p->v.Exec.body = body;
1157 p->v.Exec.globals = globals;
1158 p->v.Exec.locals = locals;
1159 p->lineno = lineno;
1160 return p;
1161}
1162
1163stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001164Global(asdl_seq * names, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001165{
1166 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001167 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001168 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001169 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001170 return NULL;
1171 }
1172 p->kind = Global_kind;
1173 p->v.Global.names = names;
1174 p->lineno = lineno;
1175 return p;
1176}
1177
1178stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001179Expr(expr_ty value, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001180{
1181 stmt_ty p;
1182 if (!value) {
1183 PyErr_SetString(PyExc_ValueError,
1184 "field value is required for Expr");
1185 return NULL;
1186 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001187 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001188 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001189 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001190 return NULL;
1191 }
1192 p->kind = Expr_kind;
1193 p->v.Expr.value = value;
1194 p->lineno = lineno;
1195 return p;
1196}
1197
1198stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001199Pass(int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001200{
1201 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001202 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001203 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001204 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001205 return NULL;
1206 }
1207 p->kind = Pass_kind;
1208 p->lineno = lineno;
1209 return p;
1210}
1211
1212stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001213Break(int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001214{
1215 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001216 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001217 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001218 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001219 return NULL;
1220 }
1221 p->kind = Break_kind;
1222 p->lineno = lineno;
1223 return p;
1224}
1225
1226stmt_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001227Continue(int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001228{
1229 stmt_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001230 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001231 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001232 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001233 return NULL;
1234 }
1235 p->kind = Continue_kind;
1236 p->lineno = lineno;
1237 return p;
1238}
1239
1240expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001241BoolOp(boolop_ty op, asdl_seq * values, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001242{
1243 expr_ty p;
1244 if (!op) {
1245 PyErr_SetString(PyExc_ValueError,
1246 "field op is required for BoolOp");
1247 return NULL;
1248 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001249 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001250 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001251 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001252 return NULL;
1253 }
1254 p->kind = BoolOp_kind;
1255 p->v.BoolOp.op = op;
1256 p->v.BoolOp.values = values;
1257 p->lineno = lineno;
1258 return p;
1259}
1260
1261expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001262BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001263{
1264 expr_ty p;
1265 if (!left) {
1266 PyErr_SetString(PyExc_ValueError,
1267 "field left is required for BinOp");
1268 return NULL;
1269 }
1270 if (!op) {
1271 PyErr_SetString(PyExc_ValueError,
1272 "field op is required for BinOp");
1273 return NULL;
1274 }
1275 if (!right) {
1276 PyErr_SetString(PyExc_ValueError,
1277 "field right is required for BinOp");
1278 return NULL;
1279 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001280 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001281 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001282 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001283 return NULL;
1284 }
1285 p->kind = BinOp_kind;
1286 p->v.BinOp.left = left;
1287 p->v.BinOp.op = op;
1288 p->v.BinOp.right = right;
1289 p->lineno = lineno;
1290 return p;
1291}
1292
1293expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001294UnaryOp(unaryop_ty op, expr_ty operand, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001295{
1296 expr_ty p;
1297 if (!op) {
1298 PyErr_SetString(PyExc_ValueError,
1299 "field op is required for UnaryOp");
1300 return NULL;
1301 }
1302 if (!operand) {
1303 PyErr_SetString(PyExc_ValueError,
1304 "field operand is required for UnaryOp");
1305 return NULL;
1306 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001307 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001308 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001309 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001310 return NULL;
1311 }
1312 p->kind = UnaryOp_kind;
1313 p->v.UnaryOp.op = op;
1314 p->v.UnaryOp.operand = operand;
1315 p->lineno = lineno;
1316 return p;
1317}
1318
1319expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001320Lambda(arguments_ty args, expr_ty body, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001321{
1322 expr_ty p;
1323 if (!args) {
1324 PyErr_SetString(PyExc_ValueError,
1325 "field args is required for Lambda");
1326 return NULL;
1327 }
1328 if (!body) {
1329 PyErr_SetString(PyExc_ValueError,
1330 "field body is required for Lambda");
1331 return NULL;
1332 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001333 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001334 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001335 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001336 return NULL;
1337 }
1338 p->kind = Lambda_kind;
1339 p->v.Lambda.args = args;
1340 p->v.Lambda.body = body;
1341 p->lineno = lineno;
1342 return p;
1343}
1344
1345expr_ty
Thomas Woutersdca3b9c2006-02-27 00:24:13 +00001346IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, PyArena *arena)
1347{
1348 expr_ty p;
1349 if (!test) {
1350 PyErr_SetString(PyExc_ValueError,
1351 "field test is required for IfExp");
1352 return NULL;
1353 }
1354 if (!body) {
1355 PyErr_SetString(PyExc_ValueError,
1356 "field body is required for IfExp");
1357 return NULL;
1358 }
1359 if (!orelse) {
1360 PyErr_SetString(PyExc_ValueError,
1361 "field orelse is required for IfExp");
1362 return NULL;
1363 }
1364 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1365 if (!p) {
1366 PyErr_NoMemory();
1367 return NULL;
1368 }
1369 p->kind = IfExp_kind;
1370 p->v.IfExp.test = test;
1371 p->v.IfExp.body = body;
1372 p->v.IfExp.orelse = orelse;
1373 p->lineno = lineno;
1374 return p;
1375}
1376
1377expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001378Dict(asdl_seq * keys, asdl_seq * values, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001379{
1380 expr_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001381 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001382 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001383 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001384 return NULL;
1385 }
1386 p->kind = Dict_kind;
1387 p->v.Dict.keys = keys;
1388 p->v.Dict.values = values;
1389 p->lineno = lineno;
1390 return p;
1391}
1392
1393expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001394ListComp(expr_ty elt, asdl_seq * generators, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001395{
1396 expr_ty p;
1397 if (!elt) {
1398 PyErr_SetString(PyExc_ValueError,
1399 "field elt is required for ListComp");
1400 return NULL;
1401 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001402 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001403 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001404 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001405 return NULL;
1406 }
1407 p->kind = ListComp_kind;
1408 p->v.ListComp.elt = elt;
1409 p->v.ListComp.generators = generators;
1410 p->lineno = lineno;
1411 return p;
1412}
1413
1414expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001415GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001416{
1417 expr_ty p;
1418 if (!elt) {
1419 PyErr_SetString(PyExc_ValueError,
1420 "field elt is required for GeneratorExp");
1421 return NULL;
1422 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001423 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001424 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001425 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001426 return NULL;
1427 }
1428 p->kind = GeneratorExp_kind;
1429 p->v.GeneratorExp.elt = elt;
1430 p->v.GeneratorExp.generators = generators;
1431 p->lineno = lineno;
1432 return p;
1433}
1434
1435expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001436Yield(expr_ty value, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001437{
1438 expr_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001439 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001440 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001441 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001442 return NULL;
1443 }
1444 p->kind = Yield_kind;
1445 p->v.Yield.value = value;
1446 p->lineno = lineno;
1447 return p;
1448}
1449
1450expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001451Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators, int lineno,
1452 PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001453{
1454 expr_ty p;
1455 if (!left) {
1456 PyErr_SetString(PyExc_ValueError,
1457 "field left is required for Compare");
1458 return NULL;
1459 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001460 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001461 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001462 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001463 return NULL;
1464 }
1465 p->kind = Compare_kind;
1466 p->v.Compare.left = left;
1467 p->v.Compare.ops = ops;
1468 p->v.Compare.comparators = comparators;
1469 p->lineno = lineno;
1470 return p;
1471}
1472
1473expr_ty
1474Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001475 expr_ty kwargs, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001476{
1477 expr_ty p;
1478 if (!func) {
1479 PyErr_SetString(PyExc_ValueError,
1480 "field func is required for Call");
1481 return NULL;
1482 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001483 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001484 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001485 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001486 return NULL;
1487 }
1488 p->kind = Call_kind;
1489 p->v.Call.func = func;
1490 p->v.Call.args = args;
1491 p->v.Call.keywords = keywords;
1492 p->v.Call.starargs = starargs;
1493 p->v.Call.kwargs = kwargs;
1494 p->lineno = lineno;
1495 return p;
1496}
1497
1498expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001499Repr(expr_ty value, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001500{
1501 expr_ty p;
1502 if (!value) {
1503 PyErr_SetString(PyExc_ValueError,
1504 "field value is required for Repr");
1505 return NULL;
1506 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001507 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001508 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001509 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001510 return NULL;
1511 }
1512 p->kind = Repr_kind;
1513 p->v.Repr.value = value;
1514 p->lineno = lineno;
1515 return p;
1516}
1517
1518expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001519Num(object n, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001520{
1521 expr_ty p;
1522 if (!n) {
1523 PyErr_SetString(PyExc_ValueError,
1524 "field n is required for Num");
1525 return NULL;
1526 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001527 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001528 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001529 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001530 return NULL;
1531 }
1532 p->kind = Num_kind;
1533 p->v.Num.n = n;
1534 p->lineno = lineno;
1535 return p;
1536}
1537
1538expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001539Str(string s, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001540{
1541 expr_ty p;
1542 if (!s) {
1543 PyErr_SetString(PyExc_ValueError,
1544 "field s is required for Str");
1545 return NULL;
1546 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001547 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001548 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001549 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001550 return NULL;
1551 }
1552 p->kind = Str_kind;
1553 p->v.Str.s = s;
1554 p->lineno = lineno;
1555 return p;
1556}
1557
1558expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001559Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno,
1560 PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001561{
1562 expr_ty p;
1563 if (!value) {
1564 PyErr_SetString(PyExc_ValueError,
1565 "field value is required for Attribute");
1566 return NULL;
1567 }
1568 if (!attr) {
1569 PyErr_SetString(PyExc_ValueError,
1570 "field attr is required for Attribute");
1571 return NULL;
1572 }
1573 if (!ctx) {
1574 PyErr_SetString(PyExc_ValueError,
1575 "field ctx is required for Attribute");
1576 return NULL;
1577 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001578 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001579 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001580 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001581 return NULL;
1582 }
1583 p->kind = Attribute_kind;
1584 p->v.Attribute.value = value;
1585 p->v.Attribute.attr = attr;
1586 p->v.Attribute.ctx = ctx;
1587 p->lineno = lineno;
1588 return p;
1589}
1590
1591expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001592Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno,
1593 PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001594{
1595 expr_ty p;
1596 if (!value) {
1597 PyErr_SetString(PyExc_ValueError,
1598 "field value is required for Subscript");
1599 return NULL;
1600 }
1601 if (!slice) {
1602 PyErr_SetString(PyExc_ValueError,
1603 "field slice is required for Subscript");
1604 return NULL;
1605 }
1606 if (!ctx) {
1607 PyErr_SetString(PyExc_ValueError,
1608 "field ctx is required for Subscript");
1609 return NULL;
1610 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001611 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001612 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001613 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001614 return NULL;
1615 }
1616 p->kind = Subscript_kind;
1617 p->v.Subscript.value = value;
1618 p->v.Subscript.slice = slice;
1619 p->v.Subscript.ctx = ctx;
1620 p->lineno = lineno;
1621 return p;
1622}
1623
1624expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001625Name(identifier id, expr_context_ty ctx, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001626{
1627 expr_ty p;
1628 if (!id) {
1629 PyErr_SetString(PyExc_ValueError,
1630 "field id is required for Name");
1631 return NULL;
1632 }
1633 if (!ctx) {
1634 PyErr_SetString(PyExc_ValueError,
1635 "field ctx is required for Name");
1636 return NULL;
1637 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001638 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001639 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001640 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001641 return NULL;
1642 }
1643 p->kind = Name_kind;
1644 p->v.Name.id = id;
1645 p->v.Name.ctx = ctx;
1646 p->lineno = lineno;
1647 return p;
1648}
1649
1650expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001651List(asdl_seq * elts, expr_context_ty ctx, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001652{
1653 expr_ty p;
1654 if (!ctx) {
1655 PyErr_SetString(PyExc_ValueError,
1656 "field ctx is required for List");
1657 return NULL;
1658 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001659 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001660 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001661 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001662 return NULL;
1663 }
1664 p->kind = List_kind;
1665 p->v.List.elts = elts;
1666 p->v.List.ctx = ctx;
1667 p->lineno = lineno;
1668 return p;
1669}
1670
1671expr_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001672Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001673{
1674 expr_ty p;
1675 if (!ctx) {
1676 PyErr_SetString(PyExc_ValueError,
1677 "field ctx is required for Tuple");
1678 return NULL;
1679 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001680 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001681 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001682 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001683 return NULL;
1684 }
1685 p->kind = Tuple_kind;
1686 p->v.Tuple.elts = elts;
1687 p->v.Tuple.ctx = ctx;
1688 p->lineno = lineno;
1689 return p;
1690}
1691
1692slice_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001693Ellipsis(PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001694{
1695 slice_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001696 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001697 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001698 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001699 return NULL;
1700 }
1701 p->kind = Ellipsis_kind;
1702 return p;
1703}
1704
1705slice_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001706Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001707{
1708 slice_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001709 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001710 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001711 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001712 return NULL;
1713 }
1714 p->kind = Slice_kind;
1715 p->v.Slice.lower = lower;
1716 p->v.Slice.upper = upper;
1717 p->v.Slice.step = step;
1718 return p;
1719}
1720
1721slice_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001722ExtSlice(asdl_seq * dims, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001723{
1724 slice_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001725 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001726 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001727 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001728 return NULL;
1729 }
1730 p->kind = ExtSlice_kind;
1731 p->v.ExtSlice.dims = dims;
1732 return p;
1733}
1734
1735slice_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001736Index(expr_ty value, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001737{
1738 slice_ty p;
1739 if (!value) {
1740 PyErr_SetString(PyExc_ValueError,
1741 "field value is required for Index");
1742 return NULL;
1743 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001744 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001745 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001746 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001747 return NULL;
1748 }
1749 p->kind = Index_kind;
1750 p->v.Index.value = value;
1751 return p;
1752}
1753
1754comprehension_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001755comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001756{
1757 comprehension_ty p;
1758 if (!target) {
1759 PyErr_SetString(PyExc_ValueError,
1760 "field target is required for comprehension");
1761 return NULL;
1762 }
1763 if (!iter) {
1764 PyErr_SetString(PyExc_ValueError,
1765 "field iter is required for comprehension");
1766 return NULL;
1767 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001768 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001769 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001770 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001771 return NULL;
1772 }
1773 p->target = target;
1774 p->iter = iter;
1775 p->ifs = ifs;
1776 return p;
1777}
1778
1779excepthandler_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001780excepthandler(expr_ty type, expr_ty name, asdl_seq * body, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001781{
1782 excepthandler_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001783 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001784 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001785 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001786 return NULL;
1787 }
1788 p->type = type;
1789 p->name = name;
1790 p->body = body;
1791 return p;
1792}
1793
1794arguments_ty
1795arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq *
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001796 defaults, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001797{
1798 arguments_ty p;
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001799 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001800 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001801 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001802 return NULL;
1803 }
1804 p->args = args;
1805 p->vararg = vararg;
1806 p->kwarg = kwarg;
1807 p->defaults = defaults;
1808 return p;
1809}
1810
1811keyword_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001812keyword(identifier arg, expr_ty value, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001813{
1814 keyword_ty p;
1815 if (!arg) {
1816 PyErr_SetString(PyExc_ValueError,
1817 "field arg is required for keyword");
1818 return NULL;
1819 }
1820 if (!value) {
1821 PyErr_SetString(PyExc_ValueError,
1822 "field value is required for keyword");
1823 return NULL;
1824 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001825 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001826 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001827 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001828 return NULL;
1829 }
1830 p->arg = arg;
1831 p->value = value;
1832 return p;
1833}
1834
1835alias_ty
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001836alias(identifier name, identifier asname, PyArena *arena)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001837{
1838 alias_ty p;
1839 if (!name) {
1840 PyErr_SetString(PyExc_ValueError,
1841 "field name is required for alias");
1842 return NULL;
1843 }
Neal Norwitzadb69fc2005-12-17 20:54:49 +00001844 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001845 if (!p) {
Neal Norwitz12ebfd72005-10-23 19:22:48 +00001846 PyErr_NoMemory();
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001847 return NULL;
1848 }
1849 p->name = name;
1850 p->asname = asname;
1851 return p;
1852}
1853
Neal Norwitz7b5a6042005-11-13 19:14:20 +00001854
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001855PyObject*
1856ast2obj_mod(void* _o)
Neal Norwitz7b5a6042005-11-13 19:14:20 +00001857{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001858 mod_ty o = (mod_ty)_o;
1859 PyObject *result = NULL, *value = NULL;
1860 if (!o) {
1861 Py_INCREF(Py_None);
1862 return Py_None;
1863 }
Neal Norwitz7b5a6042005-11-13 19:14:20 +00001864
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001865 switch (o->kind) {
1866 case Module_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001867 result = PyType_GenericNew(Module_type, NULL, NULL);
1868 if (!result) goto failed;
1869 value = ast2obj_list(o->v.Module.body, ast2obj_stmt);
1870 if (!value) goto failed;
1871 if (PyObject_SetAttrString(result, "body", value) == -1)
1872 goto failed;
1873 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001874 break;
1875 case Interactive_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001876 result = PyType_GenericNew(Interactive_type, NULL, NULL);
1877 if (!result) goto failed;
1878 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt);
1879 if (!value) goto failed;
1880 if (PyObject_SetAttrString(result, "body", value) == -1)
1881 goto failed;
1882 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001883 break;
1884 case Expression_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001885 result = PyType_GenericNew(Expression_type, NULL, NULL);
1886 if (!result) goto failed;
1887 value = ast2obj_expr(o->v.Expression.body);
1888 if (!value) goto failed;
1889 if (PyObject_SetAttrString(result, "body", value) == -1)
1890 goto failed;
1891 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001892 break;
1893 case Suite_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001894 result = PyType_GenericNew(Suite_type, NULL, NULL);
1895 if (!result) goto failed;
1896 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt);
1897 if (!value) goto failed;
1898 if (PyObject_SetAttrString(result, "body", value) == -1)
1899 goto failed;
1900 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001901 break;
1902 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001903 return result;
1904failed:
1905 Py_XDECREF(value);
1906 Py_XDECREF(result);
1907 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001908}
1909
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001910PyObject*
1911ast2obj_stmt(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001912{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001913 stmt_ty o = (stmt_ty)_o;
1914 PyObject *result = NULL, *value = NULL;
1915 if (!o) {
1916 Py_INCREF(Py_None);
1917 return Py_None;
1918 }
1919
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001920 switch (o->kind) {
1921 case FunctionDef_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001922 result = PyType_GenericNew(FunctionDef_type, NULL, NULL);
1923 if (!result) goto failed;
1924 value = ast2obj_identifier(o->v.FunctionDef.name);
1925 if (!value) goto failed;
1926 if (PyObject_SetAttrString(result, "name", value) == -1)
1927 goto failed;
1928 Py_DECREF(value);
1929 value = ast2obj_arguments(o->v.FunctionDef.args);
1930 if (!value) goto failed;
1931 if (PyObject_SetAttrString(result, "args", value) == -1)
1932 goto failed;
1933 Py_DECREF(value);
1934 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt);
1935 if (!value) goto failed;
1936 if (PyObject_SetAttrString(result, "body", value) == -1)
1937 goto failed;
1938 Py_DECREF(value);
1939 value = ast2obj_list(o->v.FunctionDef.decorators, ast2obj_expr);
1940 if (!value) goto failed;
1941 if (PyObject_SetAttrString(result, "decorators", value) == -1)
1942 goto failed;
1943 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001944 break;
1945 case ClassDef_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001946 result = PyType_GenericNew(ClassDef_type, NULL, NULL);
1947 if (!result) goto failed;
1948 value = ast2obj_identifier(o->v.ClassDef.name);
1949 if (!value) goto failed;
1950 if (PyObject_SetAttrString(result, "name", value) == -1)
1951 goto failed;
1952 Py_DECREF(value);
1953 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr);
1954 if (!value) goto failed;
1955 if (PyObject_SetAttrString(result, "bases", value) == -1)
1956 goto failed;
1957 Py_DECREF(value);
1958 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt);
1959 if (!value) goto failed;
1960 if (PyObject_SetAttrString(result, "body", value) == -1)
1961 goto failed;
1962 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001963 break;
1964 case Return_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001965 result = PyType_GenericNew(Return_type, NULL, NULL);
1966 if (!result) goto failed;
1967 value = ast2obj_expr(o->v.Return.value);
1968 if (!value) goto failed;
1969 if (PyObject_SetAttrString(result, "value", value) == -1)
1970 goto failed;
1971 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001972 break;
1973 case Delete_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001974 result = PyType_GenericNew(Delete_type, NULL, NULL);
1975 if (!result) goto failed;
1976 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr);
1977 if (!value) goto failed;
1978 if (PyObject_SetAttrString(result, "targets", value) == -1)
1979 goto failed;
1980 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001981 break;
1982 case Assign_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001983 result = PyType_GenericNew(Assign_type, NULL, NULL);
1984 if (!result) goto failed;
1985 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr);
1986 if (!value) goto failed;
1987 if (PyObject_SetAttrString(result, "targets", value) == -1)
1988 goto failed;
1989 Py_DECREF(value);
1990 value = ast2obj_expr(o->v.Assign.value);
1991 if (!value) goto failed;
1992 if (PyObject_SetAttrString(result, "value", value) == -1)
1993 goto failed;
1994 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00001995 break;
1996 case AugAssign_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00001997 result = PyType_GenericNew(AugAssign_type, NULL, NULL);
1998 if (!result) goto failed;
1999 value = ast2obj_expr(o->v.AugAssign.target);
2000 if (!value) goto failed;
2001 if (PyObject_SetAttrString(result, "target", value) == -1)
2002 goto failed;
2003 Py_DECREF(value);
2004 value = ast2obj_operator(o->v.AugAssign.op);
2005 if (!value) goto failed;
2006 if (PyObject_SetAttrString(result, "op", value) == -1)
2007 goto failed;
2008 Py_DECREF(value);
2009 value = ast2obj_expr(o->v.AugAssign.value);
2010 if (!value) goto failed;
2011 if (PyObject_SetAttrString(result, "value", value) == -1)
2012 goto failed;
2013 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002014 break;
2015 case Print_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002016 result = PyType_GenericNew(Print_type, NULL, NULL);
2017 if (!result) goto failed;
2018 value = ast2obj_expr(o->v.Print.dest);
2019 if (!value) goto failed;
2020 if (PyObject_SetAttrString(result, "dest", value) == -1)
2021 goto failed;
2022 Py_DECREF(value);
2023 value = ast2obj_list(o->v.Print.values, ast2obj_expr);
2024 if (!value) goto failed;
2025 if (PyObject_SetAttrString(result, "values", value) == -1)
2026 goto failed;
2027 Py_DECREF(value);
2028 value = ast2obj_bool(o->v.Print.nl);
2029 if (!value) goto failed;
2030 if (PyObject_SetAttrString(result, "nl", value) == -1)
2031 goto failed;
2032 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002033 break;
2034 case For_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002035 result = PyType_GenericNew(For_type, NULL, NULL);
2036 if (!result) goto failed;
2037 value = ast2obj_expr(o->v.For.target);
2038 if (!value) goto failed;
2039 if (PyObject_SetAttrString(result, "target", value) == -1)
2040 goto failed;
2041 Py_DECREF(value);
2042 value = ast2obj_expr(o->v.For.iter);
2043 if (!value) goto failed;
2044 if (PyObject_SetAttrString(result, "iter", value) == -1)
2045 goto failed;
2046 Py_DECREF(value);
2047 value = ast2obj_list(o->v.For.body, ast2obj_stmt);
2048 if (!value) goto failed;
2049 if (PyObject_SetAttrString(result, "body", value) == -1)
2050 goto failed;
2051 Py_DECREF(value);
2052 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt);
2053 if (!value) goto failed;
2054 if (PyObject_SetAttrString(result, "orelse", value) == -1)
2055 goto failed;
2056 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002057 break;
2058 case While_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002059 result = PyType_GenericNew(While_type, NULL, NULL);
2060 if (!result) goto failed;
2061 value = ast2obj_expr(o->v.While.test);
2062 if (!value) goto failed;
2063 if (PyObject_SetAttrString(result, "test", value) == -1)
2064 goto failed;
2065 Py_DECREF(value);
2066 value = ast2obj_list(o->v.While.body, ast2obj_stmt);
2067 if (!value) goto failed;
2068 if (PyObject_SetAttrString(result, "body", value) == -1)
2069 goto failed;
2070 Py_DECREF(value);
2071 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt);
2072 if (!value) goto failed;
2073 if (PyObject_SetAttrString(result, "orelse", value) == -1)
2074 goto failed;
2075 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002076 break;
2077 case If_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002078 result = PyType_GenericNew(If_type, NULL, NULL);
2079 if (!result) goto failed;
2080 value = ast2obj_expr(o->v.If.test);
2081 if (!value) goto failed;
2082 if (PyObject_SetAttrString(result, "test", value) == -1)
2083 goto failed;
2084 Py_DECREF(value);
2085 value = ast2obj_list(o->v.If.body, ast2obj_stmt);
2086 if (!value) goto failed;
2087 if (PyObject_SetAttrString(result, "body", value) == -1)
2088 goto failed;
2089 Py_DECREF(value);
2090 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt);
2091 if (!value) goto failed;
2092 if (PyObject_SetAttrString(result, "orelse", value) == -1)
2093 goto failed;
2094 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002095 break;
Guido van Rossumc2e20742006-02-27 22:32:47 +00002096 case With_kind:
2097 result = PyType_GenericNew(With_type, NULL, NULL);
2098 if (!result) goto failed;
2099 value = ast2obj_expr(o->v.With.context_expr);
2100 if (!value) goto failed;
2101 if (PyObject_SetAttrString(result, "context_expr", value) == -1)
2102 goto failed;
2103 Py_DECREF(value);
2104 value = ast2obj_expr(o->v.With.optional_vars);
2105 if (!value) goto failed;
2106 if (PyObject_SetAttrString(result, "optional_vars", value) ==
2107 -1)
2108 goto failed;
2109 Py_DECREF(value);
2110 value = ast2obj_list(o->v.With.body, ast2obj_stmt);
2111 if (!value) goto failed;
2112 if (PyObject_SetAttrString(result, "body", value) == -1)
2113 goto failed;
2114 Py_DECREF(value);
2115 break;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002116 case Raise_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002117 result = PyType_GenericNew(Raise_type, NULL, NULL);
2118 if (!result) goto failed;
2119 value = ast2obj_expr(o->v.Raise.type);
2120 if (!value) goto failed;
2121 if (PyObject_SetAttrString(result, "type", value) == -1)
2122 goto failed;
2123 Py_DECREF(value);
2124 value = ast2obj_expr(o->v.Raise.inst);
2125 if (!value) goto failed;
2126 if (PyObject_SetAttrString(result, "inst", value) == -1)
2127 goto failed;
2128 Py_DECREF(value);
2129 value = ast2obj_expr(o->v.Raise.tback);
2130 if (!value) goto failed;
2131 if (PyObject_SetAttrString(result, "tback", value) == -1)
2132 goto failed;
2133 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002134 break;
2135 case TryExcept_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002136 result = PyType_GenericNew(TryExcept_type, NULL, NULL);
2137 if (!result) goto failed;
2138 value = ast2obj_list(o->v.TryExcept.body, ast2obj_stmt);
2139 if (!value) goto failed;
2140 if (PyObject_SetAttrString(result, "body", value) == -1)
2141 goto failed;
2142 Py_DECREF(value);
2143 value = ast2obj_list(o->v.TryExcept.handlers,
2144 ast2obj_excepthandler);
2145 if (!value) goto failed;
2146 if (PyObject_SetAttrString(result, "handlers", value) == -1)
2147 goto failed;
2148 Py_DECREF(value);
2149 value = ast2obj_list(o->v.TryExcept.orelse, ast2obj_stmt);
2150 if (!value) goto failed;
2151 if (PyObject_SetAttrString(result, "orelse", value) == -1)
2152 goto failed;
2153 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002154 break;
2155 case TryFinally_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002156 result = PyType_GenericNew(TryFinally_type, NULL, NULL);
2157 if (!result) goto failed;
2158 value = ast2obj_list(o->v.TryFinally.body, ast2obj_stmt);
2159 if (!value) goto failed;
2160 if (PyObject_SetAttrString(result, "body", value) == -1)
2161 goto failed;
2162 Py_DECREF(value);
2163 value = ast2obj_list(o->v.TryFinally.finalbody, ast2obj_stmt);
2164 if (!value) goto failed;
2165 if (PyObject_SetAttrString(result, "finalbody", value) == -1)
2166 goto failed;
2167 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002168 break;
2169 case Assert_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002170 result = PyType_GenericNew(Assert_type, NULL, NULL);
2171 if (!result) goto failed;
2172 value = ast2obj_expr(o->v.Assert.test);
2173 if (!value) goto failed;
2174 if (PyObject_SetAttrString(result, "test", value) == -1)
2175 goto failed;
2176 Py_DECREF(value);
2177 value = ast2obj_expr(o->v.Assert.msg);
2178 if (!value) goto failed;
2179 if (PyObject_SetAttrString(result, "msg", value) == -1)
2180 goto failed;
2181 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002182 break;
2183 case Import_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002184 result = PyType_GenericNew(Import_type, NULL, NULL);
2185 if (!result) goto failed;
2186 value = ast2obj_list(o->v.Import.names, ast2obj_alias);
2187 if (!value) goto failed;
2188 if (PyObject_SetAttrString(result, "names", value) == -1)
2189 goto failed;
2190 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002191 break;
2192 case ImportFrom_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002193 result = PyType_GenericNew(ImportFrom_type, NULL, NULL);
2194 if (!result) goto failed;
2195 value = ast2obj_identifier(o->v.ImportFrom.module);
2196 if (!value) goto failed;
2197 if (PyObject_SetAttrString(result, "module", value) == -1)
2198 goto failed;
2199 Py_DECREF(value);
2200 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias);
2201 if (!value) goto failed;
2202 if (PyObject_SetAttrString(result, "names", value) == -1)
2203 goto failed;
2204 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002205 break;
2206 case Exec_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002207 result = PyType_GenericNew(Exec_type, NULL, NULL);
2208 if (!result) goto failed;
2209 value = ast2obj_expr(o->v.Exec.body);
2210 if (!value) goto failed;
2211 if (PyObject_SetAttrString(result, "body", value) == -1)
2212 goto failed;
2213 Py_DECREF(value);
2214 value = ast2obj_expr(o->v.Exec.globals);
2215 if (!value) goto failed;
2216 if (PyObject_SetAttrString(result, "globals", value) == -1)
2217 goto failed;
2218 Py_DECREF(value);
2219 value = ast2obj_expr(o->v.Exec.locals);
2220 if (!value) goto failed;
2221 if (PyObject_SetAttrString(result, "locals", value) == -1)
2222 goto failed;
2223 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002224 break;
2225 case Global_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002226 result = PyType_GenericNew(Global_type, NULL, NULL);
2227 if (!result) goto failed;
2228 value = ast2obj_list(o->v.Global.names, ast2obj_identifier);
2229 if (!value) goto failed;
2230 if (PyObject_SetAttrString(result, "names", value) == -1)
2231 goto failed;
2232 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002233 break;
2234 case Expr_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002235 result = PyType_GenericNew(Expr_type, NULL, NULL);
2236 if (!result) goto failed;
2237 value = ast2obj_expr(o->v.Expr.value);
2238 if (!value) goto failed;
2239 if (PyObject_SetAttrString(result, "value", value) == -1)
2240 goto failed;
2241 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002242 break;
2243 case Pass_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002244 result = PyType_GenericNew(Pass_type, NULL, NULL);
2245 if (!result) goto failed;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002246 break;
2247 case Break_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002248 result = PyType_GenericNew(Break_type, NULL, NULL);
2249 if (!result) goto failed;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002250 break;
2251 case Continue_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002252 result = PyType_GenericNew(Continue_type, NULL, NULL);
2253 if (!result) goto failed;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002254 break;
2255 }
Martin v. Löwis577b5b92006-02-27 15:23:19 +00002256 value = ast2obj_int(o->lineno);
2257 if (!value) goto failed;
2258 PyObject_SetAttrString(result, "lineno", value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002259 return result;
2260failed:
2261 Py_XDECREF(value);
2262 Py_XDECREF(result);
2263 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002264}
2265
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002266PyObject*
2267ast2obj_expr(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002268{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002269 expr_ty o = (expr_ty)_o;
2270 PyObject *result = NULL, *value = NULL;
2271 if (!o) {
2272 Py_INCREF(Py_None);
2273 return Py_None;
2274 }
2275
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002276 switch (o->kind) {
2277 case BoolOp_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002278 result = PyType_GenericNew(BoolOp_type, NULL, NULL);
2279 if (!result) goto failed;
2280 value = ast2obj_boolop(o->v.BoolOp.op);
2281 if (!value) goto failed;
2282 if (PyObject_SetAttrString(result, "op", value) == -1)
2283 goto failed;
2284 Py_DECREF(value);
2285 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr);
2286 if (!value) goto failed;
2287 if (PyObject_SetAttrString(result, "values", value) == -1)
2288 goto failed;
2289 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002290 break;
2291 case BinOp_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002292 result = PyType_GenericNew(BinOp_type, NULL, NULL);
2293 if (!result) goto failed;
2294 value = ast2obj_expr(o->v.BinOp.left);
2295 if (!value) goto failed;
2296 if (PyObject_SetAttrString(result, "left", value) == -1)
2297 goto failed;
2298 Py_DECREF(value);
2299 value = ast2obj_operator(o->v.BinOp.op);
2300 if (!value) goto failed;
2301 if (PyObject_SetAttrString(result, "op", value) == -1)
2302 goto failed;
2303 Py_DECREF(value);
2304 value = ast2obj_expr(o->v.BinOp.right);
2305 if (!value) goto failed;
2306 if (PyObject_SetAttrString(result, "right", value) == -1)
2307 goto failed;
2308 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002309 break;
2310 case UnaryOp_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002311 result = PyType_GenericNew(UnaryOp_type, NULL, NULL);
2312 if (!result) goto failed;
2313 value = ast2obj_unaryop(o->v.UnaryOp.op);
2314 if (!value) goto failed;
2315 if (PyObject_SetAttrString(result, "op", value) == -1)
2316 goto failed;
2317 Py_DECREF(value);
2318 value = ast2obj_expr(o->v.UnaryOp.operand);
2319 if (!value) goto failed;
2320 if (PyObject_SetAttrString(result, "operand", value) == -1)
2321 goto failed;
2322 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002323 break;
2324 case Lambda_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002325 result = PyType_GenericNew(Lambda_type, NULL, NULL);
2326 if (!result) goto failed;
2327 value = ast2obj_arguments(o->v.Lambda.args);
2328 if (!value) goto failed;
2329 if (PyObject_SetAttrString(result, "args", value) == -1)
2330 goto failed;
2331 Py_DECREF(value);
2332 value = ast2obj_expr(o->v.Lambda.body);
2333 if (!value) goto failed;
2334 if (PyObject_SetAttrString(result, "body", value) == -1)
2335 goto failed;
2336 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002337 break;
Thomas Woutersdca3b9c2006-02-27 00:24:13 +00002338 case IfExp_kind:
2339 result = PyType_GenericNew(IfExp_type, NULL, NULL);
2340 if (!result) goto failed;
2341 value = ast2obj_expr(o->v.IfExp.test);
2342 if (!value) goto failed;
2343 if (PyObject_SetAttrString(result, "test", value) == -1)
2344 goto failed;
2345 Py_DECREF(value);
2346 value = ast2obj_expr(o->v.IfExp.body);
2347 if (!value) goto failed;
2348 if (PyObject_SetAttrString(result, "body", value) == -1)
2349 goto failed;
2350 Py_DECREF(value);
2351 value = ast2obj_expr(o->v.IfExp.orelse);
2352 if (!value) goto failed;
2353 if (PyObject_SetAttrString(result, "orelse", value) == -1)
2354 goto failed;
2355 Py_DECREF(value);
2356 break;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002357 case Dict_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002358 result = PyType_GenericNew(Dict_type, NULL, NULL);
2359 if (!result) goto failed;
2360 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr);
2361 if (!value) goto failed;
2362 if (PyObject_SetAttrString(result, "keys", value) == -1)
2363 goto failed;
2364 Py_DECREF(value);
2365 value = ast2obj_list(o->v.Dict.values, ast2obj_expr);
2366 if (!value) goto failed;
2367 if (PyObject_SetAttrString(result, "values", value) == -1)
2368 goto failed;
2369 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002370 break;
2371 case ListComp_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002372 result = PyType_GenericNew(ListComp_type, NULL, NULL);
2373 if (!result) goto failed;
2374 value = ast2obj_expr(o->v.ListComp.elt);
2375 if (!value) goto failed;
2376 if (PyObject_SetAttrString(result, "elt", value) == -1)
2377 goto failed;
2378 Py_DECREF(value);
2379 value = ast2obj_list(o->v.ListComp.generators,
2380 ast2obj_comprehension);
2381 if (!value) goto failed;
2382 if (PyObject_SetAttrString(result, "generators", value) == -1)
2383 goto failed;
2384 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002385 break;
2386 case GeneratorExp_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002387 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL);
2388 if (!result) goto failed;
2389 value = ast2obj_expr(o->v.GeneratorExp.elt);
2390 if (!value) goto failed;
2391 if (PyObject_SetAttrString(result, "elt", value) == -1)
2392 goto failed;
2393 Py_DECREF(value);
2394 value = ast2obj_list(o->v.GeneratorExp.generators,
2395 ast2obj_comprehension);
2396 if (!value) goto failed;
2397 if (PyObject_SetAttrString(result, "generators", value) == -1)
2398 goto failed;
2399 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002400 break;
2401 case Yield_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002402 result = PyType_GenericNew(Yield_type, NULL, NULL);
2403 if (!result) goto failed;
2404 value = ast2obj_expr(o->v.Yield.value);
2405 if (!value) goto failed;
2406 if (PyObject_SetAttrString(result, "value", value) == -1)
2407 goto failed;
2408 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002409 break;
2410 case Compare_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002411 result = PyType_GenericNew(Compare_type, NULL, NULL);
2412 if (!result) goto failed;
2413 value = ast2obj_expr(o->v.Compare.left);
2414 if (!value) goto failed;
2415 if (PyObject_SetAttrString(result, "left", value) == -1)
2416 goto failed;
2417 Py_DECREF(value);
Martin v. Löwisce1d5d22006-02-26 20:51:25 +00002418 {
2419 int i, n = asdl_seq_LEN(o->v.Compare.ops);
2420 value = PyList_New(n);
2421 if (!value) goto failed;
2422 for(i = 0; i < n; i++)
2423 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
2424 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002425 if (!value) goto failed;
2426 if (PyObject_SetAttrString(result, "ops", value) == -1)
2427 goto failed;
2428 Py_DECREF(value);
2429 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr);
2430 if (!value) goto failed;
2431 if (PyObject_SetAttrString(result, "comparators", value) == -1)
2432 goto failed;
2433 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002434 break;
2435 case Call_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002436 result = PyType_GenericNew(Call_type, NULL, NULL);
2437 if (!result) goto failed;
2438 value = ast2obj_expr(o->v.Call.func);
2439 if (!value) goto failed;
2440 if (PyObject_SetAttrString(result, "func", value) == -1)
2441 goto failed;
2442 Py_DECREF(value);
2443 value = ast2obj_list(o->v.Call.args, ast2obj_expr);
2444 if (!value) goto failed;
2445 if (PyObject_SetAttrString(result, "args", value) == -1)
2446 goto failed;
2447 Py_DECREF(value);
2448 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword);
2449 if (!value) goto failed;
2450 if (PyObject_SetAttrString(result, "keywords", value) == -1)
2451 goto failed;
2452 Py_DECREF(value);
2453 value = ast2obj_expr(o->v.Call.starargs);
2454 if (!value) goto failed;
2455 if (PyObject_SetAttrString(result, "starargs", value) == -1)
2456 goto failed;
2457 Py_DECREF(value);
2458 value = ast2obj_expr(o->v.Call.kwargs);
2459 if (!value) goto failed;
2460 if (PyObject_SetAttrString(result, "kwargs", value) == -1)
2461 goto failed;
2462 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002463 break;
2464 case Repr_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002465 result = PyType_GenericNew(Repr_type, NULL, NULL);
2466 if (!result) goto failed;
2467 value = ast2obj_expr(o->v.Repr.value);
2468 if (!value) goto failed;
2469 if (PyObject_SetAttrString(result, "value", value) == -1)
2470 goto failed;
2471 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002472 break;
2473 case Num_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002474 result = PyType_GenericNew(Num_type, NULL, NULL);
2475 if (!result) goto failed;
2476 value = ast2obj_object(o->v.Num.n);
2477 if (!value) goto failed;
2478 if (PyObject_SetAttrString(result, "n", value) == -1)
2479 goto failed;
2480 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002481 break;
2482 case Str_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002483 result = PyType_GenericNew(Str_type, NULL, NULL);
2484 if (!result) goto failed;
2485 value = ast2obj_string(o->v.Str.s);
2486 if (!value) goto failed;
2487 if (PyObject_SetAttrString(result, "s", value) == -1)
2488 goto failed;
2489 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002490 break;
2491 case Attribute_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002492 result = PyType_GenericNew(Attribute_type, NULL, NULL);
2493 if (!result) goto failed;
2494 value = ast2obj_expr(o->v.Attribute.value);
2495 if (!value) goto failed;
2496 if (PyObject_SetAttrString(result, "value", value) == -1)
2497 goto failed;
2498 Py_DECREF(value);
2499 value = ast2obj_identifier(o->v.Attribute.attr);
2500 if (!value) goto failed;
2501 if (PyObject_SetAttrString(result, "attr", value) == -1)
2502 goto failed;
2503 Py_DECREF(value);
2504 value = ast2obj_expr_context(o->v.Attribute.ctx);
2505 if (!value) goto failed;
2506 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2507 goto failed;
2508 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002509 break;
2510 case Subscript_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002511 result = PyType_GenericNew(Subscript_type, NULL, NULL);
2512 if (!result) goto failed;
2513 value = ast2obj_expr(o->v.Subscript.value);
2514 if (!value) goto failed;
2515 if (PyObject_SetAttrString(result, "value", value) == -1)
2516 goto failed;
2517 Py_DECREF(value);
2518 value = ast2obj_slice(o->v.Subscript.slice);
2519 if (!value) goto failed;
2520 if (PyObject_SetAttrString(result, "slice", value) == -1)
2521 goto failed;
2522 Py_DECREF(value);
2523 value = ast2obj_expr_context(o->v.Subscript.ctx);
2524 if (!value) goto failed;
2525 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2526 goto failed;
2527 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002528 break;
2529 case Name_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002530 result = PyType_GenericNew(Name_type, NULL, NULL);
2531 if (!result) goto failed;
2532 value = ast2obj_identifier(o->v.Name.id);
2533 if (!value) goto failed;
2534 if (PyObject_SetAttrString(result, "id", value) == -1)
2535 goto failed;
2536 Py_DECREF(value);
2537 value = ast2obj_expr_context(o->v.Name.ctx);
2538 if (!value) goto failed;
2539 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2540 goto failed;
2541 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002542 break;
2543 case List_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002544 result = PyType_GenericNew(List_type, NULL, NULL);
2545 if (!result) goto failed;
2546 value = ast2obj_list(o->v.List.elts, ast2obj_expr);
2547 if (!value) goto failed;
2548 if (PyObject_SetAttrString(result, "elts", value) == -1)
2549 goto failed;
2550 Py_DECREF(value);
2551 value = ast2obj_expr_context(o->v.List.ctx);
2552 if (!value) goto failed;
2553 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2554 goto failed;
2555 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002556 break;
2557 case Tuple_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002558 result = PyType_GenericNew(Tuple_type, NULL, NULL);
2559 if (!result) goto failed;
2560 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr);
2561 if (!value) goto failed;
2562 if (PyObject_SetAttrString(result, "elts", value) == -1)
2563 goto failed;
2564 Py_DECREF(value);
2565 value = ast2obj_expr_context(o->v.Tuple.ctx);
2566 if (!value) goto failed;
2567 if (PyObject_SetAttrString(result, "ctx", value) == -1)
2568 goto failed;
2569 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002570 break;
2571 }
Martin v. Löwis577b5b92006-02-27 15:23:19 +00002572 value = ast2obj_int(o->lineno);
2573 if (!value) goto failed;
2574 PyObject_SetAttrString(result, "lineno", value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002575 return result;
2576failed:
2577 Py_XDECREF(value);
2578 Py_XDECREF(result);
2579 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002580}
2581
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002582PyObject* ast2obj_expr_context(expr_context_ty o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002583{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002584 switch(o) {
2585 case Load:
2586 Py_INCREF(Load_singleton);
2587 return Load_singleton;
2588 case Store:
2589 Py_INCREF(Store_singleton);
2590 return Store_singleton;
2591 case Del:
2592 Py_INCREF(Del_singleton);
2593 return Del_singleton;
2594 case AugLoad:
2595 Py_INCREF(AugLoad_singleton);
2596 return AugLoad_singleton;
2597 case AugStore:
2598 Py_INCREF(AugStore_singleton);
2599 return AugStore_singleton;
2600 case Param:
2601 Py_INCREF(Param_singleton);
2602 return Param_singleton;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002603 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002604 return NULL; /* cannot happen */
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002605}
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002606PyObject*
2607ast2obj_slice(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002608{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002609 slice_ty o = (slice_ty)_o;
2610 PyObject *result = NULL, *value = NULL;
2611 if (!o) {
2612 Py_INCREF(Py_None);
2613 return Py_None;
2614 }
2615
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002616 switch (o->kind) {
2617 case Ellipsis_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002618 result = PyType_GenericNew(Ellipsis_type, NULL, NULL);
2619 if (!result) goto failed;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002620 break;
2621 case Slice_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002622 result = PyType_GenericNew(Slice_type, NULL, NULL);
2623 if (!result) goto failed;
2624 value = ast2obj_expr(o->v.Slice.lower);
2625 if (!value) goto failed;
2626 if (PyObject_SetAttrString(result, "lower", value) == -1)
2627 goto failed;
2628 Py_DECREF(value);
2629 value = ast2obj_expr(o->v.Slice.upper);
2630 if (!value) goto failed;
2631 if (PyObject_SetAttrString(result, "upper", value) == -1)
2632 goto failed;
2633 Py_DECREF(value);
2634 value = ast2obj_expr(o->v.Slice.step);
2635 if (!value) goto failed;
2636 if (PyObject_SetAttrString(result, "step", value) == -1)
2637 goto failed;
2638 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002639 break;
2640 case ExtSlice_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002641 result = PyType_GenericNew(ExtSlice_type, NULL, NULL);
2642 if (!result) goto failed;
2643 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);
2644 if (!value) goto failed;
2645 if (PyObject_SetAttrString(result, "dims", value) == -1)
2646 goto failed;
2647 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002648 break;
2649 case Index_kind:
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002650 result = PyType_GenericNew(Index_type, NULL, NULL);
2651 if (!result) goto failed;
2652 value = ast2obj_expr(o->v.Index.value);
2653 if (!value) goto failed;
2654 if (PyObject_SetAttrString(result, "value", value) == -1)
2655 goto failed;
2656 Py_DECREF(value);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002657 break;
2658 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002659 return result;
2660failed:
2661 Py_XDECREF(value);
2662 Py_XDECREF(result);
2663 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002664}
2665
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002666PyObject* ast2obj_boolop(boolop_ty o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002667{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002668 switch(o) {
2669 case And:
2670 Py_INCREF(And_singleton);
2671 return And_singleton;
2672 case Or:
2673 Py_INCREF(Or_singleton);
2674 return Or_singleton;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002675 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002676 return NULL; /* cannot happen */
2677}
2678PyObject* ast2obj_operator(operator_ty o)
2679{
2680 switch(o) {
2681 case Add:
2682 Py_INCREF(Add_singleton);
2683 return Add_singleton;
2684 case Sub:
2685 Py_INCREF(Sub_singleton);
2686 return Sub_singleton;
2687 case Mult:
2688 Py_INCREF(Mult_singleton);
2689 return Mult_singleton;
2690 case Div:
2691 Py_INCREF(Div_singleton);
2692 return Div_singleton;
2693 case Mod:
2694 Py_INCREF(Mod_singleton);
2695 return Mod_singleton;
2696 case Pow:
2697 Py_INCREF(Pow_singleton);
2698 return Pow_singleton;
2699 case LShift:
2700 Py_INCREF(LShift_singleton);
2701 return LShift_singleton;
2702 case RShift:
2703 Py_INCREF(RShift_singleton);
2704 return RShift_singleton;
2705 case BitOr:
2706 Py_INCREF(BitOr_singleton);
2707 return BitOr_singleton;
2708 case BitXor:
2709 Py_INCREF(BitXor_singleton);
2710 return BitXor_singleton;
2711 case BitAnd:
2712 Py_INCREF(BitAnd_singleton);
2713 return BitAnd_singleton;
2714 case FloorDiv:
2715 Py_INCREF(FloorDiv_singleton);
2716 return FloorDiv_singleton;
2717 }
2718 return NULL; /* cannot happen */
2719}
2720PyObject* ast2obj_unaryop(unaryop_ty o)
2721{
2722 switch(o) {
2723 case Invert:
2724 Py_INCREF(Invert_singleton);
2725 return Invert_singleton;
2726 case Not:
2727 Py_INCREF(Not_singleton);
2728 return Not_singleton;
2729 case UAdd:
2730 Py_INCREF(UAdd_singleton);
2731 return UAdd_singleton;
2732 case USub:
2733 Py_INCREF(USub_singleton);
2734 return USub_singleton;
2735 }
2736 return NULL; /* cannot happen */
2737}
2738PyObject* ast2obj_cmpop(cmpop_ty o)
2739{
2740 switch(o) {
2741 case Eq:
2742 Py_INCREF(Eq_singleton);
2743 return Eq_singleton;
2744 case NotEq:
2745 Py_INCREF(NotEq_singleton);
2746 return NotEq_singleton;
2747 case Lt:
2748 Py_INCREF(Lt_singleton);
2749 return Lt_singleton;
2750 case LtE:
2751 Py_INCREF(LtE_singleton);
2752 return LtE_singleton;
2753 case Gt:
2754 Py_INCREF(Gt_singleton);
2755 return Gt_singleton;
2756 case GtE:
2757 Py_INCREF(GtE_singleton);
2758 return GtE_singleton;
2759 case Is:
2760 Py_INCREF(Is_singleton);
2761 return Is_singleton;
2762 case IsNot:
2763 Py_INCREF(IsNot_singleton);
2764 return IsNot_singleton;
2765 case In:
2766 Py_INCREF(In_singleton);
2767 return In_singleton;
2768 case NotIn:
2769 Py_INCREF(NotIn_singleton);
2770 return NotIn_singleton;
2771 }
2772 return NULL; /* cannot happen */
2773}
2774PyObject*
2775ast2obj_comprehension(void* _o)
2776{
2777 comprehension_ty o = (comprehension_ty)_o;
2778 PyObject *result = NULL, *value = NULL;
2779 if (!o) {
2780 Py_INCREF(Py_None);
2781 return Py_None;
2782 }
2783
2784 result = PyType_GenericNew(comprehension_type, NULL, NULL);
2785 if (!result) return NULL;
2786 value = ast2obj_expr(o->target);
2787 if (!value) goto failed;
2788 if (PyObject_SetAttrString(result, "target", value) == -1)
2789 goto failed;
2790 Py_DECREF(value);
2791 value = ast2obj_expr(o->iter);
2792 if (!value) goto failed;
2793 if (PyObject_SetAttrString(result, "iter", value) == -1)
2794 goto failed;
2795 Py_DECREF(value);
2796 value = ast2obj_list(o->ifs, ast2obj_expr);
2797 if (!value) goto failed;
2798 if (PyObject_SetAttrString(result, "ifs", value) == -1)
2799 goto failed;
2800 Py_DECREF(value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002801 return result;
2802failed:
2803 Py_XDECREF(value);
2804 Py_XDECREF(result);
2805 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002806}
2807
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002808PyObject*
2809ast2obj_excepthandler(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002810{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002811 excepthandler_ty o = (excepthandler_ty)_o;
2812 PyObject *result = NULL, *value = NULL;
2813 if (!o) {
2814 Py_INCREF(Py_None);
2815 return Py_None;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002816 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002817
2818 result = PyType_GenericNew(excepthandler_type, NULL, NULL);
2819 if (!result) return NULL;
2820 value = ast2obj_expr(o->type);
2821 if (!value) goto failed;
2822 if (PyObject_SetAttrString(result, "type", value) == -1)
2823 goto failed;
2824 Py_DECREF(value);
2825 value = ast2obj_expr(o->name);
2826 if (!value) goto failed;
2827 if (PyObject_SetAttrString(result, "name", value) == -1)
2828 goto failed;
2829 Py_DECREF(value);
2830 value = ast2obj_list(o->body, ast2obj_stmt);
2831 if (!value) goto failed;
2832 if (PyObject_SetAttrString(result, "body", value) == -1)
2833 goto failed;
2834 Py_DECREF(value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002835 return result;
2836failed:
2837 Py_XDECREF(value);
2838 Py_XDECREF(result);
2839 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002840}
2841
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002842PyObject*
2843ast2obj_arguments(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002844{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002845 arguments_ty o = (arguments_ty)_o;
2846 PyObject *result = NULL, *value = NULL;
2847 if (!o) {
2848 Py_INCREF(Py_None);
2849 return Py_None;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002850 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002851
2852 result = PyType_GenericNew(arguments_type, NULL, NULL);
2853 if (!result) return NULL;
2854 value = ast2obj_list(o->args, ast2obj_expr);
2855 if (!value) goto failed;
2856 if (PyObject_SetAttrString(result, "args", value) == -1)
2857 goto failed;
2858 Py_DECREF(value);
2859 value = ast2obj_identifier(o->vararg);
2860 if (!value) goto failed;
2861 if (PyObject_SetAttrString(result, "vararg", value) == -1)
2862 goto failed;
2863 Py_DECREF(value);
2864 value = ast2obj_identifier(o->kwarg);
2865 if (!value) goto failed;
2866 if (PyObject_SetAttrString(result, "kwarg", value) == -1)
2867 goto failed;
2868 Py_DECREF(value);
2869 value = ast2obj_list(o->defaults, ast2obj_expr);
2870 if (!value) goto failed;
2871 if (PyObject_SetAttrString(result, "defaults", value) == -1)
2872 goto failed;
2873 Py_DECREF(value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002874 return result;
2875failed:
2876 Py_XDECREF(value);
2877 Py_XDECREF(result);
2878 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002879}
2880
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002881PyObject*
2882ast2obj_keyword(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002883{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002884 keyword_ty o = (keyword_ty)_o;
2885 PyObject *result = NULL, *value = NULL;
2886 if (!o) {
2887 Py_INCREF(Py_None);
2888 return Py_None;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002889 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002890
2891 result = PyType_GenericNew(keyword_type, NULL, NULL);
2892 if (!result) return NULL;
2893 value = ast2obj_identifier(o->arg);
2894 if (!value) goto failed;
2895 if (PyObject_SetAttrString(result, "arg", value) == -1)
2896 goto failed;
2897 Py_DECREF(value);
2898 value = ast2obj_expr(o->value);
2899 if (!value) goto failed;
2900 if (PyObject_SetAttrString(result, "value", value) == -1)
2901 goto failed;
2902 Py_DECREF(value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002903 return result;
2904failed:
2905 Py_XDECREF(value);
2906 Py_XDECREF(result);
2907 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002908}
2909
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002910PyObject*
2911ast2obj_alias(void* _o)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002912{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002913 alias_ty o = (alias_ty)_o;
2914 PyObject *result = NULL, *value = NULL;
2915 if (!o) {
2916 Py_INCREF(Py_None);
2917 return Py_None;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002918 }
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002919
2920 result = PyType_GenericNew(alias_type, NULL, NULL);
2921 if (!result) return NULL;
2922 value = ast2obj_identifier(o->name);
2923 if (!value) goto failed;
2924 if (PyObject_SetAttrString(result, "name", value) == -1)
2925 goto failed;
2926 Py_DECREF(value);
2927 value = ast2obj_identifier(o->asname);
2928 if (!value) goto failed;
2929 if (PyObject_SetAttrString(result, "asname", value) == -1)
2930 goto failed;
2931 Py_DECREF(value);
Martin v. Löwisbd260da2006-02-26 19:42:26 +00002932 return result;
2933failed:
2934 Py_XDECREF(value);
2935 Py_XDECREF(result);
2936 return NULL;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002937}
2938
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002939
Martin v. Löwis577b5b92006-02-27 15:23:19 +00002940PyMODINIT_FUNC
2941init_ast(void)
2942{
2943 PyObject *m, *d;
2944 if (!init_types()) return;
2945 m = Py_InitModule3("_ast", NULL, NULL);
2946 if (!m) return;
2947 d = PyModule_GetDict(m);
2948 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
2949 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
2950 return;
2951 if(PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
2952 if(PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
2953 return;
2954 if(PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type)
2955 < 0) return;
2956 if(PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) <
2957 0) return;
2958 if(PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return;
2959 if(PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return;
2960 if(PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type)
2961 < 0) return;
2962 if(PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0)
2963 return;
2964 if(PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0)
2965 return;
2966 if(PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0)
2967 return;
2968 if(PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0)
2969 return;
2970 if(PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 0)
2971 return;
2972 if(PyDict_SetItemString(d, "Print", (PyObject*)Print_type) < 0) return;
2973 if(PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return;
2974 if(PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return;
2975 if(PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return;
Guido van Rossumc2e20742006-02-27 22:32:47 +00002976 if(PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return;
Martin v. Löwis577b5b92006-02-27 15:23:19 +00002977 if(PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return;
2978 if(PyDict_SetItemString(d, "TryExcept", (PyObject*)TryExcept_type) < 0)
2979 return;
2980 if(PyDict_SetItemString(d, "TryFinally", (PyObject*)TryFinally_type) <
2981 0) return;
2982 if(PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0)
2983 return;
2984 if(PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0)
2985 return;
2986 if(PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) <
2987 0) return;
2988 if(PyDict_SetItemString(d, "Exec", (PyObject*)Exec_type) < 0) return;
2989 if(PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0)
2990 return;
2991 if(PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return;
2992 if(PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return;
2993 if(PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return;
2994 if(PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0)
2995 return;
2996 if(PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return;
2997 if(PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0)
2998 return;
2999 if(PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return;
3000 if(PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0)
3001 return;
3002 if(PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0)
3003 return;
3004 if(PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return;
3005 if(PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return;
3006 if(PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0)
3007 return;
3008 if(PyDict_SetItemString(d, "GeneratorExp",
3009 (PyObject*)GeneratorExp_type) < 0) return;
3010 if(PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return;
3011 if(PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0)
3012 return;
3013 if(PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return;
3014 if(PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return;
3015 if(PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return;
3016 if(PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return;
3017 if(PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0)
3018 return;
3019 if(PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0)
3020 return;
3021 if(PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return;
3022 if(PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return;
3023 if(PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return;
3024 if(PyDict_SetItemString(d, "expr_context",
3025 (PyObject*)expr_context_type) < 0) return;
3026 if(PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return;
3027 if(PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return;
3028 if(PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return;
3029 if(PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0)
3030 return;
3031 if(PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0)
3032 return;
3033 if(PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return;
3034 if(PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return;
3035 if(PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0)
3036 return;
3037 if(PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return;
3038 if(PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0)
3039 return;
3040 if(PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return;
3041 if(PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0)
3042 return;
3043 if(PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return;
3044 if(PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return;
3045 if(PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0)
3046 return;
3047 if(PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return;
3048 if(PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return;
3049 if(PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return;
3050 if(PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return;
3051 if(PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return;
3052 if(PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return;
3053 if(PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0)
3054 return;
3055 if(PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0)
3056 return;
3057 if(PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return;
3058 if(PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0)
3059 return;
3060 if(PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0)
3061 return;
3062 if(PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0)
3063 return;
3064 if(PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0)
3065 return;
3066 if(PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0)
3067 return;
3068 if(PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return;
3069 if(PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return;
3070 if(PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return;
3071 if(PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return;
3072 if(PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return;
3073 if(PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return;
3074 if(PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return;
3075 if(PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return;
3076 if(PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return;
3077 if(PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return;
3078 if(PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return;
3079 if(PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return;
3080 if(PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return;
3081 if(PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return;
3082 if(PyDict_SetItemString(d, "comprehension",
3083 (PyObject*)comprehension_type) < 0) return;
3084 if(PyDict_SetItemString(d, "excepthandler",
3085 (PyObject*)excepthandler_type) < 0) return;
3086 if(PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 0)
3087 return;
3088 if(PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0)
3089 return;
3090 if(PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return;
3091}
3092
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00003093
Martin v. Löwisbd260da2006-02-26 19:42:26 +00003094PyObject* PyAST_mod2obj(mod_ty t)
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00003095{
Martin v. Löwisbd260da2006-02-26 19:42:26 +00003096 init_types();
3097 return ast2obj_mod(t);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00003098}
3099
Neal Norwitz7b5a6042005-11-13 19:14:20 +00003100