comparison Python/Python-ast.c @ 84850:f2d557484906 3.3

According to the PEP 7, C code must "use 4-space indents" Replace 8 spaces with 4.
author Victor Stinner <victor.stinner@gmail.com>
date Sat, 27 Jul 2013 00:00:36 +0200
parents ffb2fa900cb7
children d14f40c87438 1b464f8453a4
comparison
equal deleted inserted replaced
84848:57457028dd7a 84850:f2d557484906
9 static PyTypeObject *mod_type; 9 static PyTypeObject *mod_type;
10 static PyObject* ast2obj_mod(void*); 10 static PyObject* ast2obj_mod(void*);
11 static PyTypeObject *Module_type; 11 static PyTypeObject *Module_type;
12 _Py_IDENTIFIER(body); 12 _Py_IDENTIFIER(body);
13 static char *Module_fields[]={ 13 static char *Module_fields[]={
14 "body", 14 "body",
15 }; 15 };
16 static PyTypeObject *Interactive_type; 16 static PyTypeObject *Interactive_type;
17 static char *Interactive_fields[]={ 17 static char *Interactive_fields[]={
18 "body", 18 "body",
19 }; 19 };
20 static PyTypeObject *Expression_type; 20 static PyTypeObject *Expression_type;
21 static char *Expression_fields[]={ 21 static char *Expression_fields[]={
22 "body", 22 "body",
23 }; 23 };
24 static PyTypeObject *Suite_type; 24 static PyTypeObject *Suite_type;
25 static char *Suite_fields[]={ 25 static char *Suite_fields[]={
26 "body", 26 "body",
27 }; 27 };
28 static PyTypeObject *stmt_type; 28 static PyTypeObject *stmt_type;
29 _Py_IDENTIFIER(lineno); 29 _Py_IDENTIFIER(lineno);
30 _Py_IDENTIFIER(col_offset); 30 _Py_IDENTIFIER(col_offset);
31 static char *stmt_attributes[] = { 31 static char *stmt_attributes[] = {
32 "lineno", 32 "lineno",
33 "col_offset", 33 "col_offset",
34 }; 34 };
35 static PyObject* ast2obj_stmt(void*); 35 static PyObject* ast2obj_stmt(void*);
36 static PyTypeObject *FunctionDef_type; 36 static PyTypeObject *FunctionDef_type;
37 _Py_IDENTIFIER(name); 37 _Py_IDENTIFIER(name);
38 _Py_IDENTIFIER(args); 38 _Py_IDENTIFIER(args);
39 _Py_IDENTIFIER(decorator_list); 39 _Py_IDENTIFIER(decorator_list);
40 _Py_IDENTIFIER(returns); 40 _Py_IDENTIFIER(returns);
41 static char *FunctionDef_fields[]={ 41 static char *FunctionDef_fields[]={
42 "name", 42 "name",
43 "args", 43 "args",
44 "body", 44 "body",
45 "decorator_list", 45 "decorator_list",
46 "returns", 46 "returns",
47 }; 47 };
48 static PyTypeObject *ClassDef_type; 48 static PyTypeObject *ClassDef_type;
49 _Py_IDENTIFIER(bases); 49 _Py_IDENTIFIER(bases);
50 _Py_IDENTIFIER(keywords); 50 _Py_IDENTIFIER(keywords);
51 _Py_IDENTIFIER(starargs); 51 _Py_IDENTIFIER(starargs);
52 _Py_IDENTIFIER(kwargs); 52 _Py_IDENTIFIER(kwargs);
53 static char *ClassDef_fields[]={ 53 static char *ClassDef_fields[]={
54 "name", 54 "name",
55 "bases", 55 "bases",
56 "keywords", 56 "keywords",
57 "starargs", 57 "starargs",
58 "kwargs", 58 "kwargs",
59 "body", 59 "body",
60 "decorator_list", 60 "decorator_list",
61 }; 61 };
62 static PyTypeObject *Return_type; 62 static PyTypeObject *Return_type;
63 _Py_IDENTIFIER(value); 63 _Py_IDENTIFIER(value);
64 static char *Return_fields[]={ 64 static char *Return_fields[]={
65 "value", 65 "value",
66 }; 66 };
67 static PyTypeObject *Delete_type; 67 static PyTypeObject *Delete_type;
68 _Py_IDENTIFIER(targets); 68 _Py_IDENTIFIER(targets);
69 static char *Delete_fields[]={ 69 static char *Delete_fields[]={
70 "targets", 70 "targets",
71 }; 71 };
72 static PyTypeObject *Assign_type; 72 static PyTypeObject *Assign_type;
73 static char *Assign_fields[]={ 73 static char *Assign_fields[]={
74 "targets", 74 "targets",
75 "value", 75 "value",
76 }; 76 };
77 static PyTypeObject *AugAssign_type; 77 static PyTypeObject *AugAssign_type;
78 _Py_IDENTIFIER(target); 78 _Py_IDENTIFIER(target);
79 _Py_IDENTIFIER(op); 79 _Py_IDENTIFIER(op);
80 static char *AugAssign_fields[]={ 80 static char *AugAssign_fields[]={
81 "target", 81 "target",
82 "op", 82 "op",
83 "value", 83 "value",
84 }; 84 };
85 static PyTypeObject *For_type; 85 static PyTypeObject *For_type;
86 _Py_IDENTIFIER(iter); 86 _Py_IDENTIFIER(iter);
87 _Py_IDENTIFIER(orelse); 87 _Py_IDENTIFIER(orelse);
88 static char *For_fields[]={ 88 static char *For_fields[]={
89 "target", 89 "target",
90 "iter", 90 "iter",
91 "body", 91 "body",
92 "orelse", 92 "orelse",
93 }; 93 };
94 static PyTypeObject *While_type; 94 static PyTypeObject *While_type;
95 _Py_IDENTIFIER(test); 95 _Py_IDENTIFIER(test);
96 static char *While_fields[]={ 96 static char *While_fields[]={
97 "test", 97 "test",
98 "body", 98 "body",
99 "orelse", 99 "orelse",
100 }; 100 };
101 static PyTypeObject *If_type; 101 static PyTypeObject *If_type;
102 static char *If_fields[]={ 102 static char *If_fields[]={
103 "test", 103 "test",
104 "body", 104 "body",
105 "orelse", 105 "orelse",
106 }; 106 };
107 static PyTypeObject *With_type; 107 static PyTypeObject *With_type;
108 _Py_IDENTIFIER(items); 108 _Py_IDENTIFIER(items);
109 static char *With_fields[]={ 109 static char *With_fields[]={
110 "items", 110 "items",
111 "body", 111 "body",
112 }; 112 };
113 static PyTypeObject *Raise_type; 113 static PyTypeObject *Raise_type;
114 _Py_IDENTIFIER(exc); 114 _Py_IDENTIFIER(exc);
115 _Py_IDENTIFIER(cause); 115 _Py_IDENTIFIER(cause);
116 static char *Raise_fields[]={ 116 static char *Raise_fields[]={
117 "exc", 117 "exc",
118 "cause", 118 "cause",
119 }; 119 };
120 static PyTypeObject *Try_type; 120 static PyTypeObject *Try_type;
121 _Py_IDENTIFIER(handlers); 121 _Py_IDENTIFIER(handlers);
122 _Py_IDENTIFIER(finalbody); 122 _Py_IDENTIFIER(finalbody);
123 static char *Try_fields[]={ 123 static char *Try_fields[]={
124 "body", 124 "body",
125 "handlers", 125 "handlers",
126 "orelse", 126 "orelse",
127 "finalbody", 127 "finalbody",
128 }; 128 };
129 static PyTypeObject *Assert_type; 129 static PyTypeObject *Assert_type;
130 _Py_IDENTIFIER(msg); 130 _Py_IDENTIFIER(msg);
131 static char *Assert_fields[]={ 131 static char *Assert_fields[]={
132 "test", 132 "test",
133 "msg", 133 "msg",
134 }; 134 };
135 static PyTypeObject *Import_type; 135 static PyTypeObject *Import_type;
136 _Py_IDENTIFIER(names); 136 _Py_IDENTIFIER(names);
137 static char *Import_fields[]={ 137 static char *Import_fields[]={
138 "names", 138 "names",
139 }; 139 };
140 static PyTypeObject *ImportFrom_type; 140 static PyTypeObject *ImportFrom_type;
141 _Py_IDENTIFIER(module); 141 _Py_IDENTIFIER(module);
142 _Py_IDENTIFIER(level); 142 _Py_IDENTIFIER(level);
143 static char *ImportFrom_fields[]={ 143 static char *ImportFrom_fields[]={
144 "module", 144 "module",
145 "names", 145 "names",
146 "level", 146 "level",
147 }; 147 };
148 static PyTypeObject *Global_type; 148 static PyTypeObject *Global_type;
149 static char *Global_fields[]={ 149 static char *Global_fields[]={
150 "names", 150 "names",
151 }; 151 };
152 static PyTypeObject *Nonlocal_type; 152 static PyTypeObject *Nonlocal_type;
153 static char *Nonlocal_fields[]={ 153 static char *Nonlocal_fields[]={
154 "names", 154 "names",
155 }; 155 };
156 static PyTypeObject *Expr_type; 156 static PyTypeObject *Expr_type;
157 static char *Expr_fields[]={ 157 static char *Expr_fields[]={
158 "value", 158 "value",
159 }; 159 };
160 static PyTypeObject *Pass_type; 160 static PyTypeObject *Pass_type;
161 static PyTypeObject *Break_type; 161 static PyTypeObject *Break_type;
162 static PyTypeObject *Continue_type; 162 static PyTypeObject *Continue_type;
163 static PyTypeObject *expr_type; 163 static PyTypeObject *expr_type;
164 static char *expr_attributes[] = { 164 static char *expr_attributes[] = {
165 "lineno", 165 "lineno",
166 "col_offset", 166 "col_offset",
167 }; 167 };
168 static PyObject* ast2obj_expr(void*); 168 static PyObject* ast2obj_expr(void*);
169 static PyTypeObject *BoolOp_type; 169 static PyTypeObject *BoolOp_type;
170 _Py_IDENTIFIER(values); 170 _Py_IDENTIFIER(values);
171 static char *BoolOp_fields[]={ 171 static char *BoolOp_fields[]={
172 "op", 172 "op",
173 "values", 173 "values",
174 }; 174 };
175 static PyTypeObject *BinOp_type; 175 static PyTypeObject *BinOp_type;
176 _Py_IDENTIFIER(left); 176 _Py_IDENTIFIER(left);
177 _Py_IDENTIFIER(right); 177 _Py_IDENTIFIER(right);
178 static char *BinOp_fields[]={ 178 static char *BinOp_fields[]={
179 "left", 179 "left",
180 "op", 180 "op",
181 "right", 181 "right",
182 }; 182 };
183 static PyTypeObject *UnaryOp_type; 183 static PyTypeObject *UnaryOp_type;
184 _Py_IDENTIFIER(operand); 184 _Py_IDENTIFIER(operand);
185 static char *UnaryOp_fields[]={ 185 static char *UnaryOp_fields[]={
186 "op", 186 "op",
187 "operand", 187 "operand",
188 }; 188 };
189 static PyTypeObject *Lambda_type; 189 static PyTypeObject *Lambda_type;
190 static char *Lambda_fields[]={ 190 static char *Lambda_fields[]={
191 "args", 191 "args",
192 "body", 192 "body",
193 }; 193 };
194 static PyTypeObject *IfExp_type; 194 static PyTypeObject *IfExp_type;
195 static char *IfExp_fields[]={ 195 static char *IfExp_fields[]={
196 "test", 196 "test",
197 "body", 197 "body",
198 "orelse", 198 "orelse",
199 }; 199 };
200 static PyTypeObject *Dict_type; 200 static PyTypeObject *Dict_type;
201 _Py_IDENTIFIER(keys); 201 _Py_IDENTIFIER(keys);
202 static char *Dict_fields[]={ 202 static char *Dict_fields[]={
203 "keys", 203 "keys",
204 "values", 204 "values",
205 }; 205 };
206 static PyTypeObject *Set_type; 206 static PyTypeObject *Set_type;
207 _Py_IDENTIFIER(elts); 207 _Py_IDENTIFIER(elts);
208 static char *Set_fields[]={ 208 static char *Set_fields[]={
209 "elts", 209 "elts",
210 }; 210 };
211 static PyTypeObject *ListComp_type; 211 static PyTypeObject *ListComp_type;
212 _Py_IDENTIFIER(elt); 212 _Py_IDENTIFIER(elt);
213 _Py_IDENTIFIER(generators); 213 _Py_IDENTIFIER(generators);
214 static char *ListComp_fields[]={ 214 static char *ListComp_fields[]={
215 "elt", 215 "elt",
216 "generators", 216 "generators",
217 }; 217 };
218 static PyTypeObject *SetComp_type; 218 static PyTypeObject *SetComp_type;
219 static char *SetComp_fields[]={ 219 static char *SetComp_fields[]={
220 "elt", 220 "elt",
221 "generators", 221 "generators",
222 }; 222 };
223 static PyTypeObject *DictComp_type; 223 static PyTypeObject *DictComp_type;
224 _Py_IDENTIFIER(key); 224 _Py_IDENTIFIER(key);
225 static char *DictComp_fields[]={ 225 static char *DictComp_fields[]={
226 "key", 226 "key",
227 "value", 227 "value",
228 "generators", 228 "generators",
229 }; 229 };
230 static PyTypeObject *GeneratorExp_type; 230 static PyTypeObject *GeneratorExp_type;
231 static char *GeneratorExp_fields[]={ 231 static char *GeneratorExp_fields[]={
232 "elt", 232 "elt",
233 "generators", 233 "generators",
234 }; 234 };
235 static PyTypeObject *Yield_type; 235 static PyTypeObject *Yield_type;
236 static char *Yield_fields[]={ 236 static char *Yield_fields[]={
237 "value", 237 "value",
238 }; 238 };
239 static PyTypeObject *YieldFrom_type; 239 static PyTypeObject *YieldFrom_type;
240 static char *YieldFrom_fields[]={ 240 static char *YieldFrom_fields[]={
241 "value", 241 "value",
242 }; 242 };
243 static PyTypeObject *Compare_type; 243 static PyTypeObject *Compare_type;
244 _Py_IDENTIFIER(ops); 244 _Py_IDENTIFIER(ops);
245 _Py_IDENTIFIER(comparators); 245 _Py_IDENTIFIER(comparators);
246 static char *Compare_fields[]={ 246 static char *Compare_fields[]={
247 "left", 247 "left",
248 "ops", 248 "ops",
249 "comparators", 249 "comparators",
250 }; 250 };
251 static PyTypeObject *Call_type; 251 static PyTypeObject *Call_type;
252 _Py_IDENTIFIER(func); 252 _Py_IDENTIFIER(func);
253 static char *Call_fields[]={ 253 static char *Call_fields[]={
254 "func", 254 "func",
255 "args", 255 "args",
256 "keywords", 256 "keywords",
257 "starargs", 257 "starargs",
258 "kwargs", 258 "kwargs",
259 }; 259 };
260 static PyTypeObject *Num_type; 260 static PyTypeObject *Num_type;
261 _Py_IDENTIFIER(n); 261 _Py_IDENTIFIER(n);
262 static char *Num_fields[]={ 262 static char *Num_fields[]={
263 "n", 263 "n",
264 }; 264 };
265 static PyTypeObject *Str_type; 265 static PyTypeObject *Str_type;
266 _Py_IDENTIFIER(s); 266 _Py_IDENTIFIER(s);
267 static char *Str_fields[]={ 267 static char *Str_fields[]={
268 "s", 268 "s",
269 }; 269 };
270 static PyTypeObject *Bytes_type; 270 static PyTypeObject *Bytes_type;
271 static char *Bytes_fields[]={ 271 static char *Bytes_fields[]={
272 "s", 272 "s",
273 }; 273 };
274 static PyTypeObject *Ellipsis_type; 274 static PyTypeObject *Ellipsis_type;
275 static PyTypeObject *Attribute_type; 275 static PyTypeObject *Attribute_type;
276 _Py_IDENTIFIER(attr); 276 _Py_IDENTIFIER(attr);
277 _Py_IDENTIFIER(ctx); 277 _Py_IDENTIFIER(ctx);
278 static char *Attribute_fields[]={ 278 static char *Attribute_fields[]={
279 "value", 279 "value",
280 "attr", 280 "attr",
281 "ctx", 281 "ctx",
282 }; 282 };
283 static PyTypeObject *Subscript_type; 283 static PyTypeObject *Subscript_type;
284 _Py_IDENTIFIER(slice); 284 _Py_IDENTIFIER(slice);
285 static char *Subscript_fields[]={ 285 static char *Subscript_fields[]={
286 "value", 286 "value",
287 "slice", 287 "slice",
288 "ctx", 288 "ctx",
289 }; 289 };
290 static PyTypeObject *Starred_type; 290 static PyTypeObject *Starred_type;
291 static char *Starred_fields[]={ 291 static char *Starred_fields[]={
292 "value", 292 "value",
293 "ctx", 293 "ctx",
294 }; 294 };
295 static PyTypeObject *Name_type; 295 static PyTypeObject *Name_type;
296 _Py_IDENTIFIER(id); 296 _Py_IDENTIFIER(id);
297 static char *Name_fields[]={ 297 static char *Name_fields[]={
298 "id", 298 "id",
299 "ctx", 299 "ctx",
300 }; 300 };
301 static PyTypeObject *List_type; 301 static PyTypeObject *List_type;
302 static char *List_fields[]={ 302 static char *List_fields[]={
303 "elts", 303 "elts",
304 "ctx", 304 "ctx",
305 }; 305 };
306 static PyTypeObject *Tuple_type; 306 static PyTypeObject *Tuple_type;
307 static char *Tuple_fields[]={ 307 static char *Tuple_fields[]={
308 "elts", 308 "elts",
309 "ctx", 309 "ctx",
310 }; 310 };
311 static PyTypeObject *expr_context_type; 311 static PyTypeObject *expr_context_type;
312 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, 312 static PyObject *Load_singleton, *Store_singleton, *Del_singleton,
313 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; 313 *AugLoad_singleton, *AugStore_singleton, *Param_singleton;
314 static PyObject* ast2obj_expr_context(expr_context_ty); 314 static PyObject* ast2obj_expr_context(expr_context_ty);
323 static PyTypeObject *Slice_type; 323 static PyTypeObject *Slice_type;
324 _Py_IDENTIFIER(lower); 324 _Py_IDENTIFIER(lower);
325 _Py_IDENTIFIER(upper); 325 _Py_IDENTIFIER(upper);
326 _Py_IDENTIFIER(step); 326 _Py_IDENTIFIER(step);
327 static char *Slice_fields[]={ 327 static char *Slice_fields[]={
328 "lower", 328 "lower",
329 "upper", 329 "upper",
330 "step", 330 "step",
331 }; 331 };
332 static PyTypeObject *ExtSlice_type; 332 static PyTypeObject *ExtSlice_type;
333 _Py_IDENTIFIER(dims); 333 _Py_IDENTIFIER(dims);
334 static char *ExtSlice_fields[]={ 334 static char *ExtSlice_fields[]={
335 "dims", 335 "dims",
336 }; 336 };
337 static PyTypeObject *Index_type; 337 static PyTypeObject *Index_type;
338 static char *Index_fields[]={ 338 static char *Index_fields[]={
339 "value", 339 "value",
340 }; 340 };
341 static PyTypeObject *boolop_type; 341 static PyTypeObject *boolop_type;
342 static PyObject *And_singleton, *Or_singleton; 342 static PyObject *And_singleton, *Or_singleton;
343 static PyObject* ast2obj_boolop(boolop_ty); 343 static PyObject* ast2obj_boolop(boolop_ty);
344 static PyTypeObject *And_type; 344 static PyTypeObject *And_type;
386 static PyTypeObject *NotIn_type; 386 static PyTypeObject *NotIn_type;
387 static PyTypeObject *comprehension_type; 387 static PyTypeObject *comprehension_type;
388 static PyObject* ast2obj_comprehension(void*); 388 static PyObject* ast2obj_comprehension(void*);
389 _Py_IDENTIFIER(ifs); 389 _Py_IDENTIFIER(ifs);
390 static char *comprehension_fields[]={ 390 static char *comprehension_fields[]={
391 "target", 391 "target",
392 "iter", 392 "iter",
393 "ifs", 393 "ifs",
394 }; 394 };
395 static PyTypeObject *excepthandler_type; 395 static PyTypeObject *excepthandler_type;
396 static char *excepthandler_attributes[] = { 396 static char *excepthandler_attributes[] = {
397 "lineno", 397 "lineno",
398 "col_offset", 398 "col_offset",
399 }; 399 };
400 static PyObject* ast2obj_excepthandler(void*); 400 static PyObject* ast2obj_excepthandler(void*);
401 static PyTypeObject *ExceptHandler_type; 401 static PyTypeObject *ExceptHandler_type;
402 _Py_IDENTIFIER(type); 402 _Py_IDENTIFIER(type);
403 static char *ExceptHandler_fields[]={ 403 static char *ExceptHandler_fields[]={
404 "type", 404 "type",
405 "name", 405 "name",
406 "body", 406 "body",
407 }; 407 };
408 static PyTypeObject *arguments_type; 408 static PyTypeObject *arguments_type;
409 static PyObject* ast2obj_arguments(void*); 409 static PyObject* ast2obj_arguments(void*);
410 _Py_IDENTIFIER(vararg); 410 _Py_IDENTIFIER(vararg);
411 _Py_IDENTIFIER(varargannotation); 411 _Py_IDENTIFIER(varargannotation);
413 _Py_IDENTIFIER(kwarg); 413 _Py_IDENTIFIER(kwarg);
414 _Py_IDENTIFIER(kwargannotation); 414 _Py_IDENTIFIER(kwargannotation);
415 _Py_IDENTIFIER(defaults); 415 _Py_IDENTIFIER(defaults);
416 _Py_IDENTIFIER(kw_defaults); 416 _Py_IDENTIFIER(kw_defaults);
417 static char *arguments_fields[]={ 417 static char *arguments_fields[]={
418 "args", 418 "args",
419 "vararg", 419 "vararg",
420 "varargannotation", 420 "varargannotation",
421 "kwonlyargs", 421 "kwonlyargs",
422 "kwarg", 422 "kwarg",
423 "kwargannotation", 423 "kwargannotation",
424 "defaults", 424 "defaults",
425 "kw_defaults", 425 "kw_defaults",
426 }; 426 };
427 static PyTypeObject *arg_type; 427 static PyTypeObject *arg_type;
428 static PyObject* ast2obj_arg(void*); 428 static PyObject* ast2obj_arg(void*);
429 _Py_IDENTIFIER(arg); 429 _Py_IDENTIFIER(arg);
430 _Py_IDENTIFIER(annotation); 430 _Py_IDENTIFIER(annotation);
431 static char *arg_fields[]={ 431 static char *arg_fields[]={
432 "arg", 432 "arg",
433 "annotation", 433 "annotation",
434 }; 434 };
435 static PyTypeObject *keyword_type; 435 static PyTypeObject *keyword_type;
436 static PyObject* ast2obj_keyword(void*); 436 static PyObject* ast2obj_keyword(void*);
437 static char *keyword_fields[]={ 437 static char *keyword_fields[]={
438 "arg", 438 "arg",
439 "value", 439 "value",
440 }; 440 };
441 static PyTypeObject *alias_type; 441 static PyTypeObject *alias_type;
442 static PyObject* ast2obj_alias(void*); 442 static PyObject* ast2obj_alias(void*);
443 _Py_IDENTIFIER(asname); 443 _Py_IDENTIFIER(asname);
444 static char *alias_fields[]={ 444 static char *alias_fields[]={
445 "name", 445 "name",
446 "asname", 446 "asname",
447 }; 447 };
448 static PyTypeObject *withitem_type; 448 static PyTypeObject *withitem_type;
449 static PyObject* ast2obj_withitem(void*); 449 static PyObject* ast2obj_withitem(void*);
450 _Py_IDENTIFIER(context_expr); 450 _Py_IDENTIFIER(context_expr);
451 _Py_IDENTIFIER(optional_vars); 451 _Py_IDENTIFIER(optional_vars);
452 static char *withitem_fields[]={ 452 static char *withitem_fields[]={
453 "context_expr", 453 "context_expr",
454 "optional_vars", 454 "optional_vars",
455 }; 455 };
456 456
457 457
458 typedef struct { 458 typedef struct {
459 PyObject_HEAD 459 PyObject_HEAD
755 } 755 }
756 756
757 757
758 static int init_types(void) 758 static int init_types(void)
759 { 759 {
760 static int initialized; 760 static int initialized;
761 if (initialized) return 1; 761 if (initialized) return 1;
762 if (add_ast_fields() < 0) return 0; 762 if (add_ast_fields() < 0) return 0;
763 mod_type = make_type("mod", &AST_type, NULL, 0); 763 mod_type = make_type("mod", &AST_type, NULL, 0);
764 if (!mod_type) return 0; 764 if (!mod_type) return 0;
765 if (!add_attributes(mod_type, NULL, 0)) return 0; 765 if (!add_attributes(mod_type, NULL, 0)) return 0;
766 Module_type = make_type("Module", mod_type, Module_fields, 1); 766 Module_type = make_type("Module", mod_type, Module_fields, 1);
767 if (!Module_type) return 0; 767 if (!Module_type) return 0;
768 Interactive_type = make_type("Interactive", mod_type, 768 Interactive_type = make_type("Interactive", mod_type, Interactive_fields,
769 Interactive_fields, 1); 769 1);
770 if (!Interactive_type) return 0; 770 if (!Interactive_type) return 0;
771 Expression_type = make_type("Expression", mod_type, Expression_fields, 771 Expression_type = make_type("Expression", mod_type, Expression_fields, 1);
772 1); 772 if (!Expression_type) return 0;
773 if (!Expression_type) return 0; 773 Suite_type = make_type("Suite", mod_type, Suite_fields, 1);
774 Suite_type = make_type("Suite", mod_type, Suite_fields, 1); 774 if (!Suite_type) return 0;
775 if (!Suite_type) return 0; 775 stmt_type = make_type("stmt", &AST_type, NULL, 0);
776 stmt_type = make_type("stmt", &AST_type, NULL, 0); 776 if (!stmt_type) return 0;
777 if (!stmt_type) return 0; 777 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0;
778 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0; 778 FunctionDef_type = make_type("FunctionDef", stmt_type, FunctionDef_fields,
779 FunctionDef_type = make_type("FunctionDef", stmt_type, 779 5);
780 FunctionDef_fields, 5); 780 if (!FunctionDef_type) return 0;
781 if (!FunctionDef_type) return 0; 781 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7);
782 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7); 782 if (!ClassDef_type) return 0;
783 if (!ClassDef_type) return 0; 783 Return_type = make_type("Return", stmt_type, Return_fields, 1);
784 Return_type = make_type("Return", stmt_type, Return_fields, 1); 784 if (!Return_type) return 0;
785 if (!Return_type) return 0; 785 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1);
786 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1); 786 if (!Delete_type) return 0;
787 if (!Delete_type) return 0; 787 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2);
788 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2); 788 if (!Assign_type) return 0;
789 if (!Assign_type) return 0; 789 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3);
790 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3); 790 if (!AugAssign_type) return 0;
791 if (!AugAssign_type) return 0; 791 For_type = make_type("For", stmt_type, For_fields, 4);
792 For_type = make_type("For", stmt_type, For_fields, 4); 792 if (!For_type) return 0;
793 if (!For_type) return 0; 793 While_type = make_type("While", stmt_type, While_fields, 3);
794 While_type = make_type("While", stmt_type, While_fields, 3); 794 if (!While_type) return 0;
795 if (!While_type) return 0; 795 If_type = make_type("If", stmt_type, If_fields, 3);
796 If_type = make_type("If", stmt_type, If_fields, 3); 796 if (!If_type) return 0;
797 if (!If_type) return 0; 797 With_type = make_type("With", stmt_type, With_fields, 2);
798 With_type = make_type("With", stmt_type, With_fields, 2); 798 if (!With_type) return 0;
799 if (!With_type) return 0; 799 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2);
800 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2); 800 if (!Raise_type) return 0;
801 if (!Raise_type) return 0; 801 Try_type = make_type("Try", stmt_type, Try_fields, 4);
802 Try_type = make_type("Try", stmt_type, Try_fields, 4); 802 if (!Try_type) return 0;
803 if (!Try_type) return 0; 803 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2);
804 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2); 804 if (!Assert_type) return 0;
805 if (!Assert_type) return 0; 805 Import_type = make_type("Import", stmt_type, Import_fields, 1);
806 Import_type = make_type("Import", stmt_type, Import_fields, 1); 806 if (!Import_type) return 0;
807 if (!Import_type) return 0; 807 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, 3);
808 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, 808 if (!ImportFrom_type) return 0;
809 3); 809 Global_type = make_type("Global", stmt_type, Global_fields, 1);
810 if (!ImportFrom_type) return 0; 810 if (!Global_type) return 0;
811 Global_type = make_type("Global", stmt_type, Global_fields, 1); 811 Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1);
812 if (!Global_type) return 0; 812 if (!Nonlocal_type) return 0;
813 Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1); 813 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1);
814 if (!Nonlocal_type) return 0; 814 if (!Expr_type) return 0;
815 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); 815 Pass_type = make_type("Pass", stmt_type, NULL, 0);
816 if (!Expr_type) return 0; 816 if (!Pass_type) return 0;
817 Pass_type = make_type("Pass", stmt_type, NULL, 0); 817 Break_type = make_type("Break", stmt_type, NULL, 0);
818 if (!Pass_type) return 0; 818 if (!Break_type) return 0;
819 Break_type = make_type("Break", stmt_type, NULL, 0); 819 Continue_type = make_type("Continue", stmt_type, NULL, 0);
820 if (!Break_type) return 0; 820 if (!Continue_type) return 0;
821 Continue_type = make_type("Continue", stmt_type, NULL, 0); 821 expr_type = make_type("expr", &AST_type, NULL, 0);
822 if (!Continue_type) return 0; 822 if (!expr_type) return 0;
823 expr_type = make_type("expr", &AST_type, NULL, 0); 823 if (!add_attributes(expr_type, expr_attributes, 2)) return 0;
824 if (!expr_type) return 0; 824 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2);
825 if (!add_attributes(expr_type, expr_attributes, 2)) return 0; 825 if (!BoolOp_type) return 0;
826 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2); 826 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3);
827 if (!BoolOp_type) return 0; 827 if (!BinOp_type) return 0;
828 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3); 828 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2);
829 if (!BinOp_type) return 0; 829 if (!UnaryOp_type) return 0;
830 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2); 830 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2);
831 if (!UnaryOp_type) return 0; 831 if (!Lambda_type) return 0;
832 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2); 832 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3);
833 if (!Lambda_type) return 0; 833 if (!IfExp_type) return 0;
834 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3); 834 Dict_type = make_type("Dict", expr_type, Dict_fields, 2);
835 if (!IfExp_type) return 0; 835 if (!Dict_type) return 0;
836 Dict_type = make_type("Dict", expr_type, Dict_fields, 2); 836 Set_type = make_type("Set", expr_type, Set_fields, 1);
837 if (!Dict_type) return 0; 837 if (!Set_type) return 0;
838 Set_type = make_type("Set", expr_type, Set_fields, 1); 838 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2);
839 if (!Set_type) return 0; 839 if (!ListComp_type) return 0;
840 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); 840 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2);
841 if (!ListComp_type) return 0; 841 if (!SetComp_type) return 0;
842 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2); 842 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3);
843 if (!SetComp_type) return 0; 843 if (!DictComp_type) return 0;
844 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3); 844 GeneratorExp_type = make_type("GeneratorExp", expr_type,
845 if (!DictComp_type) return 0; 845 GeneratorExp_fields, 2);
846 GeneratorExp_type = make_type("GeneratorExp", expr_type, 846 if (!GeneratorExp_type) return 0;
847 GeneratorExp_fields, 2); 847 Yield_type = make_type("Yield", expr_type, Yield_fields, 1);
848 if (!GeneratorExp_type) return 0; 848 if (!Yield_type) return 0;
849 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); 849 YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1);
850 if (!Yield_type) return 0; 850 if (!YieldFrom_type) return 0;
851 YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1); 851 Compare_type = make_type("Compare", expr_type, Compare_fields, 3);
852 if (!YieldFrom_type) return 0; 852 if (!Compare_type) return 0;
853 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); 853 Call_type = make_type("Call", expr_type, Call_fields, 5);
854 if (!Compare_type) return 0; 854 if (!Call_type) return 0;
855 Call_type = make_type("Call", expr_type, Call_fields, 5); 855 Num_type = make_type("Num", expr_type, Num_fields, 1);
856 if (!Call_type) return 0; 856 if (!Num_type) return 0;
857 Num_type = make_type("Num", expr_type, Num_fields, 1); 857 Str_type = make_type("Str", expr_type, Str_fields, 1);
858 if (!Num_type) return 0; 858 if (!Str_type) return 0;
859 Str_type = make_type("Str", expr_type, Str_fields, 1); 859 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1);
860 if (!Str_type) return 0; 860 if (!Bytes_type) return 0;
861 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1); 861 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0);
862 if (!Bytes_type) return 0; 862 if (!Ellipsis_type) return 0;
863 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); 863 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3);
864 if (!Ellipsis_type) return 0; 864 if (!Attribute_type) return 0;
865 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); 865 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
866 if (!Attribute_type) return 0; 866 if (!Subscript_type) return 0;
867 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); 867 Starred_type = make_type("Starred", expr_type, Starred_fields, 2);
868 if (!Subscript_type) return 0; 868 if (!Starred_type) return 0;
869 Starred_type = make_type("Starred", expr_type, Starred_fields, 2); 869 Name_type = make_type("Name", expr_type, Name_fields, 2);
870 if (!Starred_type) return 0; 870 if (!Name_type) return 0;
871 Name_type = make_type("Name", expr_type, Name_fields, 2); 871 List_type = make_type("List", expr_type, List_fields, 2);
872 if (!Name_type) return 0; 872 if (!List_type) return 0;
873 List_type = make_type("List", expr_type, List_fields, 2); 873 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2);
874 if (!List_type) return 0; 874 if (!Tuple_type) return 0;
875 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); 875 expr_context_type = make_type("expr_context", &AST_type, NULL, 0);
876 if (!Tuple_type) return 0; 876 if (!expr_context_type) return 0;
877 expr_context_type = make_type("expr_context", &AST_type, NULL, 0); 877 if (!add_attributes(expr_context_type, NULL, 0)) return 0;
878 if (!expr_context_type) return 0; 878 Load_type = make_type("Load", expr_context_type, NULL, 0);
879 if (!add_attributes(expr_context_type, NULL, 0)) return 0; 879 if (!Load_type) return 0;
880 Load_type = make_type("Load", expr_context_type, NULL, 0); 880 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL);
881 if (!Load_type) return 0; 881 if (!Load_singleton) return 0;
882 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL); 882 Store_type = make_type("Store", expr_context_type, NULL, 0);
883 if (!Load_singleton) return 0; 883 if (!Store_type) return 0;
884 Store_type = make_type("Store", expr_context_type, NULL, 0); 884 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL);
885 if (!Store_type) return 0; 885 if (!Store_singleton) return 0;
886 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL); 886 Del_type = make_type("Del", expr_context_type, NULL, 0);
887 if (!Store_singleton) return 0; 887 if (!Del_type) return 0;
888 Del_type = make_type("Del", expr_context_type, NULL, 0); 888 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL);
889 if (!Del_type) return 0; 889 if (!Del_singleton) return 0;
890 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL); 890 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0);
891 if (!Del_singleton) return 0; 891 if (!AugLoad_type) return 0;
892 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0); 892 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL);
893 if (!AugLoad_type) return 0; 893 if (!AugLoad_singleton) return 0;
894 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL); 894 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0);
895 if (!AugLoad_singleton) return 0; 895 if (!AugStore_type) return 0;
896 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0); 896 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL);
897 if (!AugStore_type) return 0; 897 if (!AugStore_singleton) return 0;
898 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL); 898 Param_type = make_type("Param", expr_context_type, NULL, 0);
899 if (!AugStore_singleton) return 0; 899 if (!Param_type) return 0;
900 Param_type = make_type("Param", expr_context_type, NULL, 0); 900 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL);
901 if (!Param_type) return 0; 901 if (!Param_singleton) return 0;
902 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL); 902 slice_type = make_type("slice", &AST_type, NULL, 0);
903 if (!Param_singleton) return 0; 903 if (!slice_type) return 0;
904 slice_type = make_type("slice", &AST_type, NULL, 0); 904 if (!add_attributes(slice_type, NULL, 0)) return 0;
905 if (!slice_type) return 0; 905 Slice_type = make_type("Slice", slice_type, Slice_fields, 3);
906 if (!add_attributes(slice_type, NULL, 0)) return 0; 906 if (!Slice_type) return 0;
907 Slice_type = make_type("Slice", slice_type, Slice_fields, 3); 907 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1);
908 if (!Slice_type) return 0; 908 if (!ExtSlice_type) return 0;
909 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); 909 Index_type = make_type("Index", slice_type, Index_fields, 1);
910 if (!ExtSlice_type) return 0; 910 if (!Index_type) return 0;
911 Index_type = make_type("Index", slice_type, Index_fields, 1); 911 boolop_type = make_type("boolop", &AST_type, NULL, 0);
912 if (!Index_type) return 0; 912 if (!boolop_type) return 0;
913 boolop_type = make_type("boolop", &AST_type, NULL, 0); 913 if (!add_attributes(boolop_type, NULL, 0)) return 0;
914 if (!boolop_type) return 0; 914 And_type = make_type("And", boolop_type, NULL, 0);
915 if (!add_attributes(boolop_type, NULL, 0)) return 0; 915 if (!And_type) return 0;
916 And_type = make_type("And", boolop_type, NULL, 0); 916 And_singleton = PyType_GenericNew(And_type, NULL, NULL);
917 if (!And_type) return 0; 917 if (!And_singleton) return 0;
918 And_singleton = PyType_GenericNew(And_type, NULL, NULL); 918 Or_type = make_type("Or", boolop_type, NULL, 0);
919 if (!And_singleton) return 0; 919 if (!Or_type) return 0;
920 Or_type = make_type("Or", boolop_type, NULL, 0); 920 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL);
921 if (!Or_type) return 0; 921 if (!Or_singleton) return 0;
922 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL); 922 operator_type = make_type("operator", &AST_type, NULL, 0);
923 if (!Or_singleton) return 0; 923 if (!operator_type) return 0;
924 operator_type = make_type("operator", &AST_type, NULL, 0); 924 if (!add_attributes(operator_type, NULL, 0)) return 0;
925 if (!operator_type) return 0; 925 Add_type = make_type("Add", operator_type, NULL, 0);
926 if (!add_attributes(operator_type, NULL, 0)) return 0; 926 if (!Add_type) return 0;
927 Add_type = make_type("Add", operator_type, NULL, 0); 927 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL);
928 if (!Add_type) return 0; 928 if (!Add_singleton) return 0;
929 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL); 929 Sub_type = make_type("Sub", operator_type, NULL, 0);
930 if (!Add_singleton) return 0; 930 if (!Sub_type) return 0;
931 Sub_type = make_type("Sub", operator_type, NULL, 0); 931 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL);
932 if (!Sub_type) return 0; 932 if (!Sub_singleton) return 0;
933 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL); 933 Mult_type = make_type("Mult", operator_type, NULL, 0);
934 if (!Sub_singleton) return 0; 934 if (!Mult_type) return 0;
935 Mult_type = make_type("Mult", operator_type, NULL, 0); 935 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL);
936 if (!Mult_type) return 0; 936 if (!Mult_singleton) return 0;
937 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); 937 Div_type = make_type("Div", operator_type, NULL, 0);
938 if (!Mult_singleton) return 0; 938 if (!Div_type) return 0;
939 Div_type = make_type("Div", operator_type, NULL, 0); 939 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL);
940 if (!Div_type) return 0; 940 if (!Div_singleton) return 0;
941 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); 941 Mod_type = make_type("Mod", operator_type, NULL, 0);
942 if (!Div_singleton) return 0; 942 if (!Mod_type) return 0;
943 Mod_type = make_type("Mod", operator_type, NULL, 0); 943 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL);
944 if (!Mod_type) return 0; 944 if (!Mod_singleton) return 0;
945 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL); 945 Pow_type = make_type("Pow", operator_type, NULL, 0);
946 if (!Mod_singleton) return 0; 946 if (!Pow_type) return 0;
947 Pow_type = make_type("Pow", operator_type, NULL, 0); 947 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL);
948 if (!Pow_type) return 0; 948 if (!Pow_singleton) return 0;
949 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL); 949 LShift_type = make_type("LShift", operator_type, NULL, 0);
950 if (!Pow_singleton) return 0; 950 if (!LShift_type) return 0;
951 LShift_type = make_type("LShift", operator_type, NULL, 0); 951 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL);
952 if (!LShift_type) return 0; 952 if (!LShift_singleton) return 0;
953 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL); 953 RShift_type = make_type("RShift", operator_type, NULL, 0);
954 if (!LShift_singleton) return 0; 954 if (!RShift_type) return 0;
955 RShift_type = make_type("RShift", operator_type, NULL, 0); 955 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL);
956 if (!RShift_type) return 0; 956 if (!RShift_singleton) return 0;
957 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL); 957 BitOr_type = make_type("BitOr", operator_type, NULL, 0);
958 if (!RShift_singleton) return 0; 958 if (!BitOr_type) return 0;
959 BitOr_type = make_type("BitOr", operator_type, NULL, 0); 959 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL);
960 if (!BitOr_type) return 0; 960 if (!BitOr_singleton) return 0;
961 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL); 961 BitXor_type = make_type("BitXor", operator_type, NULL, 0);
962 if (!BitOr_singleton) return 0; 962 if (!BitXor_type) return 0;
963 BitXor_type = make_type("BitXor", operator_type, NULL, 0); 963 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL);
964 if (!BitXor_type) return 0; 964 if (!BitXor_singleton) return 0;
965 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL); 965 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0);
966 if (!BitXor_singleton) return 0; 966 if (!BitAnd_type) return 0;
967 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0); 967 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL);
968 if (!BitAnd_type) return 0; 968 if (!BitAnd_singleton) return 0;
969 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL); 969 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0);
970 if (!BitAnd_singleton) return 0; 970 if (!FloorDiv_type) return 0;
971 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0); 971 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL);
972 if (!FloorDiv_type) return 0; 972 if (!FloorDiv_singleton) return 0;
973 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL); 973 unaryop_type = make_type("unaryop", &AST_type, NULL, 0);
974 if (!FloorDiv_singleton) return 0; 974 if (!unaryop_type) return 0;
975 unaryop_type = make_type("unaryop", &AST_type, NULL, 0); 975 if (!add_attributes(unaryop_type, NULL, 0)) return 0;
976 if (!unaryop_type) return 0; 976 Invert_type = make_type("Invert", unaryop_type, NULL, 0);
977 if (!add_attributes(unaryop_type, NULL, 0)) return 0; 977 if (!Invert_type) return 0;
978 Invert_type = make_type("Invert", unaryop_type, NULL, 0); 978 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL);
979 if (!Invert_type) return 0; 979 if (!Invert_singleton) return 0;
980 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL); 980 Not_type = make_type("Not", unaryop_type, NULL, 0);
981 if (!Invert_singleton) return 0; 981 if (!Not_type) return 0;
982 Not_type = make_type("Not", unaryop_type, NULL, 0); 982 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL);
983 if (!Not_type) return 0; 983 if (!Not_singleton) return 0;
984 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL); 984 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0);
985 if (!Not_singleton) return 0; 985 if (!UAdd_type) return 0;
986 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0); 986 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL);
987 if (!UAdd_type) return 0; 987 if (!UAdd_singleton) return 0;
988 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL); 988 USub_type = make_type("USub", unaryop_type, NULL, 0);
989 if (!UAdd_singleton) return 0; 989 if (!USub_type) return 0;
990 USub_type = make_type("USub", unaryop_type, NULL, 0); 990 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL);
991 if (!USub_type) return 0; 991 if (!USub_singleton) return 0;
992 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL); 992 cmpop_type = make_type("cmpop", &AST_type, NULL, 0);
993 if (!USub_singleton) return 0; 993 if (!cmpop_type) return 0;
994 cmpop_type = make_type("cmpop", &AST_type, NULL, 0); 994 if (!add_attributes(cmpop_type, NULL, 0)) return 0;
995 if (!cmpop_type) return 0; 995 Eq_type = make_type("Eq", cmpop_type, NULL, 0);
996 if (!add_attributes(cmpop_type, NULL, 0)) return 0; 996 if (!Eq_type) return 0;
997 Eq_type = make_type("Eq", cmpop_type, NULL, 0); 997 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL);
998 if (!Eq_type) return 0; 998 if (!Eq_singleton) return 0;
999 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL); 999 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0);
1000 if (!Eq_singleton) return 0; 1000 if (!NotEq_type) return 0;
1001 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0); 1001 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL);
1002 if (!NotEq_type) return 0; 1002 if (!NotEq_singleton) return 0;
1003 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL); 1003 Lt_type = make_type("Lt", cmpop_type, NULL, 0);
1004 if (!NotEq_singleton) return 0; 1004 if (!Lt_type) return 0;
1005 Lt_type = make_type("Lt", cmpop_type, NULL, 0); 1005 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL);
1006 if (!Lt_type) return 0; 1006 if (!Lt_singleton) return 0;
1007 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL); 1007 LtE_type = make_type("LtE", cmpop_type, NULL, 0);
1008 if (!Lt_singleton) return 0; 1008 if (!LtE_type) return 0;
1009 LtE_type = make_type("LtE", cmpop_type, NULL, 0); 1009 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL);
1010 if (!LtE_type) return 0; 1010 if (!LtE_singleton) return 0;
1011 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL); 1011 Gt_type = make_type("Gt", cmpop_type, NULL, 0);
1012 if (!LtE_singleton) return 0; 1012 if (!Gt_type) return 0;
1013 Gt_type = make_type("Gt", cmpop_type, NULL, 0); 1013 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL);
1014 if (!Gt_type) return 0; 1014 if (!Gt_singleton) return 0;
1015 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL); 1015 GtE_type = make_type("GtE", cmpop_type, NULL, 0);
1016 if (!Gt_singleton) return 0; 1016 if (!GtE_type) return 0;
1017 GtE_type = make_type("GtE", cmpop_type, NULL, 0); 1017 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL);
1018 if (!GtE_type) return 0; 1018 if (!GtE_singleton) return 0;
1019 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL); 1019 Is_type = make_type("Is", cmpop_type, NULL, 0);
1020 if (!GtE_singleton) return 0; 1020 if (!Is_type) return 0;
1021 Is_type = make_type("Is", cmpop_type, NULL, 0); 1021 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL);
1022 if (!Is_type) return 0; 1022 if (!Is_singleton) return 0;
1023 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL); 1023 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0);
1024 if (!Is_singleton) return 0; 1024 if (!IsNot_type) return 0;
1025 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0); 1025 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL);
1026 if (!IsNot_type) return 0; 1026 if (!IsNot_singleton) return 0;
1027 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL); 1027 In_type = make_type("In", cmpop_type, NULL, 0);
1028 if (!IsNot_singleton) return 0; 1028 if (!In_type) return 0;
1029 In_type = make_type("In", cmpop_type, NULL, 0); 1029 In_singleton = PyType_GenericNew(In_type, NULL, NULL);
1030 if (!In_type) return 0; 1030 if (!In_singleton) return 0;
1031 In_singleton = PyType_GenericNew(In_type, NULL, NULL); 1031 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0);
1032 if (!In_singleton) return 0; 1032 if (!NotIn_type) return 0;
1033 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0); 1033 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL);
1034 if (!NotIn_type) return 0; 1034 if (!NotIn_singleton) return 0;
1035 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL); 1035 comprehension_type = make_type("comprehension", &AST_type,
1036 if (!NotIn_singleton) return 0; 1036 comprehension_fields, 3);
1037 comprehension_type = make_type("comprehension", &AST_type, 1037 if (!comprehension_type) return 0;
1038 comprehension_fields, 3); 1038 excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0);
1039 if (!comprehension_type) return 0; 1039 if (!excepthandler_type) return 0;
1040 excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0); 1040 if (!add_attributes(excepthandler_type, excepthandler_attributes, 2))
1041 if (!excepthandler_type) return 0; 1041 return 0;
1042 if (!add_attributes(excepthandler_type, excepthandler_attributes, 2)) 1042 ExceptHandler_type = make_type("ExceptHandler", excepthandler_type,
1043 return 0; 1043 ExceptHandler_fields, 3);
1044 ExceptHandler_type = make_type("ExceptHandler", excepthandler_type, 1044 if (!ExceptHandler_type) return 0;
1045 ExceptHandler_fields, 3); 1045 arguments_type = make_type("arguments", &AST_type, arguments_fields, 8);
1046 if (!ExceptHandler_type) return 0; 1046 if (!arguments_type) return 0;
1047 arguments_type = make_type("arguments", &AST_type, arguments_fields, 8); 1047 arg_type = make_type("arg", &AST_type, arg_fields, 2);
1048 if (!arguments_type) return 0; 1048 if (!arg_type) return 0;
1049 arg_type = make_type("arg", &AST_type, arg_fields, 2); 1049 keyword_type = make_type("keyword", &AST_type, keyword_fields, 2);
1050 if (!arg_type) return 0; 1050 if (!keyword_type) return 0;
1051 keyword_type = make_type("keyword", &AST_type, keyword_fields, 2); 1051 alias_type = make_type("alias", &AST_type, alias_fields, 2);
1052 if (!keyword_type) return 0; 1052 if (!alias_type) return 0;
1053 alias_type = make_type("alias", &AST_type, alias_fields, 2); 1053 withitem_type = make_type("withitem", &AST_type, withitem_fields, 2);
1054 if (!alias_type) return 0; 1054 if (!withitem_type) return 0;
1055 withitem_type = make_type("withitem", &AST_type, withitem_fields, 2); 1055 initialized = 1;
1056 if (!withitem_type) return 0; 1056 return 1;
1057 initialized = 1;
1058 return 1;
1059 } 1057 }
1060 1058
1061 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena); 1059 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena);
1062 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena); 1060 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena);
1063 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena); 1061 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena);
1079 static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena); 1077 static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena);
1080 1078
1081 mod_ty 1079 mod_ty
1082 Module(asdl_seq * body, PyArena *arena) 1080 Module(asdl_seq * body, PyArena *arena)
1083 { 1081 {
1084 mod_ty p; 1082 mod_ty p;
1085 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); 1083 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
1086 if (!p) 1084 if (!p)
1087 return NULL; 1085 return NULL;
1088 p->kind = Module_kind; 1086 p->kind = Module_kind;
1089 p->v.Module.body = body; 1087 p->v.Module.body = body;
1090 return p; 1088 return p;
1091 } 1089 }
1092 1090
1093 mod_ty 1091 mod_ty
1094 Interactive(asdl_seq * body, PyArena *arena) 1092 Interactive(asdl_seq * body, PyArena *arena)
1095 { 1093 {
1096 mod_ty p; 1094 mod_ty p;
1097 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); 1095 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
1098 if (!p) 1096 if (!p)
1099 return NULL; 1097 return NULL;
1100 p->kind = Interactive_kind; 1098 p->kind = Interactive_kind;
1101 p->v.Interactive.body = body; 1099 p->v.Interactive.body = body;
1102 return p; 1100 return p;
1103 } 1101 }
1104 1102
1105 mod_ty 1103 mod_ty
1106 Expression(expr_ty body, PyArena *arena) 1104 Expression(expr_ty body, PyArena *arena)
1107 { 1105 {
1108 mod_ty p; 1106 mod_ty p;
1109 if (!body) { 1107 if (!body) {
1110 PyErr_SetString(PyExc_ValueError, 1108 PyErr_SetString(PyExc_ValueError,
1111 "field body is required for Expression"); 1109 "field body is required for Expression");
1112 return NULL; 1110 return NULL;
1113 } 1111 }
1114 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); 1112 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
1115 if (!p) 1113 if (!p)
1116 return NULL; 1114 return NULL;
1117 p->kind = Expression_kind; 1115 p->kind = Expression_kind;
1118 p->v.Expression.body = body; 1116 p->v.Expression.body = body;
1119 return p; 1117 return p;
1120 } 1118 }
1121 1119
1122 mod_ty 1120 mod_ty
1123 Suite(asdl_seq * body, PyArena *arena) 1121 Suite(asdl_seq * body, PyArena *arena)
1124 { 1122 {
1125 mod_ty p; 1123 mod_ty p;
1126 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); 1124 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
1127 if (!p) 1125 if (!p)
1128 return NULL; 1126 return NULL;
1129 p->kind = Suite_kind; 1127 p->kind = Suite_kind;
1130 p->v.Suite.body = body; 1128 p->v.Suite.body = body;
1131 return p; 1129 return p;
1132 } 1130 }
1133 1131
1134 stmt_ty 1132 stmt_ty
1135 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq * 1133 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
1136 decorator_list, expr_ty returns, int lineno, int col_offset, 1134 decorator_list, expr_ty returns, int lineno, int col_offset,
1137 PyArena *arena) 1135 PyArena *arena)
1138 { 1136 {
1139 stmt_ty p; 1137 stmt_ty p;
1140 if (!name) { 1138 if (!name) {
1141 PyErr_SetString(PyExc_ValueError, 1139 PyErr_SetString(PyExc_ValueError,
1142 "field name is required for FunctionDef"); 1140 "field name is required for FunctionDef");
1143 return NULL; 1141 return NULL;
1144 } 1142 }
1145 if (!args) { 1143 if (!args) {
1146 PyErr_SetString(PyExc_ValueError, 1144 PyErr_SetString(PyExc_ValueError,
1147 "field args is required for FunctionDef"); 1145 "field args is required for FunctionDef");
1148 return NULL; 1146 return NULL;
1149 } 1147 }
1150 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1148 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1151 if (!p) 1149 if (!p)
1152 return NULL; 1150 return NULL;
1153 p->kind = FunctionDef_kind; 1151 p->kind = FunctionDef_kind;
1154 p->v.FunctionDef.name = name; 1152 p->v.FunctionDef.name = name;
1155 p->v.FunctionDef.args = args; 1153 p->v.FunctionDef.args = args;
1156 p->v.FunctionDef.body = body; 1154 p->v.FunctionDef.body = body;
1157 p->v.FunctionDef.decorator_list = decorator_list; 1155 p->v.FunctionDef.decorator_list = decorator_list;
1158 p->v.FunctionDef.returns = returns; 1156 p->v.FunctionDef.returns = returns;
1159 p->lineno = lineno; 1157 p->lineno = lineno;
1160 p->col_offset = col_offset; 1158 p->col_offset = col_offset;
1161 return p; 1159 return p;
1162 } 1160 }
1163 1161
1164 stmt_ty 1162 stmt_ty
1165 ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty 1163 ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty
1166 starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list, 1164 starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list,
1167 int lineno, int col_offset, PyArena *arena) 1165 int lineno, int col_offset, PyArena *arena)
1168 { 1166 {
1169 stmt_ty p; 1167 stmt_ty p;
1170 if (!name) { 1168 if (!name) {
1171 PyErr_SetString(PyExc_ValueError, 1169 PyErr_SetString(PyExc_ValueError,
1172 "field name is required for ClassDef"); 1170 "field name is required for ClassDef");
1173 return NULL; 1171 return NULL;
1174 } 1172 }
1175 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1173 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1176 if (!p) 1174 if (!p)
1177 return NULL; 1175 return NULL;
1178 p->kind = ClassDef_kind; 1176 p->kind = ClassDef_kind;
1179 p->v.ClassDef.name = name; 1177 p->v.ClassDef.name = name;
1180 p->v.ClassDef.bases = bases; 1178 p->v.ClassDef.bases = bases;
1181 p->v.ClassDef.keywords = keywords; 1179 p->v.ClassDef.keywords = keywords;
1182 p->v.ClassDef.starargs = starargs; 1180 p->v.ClassDef.starargs = starargs;
1183 p->v.ClassDef.kwargs = kwargs; 1181 p->v.ClassDef.kwargs = kwargs;
1184 p->v.ClassDef.body = body; 1182 p->v.ClassDef.body = body;
1185 p->v.ClassDef.decorator_list = decorator_list; 1183 p->v.ClassDef.decorator_list = decorator_list;
1186 p->lineno = lineno; 1184 p->lineno = lineno;
1187 p->col_offset = col_offset; 1185 p->col_offset = col_offset;
1188 return p; 1186 return p;
1189 } 1187 }
1190 1188
1191 stmt_ty 1189 stmt_ty
1192 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) 1190 Return(expr_ty value, int lineno, int col_offset, PyArena *arena)
1193 { 1191 {
1194 stmt_ty p; 1192 stmt_ty p;
1195 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1193 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1196 if (!p) 1194 if (!p)
1197 return NULL; 1195 return NULL;
1198 p->kind = Return_kind; 1196 p->kind = Return_kind;
1199 p->v.Return.value = value; 1197 p->v.Return.value = value;
1200 p->lineno = lineno; 1198 p->lineno = lineno;
1201 p->col_offset = col_offset; 1199 p->col_offset = col_offset;
1202 return p; 1200 return p;
1203 } 1201 }
1204 1202
1205 stmt_ty 1203 stmt_ty
1206 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) 1204 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena)
1207 { 1205 {
1208 stmt_ty p; 1206 stmt_ty p;
1209 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1207 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1210 if (!p) 1208 if (!p)
1211 return NULL; 1209 return NULL;
1212 p->kind = Delete_kind; 1210 p->kind = Delete_kind;
1213 p->v.Delete.targets = targets; 1211 p->v.Delete.targets = targets;
1214 p->lineno = lineno; 1212 p->lineno = lineno;
1215 p->col_offset = col_offset; 1213 p->col_offset = col_offset;
1216 return p; 1214 return p;
1217 } 1215 }
1218 1216
1219 stmt_ty 1217 stmt_ty
1220 Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena 1218 Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena
1221 *arena) 1219 *arena)
1222 { 1220 {
1223 stmt_ty p; 1221 stmt_ty p;
1224 if (!value) { 1222 if (!value) {
1225 PyErr_SetString(PyExc_ValueError, 1223 PyErr_SetString(PyExc_ValueError,
1226 "field value is required for Assign"); 1224 "field value is required for Assign");
1227 return NULL; 1225 return NULL;
1228 } 1226 }
1229 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1227 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1230 if (!p) 1228 if (!p)
1231 return NULL; 1229 return NULL;
1232 p->kind = Assign_kind; 1230 p->kind = Assign_kind;
1233 p->v.Assign.targets = targets; 1231 p->v.Assign.targets = targets;
1234 p->v.Assign.value = value; 1232 p->v.Assign.value = value;
1235 p->lineno = lineno; 1233 p->lineno = lineno;
1236 p->col_offset = col_offset; 1234 p->col_offset = col_offset;
1237 return p; 1235 return p;
1238 } 1236 }
1239 1237
1240 stmt_ty 1238 stmt_ty
1241 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int 1239 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
1242 col_offset, PyArena *arena) 1240 col_offset, PyArena *arena)
1243 { 1241 {
1244 stmt_ty p; 1242 stmt_ty p;
1245 if (!target) { 1243 if (!target) {
1246 PyErr_SetString(PyExc_ValueError, 1244 PyErr_SetString(PyExc_ValueError,
1247 "field target is required for AugAssign"); 1245 "field target is required for AugAssign");
1248 return NULL; 1246 return NULL;
1249 } 1247 }
1250 if (!op) { 1248 if (!op) {
1251 PyErr_SetString(PyExc_ValueError, 1249 PyErr_SetString(PyExc_ValueError,
1252 "field op is required for AugAssign"); 1250 "field op is required for AugAssign");
1253 return NULL; 1251 return NULL;
1254 } 1252 }
1255 if (!value) { 1253 if (!value) {
1256 PyErr_SetString(PyExc_ValueError, 1254 PyErr_SetString(PyExc_ValueError,
1257 "field value is required for AugAssign"); 1255 "field value is required for AugAssign");
1258 return NULL; 1256 return NULL;
1259 } 1257 }
1260 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1258 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1261 if (!p) 1259 if (!p)
1262 return NULL; 1260 return NULL;
1263 p->kind = AugAssign_kind; 1261 p->kind = AugAssign_kind;
1264 p->v.AugAssign.target = target; 1262 p->v.AugAssign.target = target;
1265 p->v.AugAssign.op = op; 1263 p->v.AugAssign.op = op;
1266 p->v.AugAssign.value = value; 1264 p->v.AugAssign.value = value;
1267 p->lineno = lineno; 1265 p->lineno = lineno;
1268 p->col_offset = col_offset; 1266 p->col_offset = col_offset;
1269 return p; 1267 return p;
1270 } 1268 }
1271 1269
1272 stmt_ty 1270 stmt_ty
1273 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int 1271 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int
1274 lineno, int col_offset, PyArena *arena) 1272 lineno, int col_offset, PyArena *arena)
1275 { 1273 {
1276 stmt_ty p; 1274 stmt_ty p;
1277 if (!target) { 1275 if (!target) {
1278 PyErr_SetString(PyExc_ValueError, 1276 PyErr_SetString(PyExc_ValueError,
1279 "field target is required for For"); 1277 "field target is required for For");
1280 return NULL; 1278 return NULL;
1281 } 1279 }
1282 if (!iter) { 1280 if (!iter) {
1283 PyErr_SetString(PyExc_ValueError, 1281 PyErr_SetString(PyExc_ValueError,
1284 "field iter is required for For"); 1282 "field iter is required for For");
1285 return NULL; 1283 return NULL;
1286 } 1284 }
1287 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1285 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1288 if (!p) 1286 if (!p)
1289 return NULL; 1287 return NULL;
1290 p->kind = For_kind; 1288 p->kind = For_kind;
1291 p->v.For.target = target; 1289 p->v.For.target = target;
1292 p->v.For.iter = iter; 1290 p->v.For.iter = iter;
1293 p->v.For.body = body; 1291 p->v.For.body = body;
1294 p->v.For.orelse = orelse; 1292 p->v.For.orelse = orelse;
1295 p->lineno = lineno; 1293 p->lineno = lineno;
1296 p->col_offset = col_offset; 1294 p->col_offset = col_offset;
1297 return p; 1295 return p;
1298 } 1296 }
1299 1297
1300 stmt_ty 1298 stmt_ty
1301 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int 1299 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
1302 col_offset, PyArena *arena) 1300 col_offset, PyArena *arena)
1303 { 1301 {
1304 stmt_ty p; 1302 stmt_ty p;
1305 if (!test) { 1303 if (!test) {
1306 PyErr_SetString(PyExc_ValueError, 1304 PyErr_SetString(PyExc_ValueError,
1307 "field test is required for While"); 1305 "field test is required for While");
1308 return NULL; 1306 return NULL;
1309 } 1307 }
1310 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1308 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1311 if (!p) 1309 if (!p)
1312 return NULL; 1310 return NULL;
1313 p->kind = While_kind; 1311 p->kind = While_kind;
1314 p->v.While.test = test; 1312 p->v.While.test = test;
1315 p->v.While.body = body; 1313 p->v.While.body = body;
1316 p->v.While.orelse = orelse; 1314 p->v.While.orelse = orelse;
1317 p->lineno = lineno; 1315 p->lineno = lineno;
1318 p->col_offset = col_offset; 1316 p->col_offset = col_offset;
1319 return p; 1317 return p;
1320 } 1318 }
1321 1319
1322 stmt_ty 1320 stmt_ty
1323 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int 1321 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
1324 col_offset, PyArena *arena) 1322 col_offset, PyArena *arena)
1325 { 1323 {
1326 stmt_ty p; 1324 stmt_ty p;
1327 if (!test) { 1325 if (!test) {
1328 PyErr_SetString(PyExc_ValueError, 1326 PyErr_SetString(PyExc_ValueError,
1329 "field test is required for If"); 1327 "field test is required for If");
1330 return NULL; 1328 return NULL;
1331 } 1329 }
1332 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1330 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1333 if (!p) 1331 if (!p)
1334 return NULL; 1332 return NULL;
1335 p->kind = If_kind; 1333 p->kind = If_kind;
1336 p->v.If.test = test; 1334 p->v.If.test = test;
1337 p->v.If.body = body; 1335 p->v.If.body = body;
1338 p->v.If.orelse = orelse; 1336 p->v.If.orelse = orelse;
1339 p->lineno = lineno; 1337 p->lineno = lineno;
1340 p->col_offset = col_offset; 1338 p->col_offset = col_offset;
1341 return p; 1339 return p;
1342 } 1340 }
1343 1341
1344 stmt_ty 1342 stmt_ty
1345 With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena 1343 With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena
1346 *arena) 1344 *arena)
1347 { 1345 {
1348 stmt_ty p; 1346 stmt_ty p;
1349 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1347 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1350 if (!p) 1348 if (!p)
1351 return NULL; 1349 return NULL;
1352 p->kind = With_kind; 1350 p->kind = With_kind;
1353 p->v.With.items = items; 1351 p->v.With.items = items;
1354 p->v.With.body = body; 1352 p->v.With.body = body;
1355 p->lineno = lineno; 1353 p->lineno = lineno;
1356 p->col_offset = col_offset; 1354 p->col_offset = col_offset;
1357 return p; 1355 return p;
1358 } 1356 }
1359 1357
1360 stmt_ty 1358 stmt_ty
1361 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena) 1359 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena)
1362 { 1360 {
1363 stmt_ty p; 1361 stmt_ty p;
1364 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1362 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1365 if (!p) 1363 if (!p)
1366 return NULL; 1364 return NULL;
1367 p->kind = Raise_kind; 1365 p->kind = Raise_kind;
1368 p->v.Raise.exc = exc; 1366 p->v.Raise.exc = exc;
1369 p->v.Raise.cause = cause; 1367 p->v.Raise.cause = cause;
1370 p->lineno = lineno; 1368 p->lineno = lineno;
1371 p->col_offset = col_offset; 1369 p->col_offset = col_offset;
1372 return p; 1370 return p;
1373 } 1371 }
1374 1372
1375 stmt_ty 1373 stmt_ty
1376 Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq * 1374 Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq *
1377 finalbody, int lineno, int col_offset, PyArena *arena) 1375 finalbody, int lineno, int col_offset, PyArena *arena)
1378 { 1376 {
1379 stmt_ty p; 1377 stmt_ty p;
1380 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1378 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1381 if (!p) 1379 if (!p)
1382 return NULL; 1380 return NULL;
1383 p->kind = Try_kind; 1381 p->kind = Try_kind;
1384 p->v.Try.body = body; 1382 p->v.Try.body = body;
1385 p->v.Try.handlers = handlers; 1383 p->v.Try.handlers = handlers;
1386 p->v.Try.orelse = orelse; 1384 p->v.Try.orelse = orelse;
1387 p->v.Try.finalbody = finalbody; 1385 p->v.Try.finalbody = finalbody;
1388 p->lineno = lineno; 1386 p->lineno = lineno;
1389 p->col_offset = col_offset; 1387 p->col_offset = col_offset;
1390 return p; 1388 return p;
1391 } 1389 }
1392 1390
1393 stmt_ty 1391 stmt_ty
1394 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) 1392 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena)
1395 { 1393 {
1396 stmt_ty p; 1394 stmt_ty p;
1397 if (!test) { 1395 if (!test) {
1398 PyErr_SetString(PyExc_ValueError, 1396 PyErr_SetString(PyExc_ValueError,
1399 "field test is required for Assert"); 1397 "field test is required for Assert");
1400 return NULL; 1398 return NULL;
1401 } 1399 }
1402 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1400 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1403 if (!p) 1401 if (!p)
1404 return NULL; 1402 return NULL;
1405 p->kind = Assert_kind; 1403 p->kind = Assert_kind;
1406 p->v.Assert.test = test; 1404 p->v.Assert.test = test;
1407 p->v.Assert.msg = msg; 1405 p->v.Assert.msg = msg;
1408 p->lineno = lineno; 1406 p->lineno = lineno;
1409 p->col_offset = col_offset; 1407 p->col_offset = col_offset;
1410 return p; 1408 return p;
1411 } 1409 }
1412 1410
1413 stmt_ty 1411 stmt_ty
1414 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) 1412 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
1415 { 1413 {
1416 stmt_ty p; 1414 stmt_ty p;
1417 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1415 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1418 if (!p) 1416 if (!p)
1419 return NULL; 1417 return NULL;
1420 p->kind = Import_kind; 1418 p->kind = Import_kind;
1421 p->v.Import.names = names; 1419 p->v.Import.names = names;
1422 p->lineno = lineno; 1420 p->lineno = lineno;
1423 p->col_offset = col_offset; 1421 p->col_offset = col_offset;
1424 return p; 1422 return p;
1425 } 1423 }
1426 1424
1427 stmt_ty 1425 stmt_ty
1428 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int 1426 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
1429 col_offset, PyArena *arena) 1427 col_offset, PyArena *arena)
1430 { 1428 {
1431 stmt_ty p; 1429 stmt_ty p;
1432 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1430 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1433 if (!p) 1431 if (!p)
1434 return NULL; 1432 return NULL;
1435 p->kind = ImportFrom_kind; 1433 p->kind = ImportFrom_kind;
1436 p->v.ImportFrom.module = module; 1434 p->v.ImportFrom.module = module;
1437 p->v.ImportFrom.names = names; 1435 p->v.ImportFrom.names = names;
1438 p->v.ImportFrom.level = level; 1436 p->v.ImportFrom.level = level;
1439 p->lineno = lineno; 1437 p->lineno = lineno;
1440 p->col_offset = col_offset; 1438 p->col_offset = col_offset;
1441 return p; 1439 return p;
1442 } 1440 }
1443 1441
1444 stmt_ty 1442 stmt_ty
1445 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) 1443 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
1446 { 1444 {
1447 stmt_ty p; 1445 stmt_ty p;
1448 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1446 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1449 if (!p) 1447 if (!p)
1450 return NULL; 1448 return NULL;
1451 p->kind = Global_kind; 1449 p->kind = Global_kind;
1452 p->v.Global.names = names; 1450 p->v.Global.names = names;
1453 p->lineno = lineno; 1451 p->lineno = lineno;
1454 p->col_offset = col_offset; 1452 p->col_offset = col_offset;
1455 return p; 1453 return p;
1456 } 1454 }
1457 1455
1458 stmt_ty 1456 stmt_ty
1459 Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena) 1457 Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
1460 { 1458 {
1461 stmt_ty p; 1459 stmt_ty p;
1462 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1460 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1463 if (!p) 1461 if (!p)
1464 return NULL; 1462 return NULL;
1465 p->kind = Nonlocal_kind; 1463 p->kind = Nonlocal_kind;
1466 p->v.Nonlocal.names = names; 1464 p->v.Nonlocal.names = names;
1467 p->lineno = lineno; 1465 p->lineno = lineno;
1468 p->col_offset = col_offset; 1466 p->col_offset = col_offset;
1469 return p; 1467 return p;
1470 } 1468 }
1471 1469
1472 stmt_ty 1470 stmt_ty
1473 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) 1471 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena)
1474 { 1472 {
1475 stmt_ty p; 1473 stmt_ty p;
1476 if (!value) { 1474 if (!value) {
1477 PyErr_SetString(PyExc_ValueError, 1475 PyErr_SetString(PyExc_ValueError,
1478 "field value is required for Expr"); 1476 "field value is required for Expr");
1479 return NULL; 1477 return NULL;
1480 } 1478 }
1481 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1479 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1482 if (!p) 1480 if (!p)
1483 return NULL; 1481 return NULL;
1484 p->kind = Expr_kind; 1482 p->kind = Expr_kind;
1485 p->v.Expr.value = value; 1483 p->v.Expr.value = value;
1486 p->lineno = lineno; 1484 p->lineno = lineno;
1487 p->col_offset = col_offset; 1485 p->col_offset = col_offset;
1488 return p; 1486 return p;
1489 } 1487 }
1490 1488
1491 stmt_ty 1489 stmt_ty
1492 Pass(int lineno, int col_offset, PyArena *arena) 1490 Pass(int lineno, int col_offset, PyArena *arena)
1493 { 1491 {
1494 stmt_ty p; 1492 stmt_ty p;
1495 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1493 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1496 if (!p) 1494 if (!p)
1497 return NULL; 1495 return NULL;
1498 p->kind = Pass_kind; 1496 p->kind = Pass_kind;
1499 p->lineno = lineno; 1497 p->lineno = lineno;
1500 p->col_offset = col_offset; 1498 p->col_offset = col_offset;
1501 return p; 1499 return p;
1502 } 1500 }
1503 1501
1504 stmt_ty 1502 stmt_ty
1505 Break(int lineno, int col_offset, PyArena *arena) 1503 Break(int lineno, int col_offset, PyArena *arena)
1506 { 1504 {
1507 stmt_ty p; 1505 stmt_ty p;
1508 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1506 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1509 if (!p) 1507 if (!p)
1510 return NULL; 1508 return NULL;
1511 p->kind = Break_kind; 1509 p->kind = Break_kind;
1512 p->lineno = lineno; 1510 p->lineno = lineno;
1513 p->col_offset = col_offset; 1511 p->col_offset = col_offset;
1514 return p; 1512 return p;
1515 } 1513 }
1516 1514
1517 stmt_ty 1515 stmt_ty
1518 Continue(int lineno, int col_offset, PyArena *arena) 1516 Continue(int lineno, int col_offset, PyArena *arena)
1519 { 1517 {
1520 stmt_ty p; 1518 stmt_ty p;
1521 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); 1519 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
1522 if (!p) 1520 if (!p)
1523 return NULL; 1521 return NULL;
1524 p->kind = Continue_kind; 1522 p->kind = Continue_kind;
1525 p->lineno = lineno; 1523 p->lineno = lineno;
1526 p->col_offset = col_offset; 1524 p->col_offset = col_offset;
1527 return p; 1525 return p;
1528 } 1526 }
1529 1527
1530 expr_ty 1528 expr_ty
1531 BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena 1529 BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena
1532 *arena) 1530 *arena)
1533 { 1531 {
1534 expr_ty p; 1532 expr_ty p;
1535 if (!op) { 1533 if (!op) {
1536 PyErr_SetString(PyExc_ValueError, 1534 PyErr_SetString(PyExc_ValueError,
1537 "field op is required for BoolOp"); 1535 "field op is required for BoolOp");
1538 return NULL; 1536 return NULL;
1539 } 1537 }
1540 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1538 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1541 if (!p) 1539 if (!p)
1542 return NULL; 1540 return NULL;
1543 p->kind = BoolOp_kind; 1541 p->kind = BoolOp_kind;
1544 p->v.BoolOp.op = op; 1542 p->v.BoolOp.op = op;
1545 p->v.BoolOp.values = values; 1543 p->v.BoolOp.values = values;
1546 p->lineno = lineno; 1544 p->lineno = lineno;
1547 p->col_offset = col_offset; 1545 p->col_offset = col_offset;
1548 return p; 1546 return p;
1549 } 1547 }
1550 1548
1551 expr_ty 1549 expr_ty
1552 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset, 1550 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
1553 PyArena *arena) 1551 PyArena *arena)
1554 { 1552 {
1555 expr_ty p; 1553 expr_ty p;
1556 if (!left) { 1554 if (!left) {
1557 PyErr_SetString(PyExc_ValueError, 1555 PyErr_SetString(PyExc_ValueError,
1558 "field left is required for BinOp"); 1556 "field left is required for BinOp");
1559 return NULL; 1557 return NULL;
1560 } 1558 }
1561 if (!op) { 1559 if (!op) {
1562 PyErr_SetString(PyExc_ValueError, 1560 PyErr_SetString(PyExc_ValueError,
1563 "field op is required for BinOp"); 1561 "field op is required for BinOp");
1564 return NULL; 1562 return NULL;
1565 } 1563 }
1566 if (!right) { 1564 if (!right) {
1567 PyErr_SetString(PyExc_ValueError, 1565 PyErr_SetString(PyExc_ValueError,
1568 "field right is required for BinOp"); 1566 "field right is required for BinOp");
1569 return NULL; 1567 return NULL;
1570 } 1568 }
1571 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1569 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1572 if (!p) 1570 if (!p)
1573 return NULL; 1571 return NULL;
1574 p->kind = BinOp_kind; 1572 p->kind = BinOp_kind;
1575 p->v.BinOp.left = left; 1573 p->v.BinOp.left = left;
1576 p->v.BinOp.op = op; 1574 p->v.BinOp.op = op;
1577 p->v.BinOp.right = right; 1575 p->v.BinOp.right = right;
1578 p->lineno = lineno; 1576 p->lineno = lineno;
1579 p->col_offset = col_offset; 1577 p->col_offset = col_offset;
1580 return p; 1578 return p;
1581 } 1579 }
1582 1580
1583 expr_ty 1581 expr_ty
1584 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena 1582 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena
1585 *arena) 1583 *arena)
1586 { 1584 {
1587 expr_ty p; 1585 expr_ty p;
1588 if (!op) { 1586 if (!op) {
1589 PyErr_SetString(PyExc_ValueError, 1587 PyErr_SetString(PyExc_ValueError,
1590 "field op is required for UnaryOp"); 1588 "field op is required for UnaryOp");
1591 return NULL; 1589 return NULL;
1592 } 1590 }
1593 if (!operand) { 1591 if (!operand) {
1594 PyErr_SetString(PyExc_ValueError, 1592 PyErr_SetString(PyExc_ValueError,
1595 "field operand is required for UnaryOp"); 1593 "field operand is required for UnaryOp");
1596 return NULL; 1594 return NULL;
1597 } 1595 }
1598 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1596 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1599 if (!p) 1597 if (!p)
1600 return NULL; 1598 return NULL;
1601 p->kind = UnaryOp_kind; 1599 p->kind = UnaryOp_kind;
1602 p->v.UnaryOp.op = op; 1600 p->v.UnaryOp.op = op;
1603 p->v.UnaryOp.operand = operand; 1601 p->v.UnaryOp.operand = operand;
1604 p->lineno = lineno; 1602 p->lineno = lineno;
1605 p->col_offset = col_offset; 1603 p->col_offset = col_offset;
1606 return p; 1604 return p;
1607 } 1605 }
1608 1606
1609 expr_ty 1607 expr_ty
1610 Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena 1608 Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena
1611 *arena) 1609 *arena)
1612 { 1610 {
1613 expr_ty p; 1611 expr_ty p;
1614 if (!args) { 1612 if (!args) {
1615 PyErr_SetString(PyExc_ValueError, 1613 PyErr_SetString(PyExc_ValueError,
1616 "field args is required for Lambda"); 1614 "field args is required for Lambda");
1617 return NULL; 1615 return NULL;
1618 } 1616 }
1619 if (!body) { 1617 if (!body) {
1620 PyErr_SetString(PyExc_ValueError, 1618 PyErr_SetString(PyExc_ValueError,
1621 "field body is required for Lambda"); 1619 "field body is required for Lambda");
1622 return NULL; 1620 return NULL;
1623 } 1621 }
1624 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1622 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1625 if (!p) 1623 if (!p)
1626 return NULL; 1624 return NULL;
1627 p->kind = Lambda_kind; 1625 p->kind = Lambda_kind;
1628 p->v.Lambda.args = args; 1626 p->v.Lambda.args = args;
1629 p->v.Lambda.body = body; 1627 p->v.Lambda.body = body;
1630 p->lineno = lineno; 1628 p->lineno = lineno;
1631 p->col_offset = col_offset; 1629 p->col_offset = col_offset;
1632 return p; 1630 return p;
1633 } 1631 }
1634 1632
1635 expr_ty 1633 expr_ty
1636 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset, 1634 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
1637 PyArena *arena) 1635 PyArena *arena)
1638 { 1636 {
1639 expr_ty p; 1637 expr_ty p;
1640 if (!test) { 1638 if (!test) {
1641 PyErr_SetString(PyExc_ValueError, 1639 PyErr_SetString(PyExc_ValueError,
1642 "field test is required for IfExp"); 1640 "field test is required for IfExp");
1643 return NULL; 1641 return NULL;
1644 } 1642 }
1645 if (!body) { 1643 if (!body) {
1646 PyErr_SetString(PyExc_ValueError, 1644 PyErr_SetString(PyExc_ValueError,
1647 "field body is required for IfExp"); 1645 "field body is required for IfExp");
1648 return NULL; 1646 return NULL;
1649 } 1647 }
1650 if (!orelse) { 1648 if (!orelse) {
1651 PyErr_SetString(PyExc_ValueError, 1649 PyErr_SetString(PyExc_ValueError,
1652 "field orelse is required for IfExp"); 1650 "field orelse is required for IfExp");
1653 return NULL; 1651 return NULL;
1654 } 1652 }
1655 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1653 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1656 if (!p) 1654 if (!p)
1657 return NULL; 1655 return NULL;
1658 p->kind = IfExp_kind; 1656 p->kind = IfExp_kind;
1659 p->v.IfExp.test = test; 1657 p->v.IfExp.test = test;
1660 p->v.IfExp.body = body; 1658 p->v.IfExp.body = body;
1661 p->v.IfExp.orelse = orelse; 1659 p->v.IfExp.orelse = orelse;
1662 p->lineno = lineno; 1660 p->lineno = lineno;
1663 p->col_offset = col_offset; 1661 p->col_offset = col_offset;
1664 return p; 1662 return p;
1665 } 1663 }
1666 1664
1667 expr_ty 1665 expr_ty
1668 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena 1666 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena
1669 *arena) 1667 *arena)
1670 { 1668 {
1671 expr_ty p; 1669 expr_ty p;
1672 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1670 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1673 if (!p) 1671 if (!p)
1674 return NULL; 1672 return NULL;
1675 p->kind = Dict_kind; 1673 p->kind = Dict_kind;
1676 p->v.Dict.keys = keys; 1674 p->v.Dict.keys = keys;
1677 p->v.Dict.values = values; 1675 p->v.Dict.values = values;
1678 p->lineno = lineno; 1676 p->lineno = lineno;
1679 p->col_offset = col_offset; 1677 p->col_offset = col_offset;
1680 return p; 1678 return p;
1681 } 1679 }
1682 1680
1683 expr_ty 1681 expr_ty
1684 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) 1682 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena)
1685 { 1683 {
1686 expr_ty p; 1684 expr_ty p;
1687 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1685 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1688 if (!p) 1686 if (!p)
1689 return NULL; 1687 return NULL;
1690 p->kind = Set_kind; 1688 p->kind = Set_kind;
1691 p->v.Set.elts = elts; 1689 p->v.Set.elts = elts;
1692 p->lineno = lineno; 1690 p->lineno = lineno;
1693 p->col_offset = col_offset; 1691 p->col_offset = col_offset;
1694 return p; 1692 return p;
1695 } 1693 }
1696 1694
1697 expr_ty 1695 expr_ty
1698 ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, 1696 ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
1699 PyArena *arena) 1697 PyArena *arena)
1700 { 1698 {
1701 expr_ty p; 1699 expr_ty p;
1702 if (!elt) { 1700 if (!elt) {
1703 PyErr_SetString(PyExc_ValueError, 1701 PyErr_SetString(PyExc_ValueError,
1704 "field elt is required for ListComp"); 1702 "field elt is required for ListComp");
1705 return NULL; 1703 return NULL;
1706 } 1704 }
1707 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1705 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1708 if (!p) 1706 if (!p)
1709 return NULL; 1707 return NULL;
1710 p->kind = ListComp_kind; 1708 p->kind = ListComp_kind;
1711 p->v.ListComp.elt = elt; 1709 p->v.ListComp.elt = elt;
1712 p->v.ListComp.generators = generators; 1710 p->v.ListComp.generators = generators;
1713 p->lineno = lineno; 1711 p->lineno = lineno;
1714 p->col_offset = col_offset; 1712 p->col_offset = col_offset;
1715 return p; 1713 return p;
1716 } 1714 }
1717 1715
1718 expr_ty 1716 expr_ty
1719 SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena 1717 SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena
1720 *arena) 1718 *arena)
1721 { 1719 {
1722 expr_ty p; 1720 expr_ty p;
1723 if (!elt) { 1721 if (!elt) {
1724 PyErr_SetString(PyExc_ValueError, 1722 PyErr_SetString(PyExc_ValueError,
1725 "field elt is required for SetComp"); 1723 "field elt is required for SetComp");
1726 return NULL; 1724 return NULL;
1727 } 1725 }
1728 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1726 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1729 if (!p) 1727 if (!p)
1730 return NULL; 1728 return NULL;
1731 p->kind = SetComp_kind; 1729 p->kind = SetComp_kind;
1732 p->v.SetComp.elt = elt; 1730 p->v.SetComp.elt = elt;
1733 p->v.SetComp.generators = generators; 1731 p->v.SetComp.generators = generators;
1734 p->lineno = lineno; 1732 p->lineno = lineno;
1735 p->col_offset = col_offset; 1733 p->col_offset = col_offset;
1736 return p; 1734 return p;
1737 } 1735 }
1738 1736
1739 expr_ty 1737 expr_ty
1740 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int 1738 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
1741 col_offset, PyArena *arena) 1739 col_offset, PyArena *arena)
1742 { 1740 {
1743 expr_ty p; 1741 expr_ty p;
1744 if (!key) { 1742 if (!key) {
1745 PyErr_SetString(PyExc_ValueError, 1743 PyErr_SetString(PyExc_ValueError,
1746 "field key is required for DictComp"); 1744 "field key is required for DictComp");
1747 return NULL; 1745 return NULL;
1748 } 1746 }
1749 if (!value) { 1747 if (!value) {
1750 PyErr_SetString(PyExc_ValueError, 1748 PyErr_SetString(PyExc_ValueError,
1751 "field value is required for DictComp"); 1749 "field value is required for DictComp");
1752 return NULL; 1750 return NULL;
1753 } 1751 }
1754 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1752 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1755 if (!p) 1753 if (!p)
1756 return NULL; 1754 return NULL;
1757 p->kind = DictComp_kind; 1755 p->kind = DictComp_kind;
1758 p->v.DictComp.key = key; 1756 p->v.DictComp.key = key;
1759 p->v.DictComp.value = value; 1757 p->v.DictComp.value = value;
1760 p->v.DictComp.generators = generators; 1758 p->v.DictComp.generators = generators;
1761 p->lineno = lineno; 1759 p->lineno = lineno;
1762 p->col_offset = col_offset; 1760 p->col_offset = col_offset;
1763 return p; 1761 return p;
1764 } 1762 }
1765 1763
1766 expr_ty 1764 expr_ty
1767 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, 1765 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
1768 PyArena *arena) 1766 PyArena *arena)
1769 { 1767 {
1770 expr_ty p; 1768 expr_ty p;
1771 if (!elt) { 1769 if (!elt) {
1772 PyErr_SetString(PyExc_ValueError, 1770 PyErr_SetString(PyExc_ValueError,
1773 "field elt is required for GeneratorExp"); 1771 "field elt is required for GeneratorExp");
1774 return NULL; 1772 return NULL;
1775 } 1773 }
1776 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1774 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1777 if (!p) 1775 if (!p)
1778 return NULL; 1776 return NULL;
1779 p->kind = GeneratorExp_kind; 1777 p->kind = GeneratorExp_kind;
1780 p->v.GeneratorExp.elt = elt; 1778 p->v.GeneratorExp.elt = elt;
1781 p->v.GeneratorExp.generators = generators; 1779 p->v.GeneratorExp.generators = generators;
1782 p->lineno = lineno; 1780 p->lineno = lineno;
1783 p->col_offset = col_offset; 1781 p->col_offset = col_offset;
1784 return p; 1782 return p;
1785 } 1783 }
1786 1784
1787 expr_ty 1785 expr_ty
1788 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) 1786 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena)
1789 { 1787 {
1790 expr_ty p; 1788 expr_ty p;
1791 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1789 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1792 if (!p) 1790 if (!p)
1793 return NULL; 1791 return NULL;
1794 p->kind = Yield_kind; 1792 p->kind = Yield_kind;
1795 p->v.Yield.value = value; 1793 p->v.Yield.value = value;
1796 p->lineno = lineno; 1794 p->lineno = lineno;
1797 p->col_offset = col_offset; 1795 p->col_offset = col_offset;
1798 return p; 1796 return p;
1799 } 1797 }
1800 1798
1801 expr_ty 1799 expr_ty
1802 YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena) 1800 YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena)
1803 { 1801 {
1804 expr_ty p; 1802 expr_ty p;
1805 if (!value) { 1803 if (!value) {
1806 PyErr_SetString(PyExc_ValueError, 1804 PyErr_SetString(PyExc_ValueError,
1807 "field value is required for YieldFrom"); 1805 "field value is required for YieldFrom");
1808 return NULL; 1806 return NULL;
1809 } 1807 }
1810 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1808 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1811 if (!p) 1809 if (!p)
1812 return NULL; 1810 return NULL;
1813 p->kind = YieldFrom_kind; 1811 p->kind = YieldFrom_kind;
1814 p->v.YieldFrom.value = value; 1812 p->v.YieldFrom.value = value;
1815 p->lineno = lineno; 1813 p->lineno = lineno;
1816 p->col_offset = col_offset; 1814 p->col_offset = col_offset;
1817 return p; 1815 return p;
1818 } 1816 }
1819 1817
1820 expr_ty 1818 expr_ty
1821 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, 1819 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
1822 int col_offset, PyArena *arena) 1820 int col_offset, PyArena *arena)
1823 { 1821 {
1824 expr_ty p; 1822 expr_ty p;
1825 if (!left) { 1823 if (!left) {
1826 PyErr_SetString(PyExc_ValueError, 1824 PyErr_SetString(PyExc_ValueError,
1827 "field left is required for Compare"); 1825 "field left is required for Compare");
1828 return NULL; 1826 return NULL;
1829 } 1827 }
1830 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1828 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1831 if (!p) 1829 if (!p)
1832 return NULL; 1830 return NULL;
1833 p->kind = Compare_kind; 1831 p->kind = Compare_kind;
1834 p->v.Compare.left = left; 1832 p->v.Compare.left = left;
1835 p->v.Compare.ops = ops; 1833 p->v.Compare.ops = ops;
1836 p->v.Compare.comparators = comparators; 1834 p->v.Compare.comparators = comparators;
1837 p->lineno = lineno; 1835 p->lineno = lineno;
1838 p->col_offset = col_offset; 1836 p->col_offset = col_offset;
1839 return p; 1837 return p;
1840 } 1838 }
1841 1839
1842 expr_ty 1840 expr_ty
1843 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, 1841 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
1844 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) 1842 expr_ty kwargs, int lineno, int col_offset, PyArena *arena)
1845 { 1843 {
1846 expr_ty p; 1844 expr_ty p;
1847 if (!func) { 1845 if (!func) {
1848 PyErr_SetString(PyExc_ValueError, 1846 PyErr_SetString(PyExc_ValueError,
1849 "field func is required for Call"); 1847 "field func is required for Call");
1850 return NULL; 1848 return NULL;
1851 } 1849 }
1852 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1850 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1853 if (!p) 1851 if (!p)
1854 return NULL; 1852 return NULL;
1855 p->kind = Call_kind; 1853 p->kind = Call_kind;
1856 p->v.Call.func = func; 1854 p->v.Call.func = func;
1857 p->v.Call.args = args; 1855 p->v.Call.args = args;
1858 p->v.Call.keywords = keywords; 1856 p->v.Call.keywords = keywords;
1859 p->v.Call.starargs = starargs; 1857 p->v.Call.starargs = starargs;
1860 p->v.Call.kwargs = kwargs; 1858 p->v.Call.kwargs = kwargs;
1861 p->lineno = lineno; 1859 p->lineno = lineno;
1862 p->col_offset = col_offset; 1860 p->col_offset = col_offset;
1863 return p; 1861 return p;
1864 } 1862 }
1865 1863
1866 expr_ty 1864 expr_ty
1867 Num(object n, int lineno, int col_offset, PyArena *arena) 1865 Num(object n, int lineno, int col_offset, PyArena *arena)
1868 { 1866 {
1869 expr_ty p; 1867 expr_ty p;
1870 if (!n) { 1868 if (!n) {
1871 PyErr_SetString(PyExc_ValueError, 1869 PyErr_SetString(PyExc_ValueError,
1872 "field n is required for Num"); 1870 "field n is required for Num");
1873 return NULL; 1871 return NULL;
1874 } 1872 }
1875 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1873 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1876 if (!p) 1874 if (!p)
1877 return NULL; 1875 return NULL;
1878 p->kind = Num_kind; 1876 p->kind = Num_kind;
1879 p->v.Num.n = n; 1877 p->v.Num.n = n;
1880 p->lineno = lineno; 1878 p->lineno = lineno;
1881 p->col_offset = col_offset; 1879 p->col_offset = col_offset;
1882 return p; 1880 return p;
1883 } 1881 }
1884 1882
1885 expr_ty 1883 expr_ty
1886 Str(string s, int lineno, int col_offset, PyArena *arena) 1884 Str(string s, int lineno, int col_offset, PyArena *arena)
1887 { 1885 {
1888 expr_ty p; 1886 expr_ty p;
1889 if (!s) { 1887 if (!s) {
1890 PyErr_SetString(PyExc_ValueError, 1888 PyErr_SetString(PyExc_ValueError,
1891 "field s is required for Str"); 1889 "field s is required for Str");
1892 return NULL; 1890 return NULL;
1893 } 1891 }
1894 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1892 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1895 if (!p) 1893 if (!p)
1896 return NULL; 1894 return NULL;
1897 p->kind = Str_kind; 1895 p->kind = Str_kind;
1898 p->v.Str.s = s; 1896 p->v.Str.s = s;
1899 p->lineno = lineno; 1897 p->lineno = lineno;
1900 p->col_offset = col_offset; 1898 p->col_offset = col_offset;
1901 return p; 1899 return p;
1902 } 1900 }
1903 1901
1904 expr_ty 1902 expr_ty
1905 Bytes(bytes s, int lineno, int col_offset, PyArena *arena) 1903 Bytes(bytes s, int lineno, int col_offset, PyArena *arena)
1906 { 1904 {
1907 expr_ty p; 1905 expr_ty p;
1908 if (!s) { 1906 if (!s) {
1909 PyErr_SetString(PyExc_ValueError, 1907 PyErr_SetString(PyExc_ValueError,
1910 "field s is required for Bytes"); 1908 "field s is required for Bytes");
1911 return NULL; 1909 return NULL;
1912 } 1910 }
1913 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1911 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1914 if (!p) 1912 if (!p)
1915 return NULL; 1913 return NULL;
1916 p->kind = Bytes_kind; 1914 p->kind = Bytes_kind;
1917 p->v.Bytes.s = s; 1915 p->v.Bytes.s = s;
1918 p->lineno = lineno; 1916 p->lineno = lineno;
1919 p->col_offset = col_offset; 1917 p->col_offset = col_offset;
1920 return p; 1918 return p;
1921 } 1919 }
1922 1920
1923 expr_ty 1921 expr_ty
1924 Ellipsis(int lineno, int col_offset, PyArena *arena) 1922 Ellipsis(int lineno, int col_offset, PyArena *arena)
1925 { 1923 {
1926 expr_ty p; 1924 expr_ty p;
1927 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1925 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1928 if (!p) 1926 if (!p)
1929 return NULL; 1927 return NULL;
1930 p->kind = Ellipsis_kind; 1928 p->kind = Ellipsis_kind;
1931 p->lineno = lineno; 1929 p->lineno = lineno;
1932 p->col_offset = col_offset; 1930 p->col_offset = col_offset;
1933 return p; 1931 return p;
1934 } 1932 }
1935 1933
1936 expr_ty 1934 expr_ty
1937 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int 1935 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
1938 col_offset, PyArena *arena) 1936 col_offset, PyArena *arena)
1939 { 1937 {
1940 expr_ty p; 1938 expr_ty p;
1941 if (!value) { 1939 if (!value) {
1942 PyErr_SetString(PyExc_ValueError, 1940 PyErr_SetString(PyExc_ValueError,
1943 "field value is required for Attribute"); 1941 "field value is required for Attribute");
1944 return NULL; 1942 return NULL;
1945 } 1943 }
1946 if (!attr) { 1944 if (!attr) {
1947 PyErr_SetString(PyExc_ValueError, 1945 PyErr_SetString(PyExc_ValueError,
1948 "field attr is required for Attribute"); 1946 "field attr is required for Attribute");
1949 return NULL; 1947 return NULL;
1950 } 1948 }
1951 if (!ctx) { 1949 if (!ctx) {
1952 PyErr_SetString(PyExc_ValueError, 1950 PyErr_SetString(PyExc_ValueError,
1953 "field ctx is required for Attribute"); 1951 "field ctx is required for Attribute");
1954 return NULL; 1952 return NULL;
1955 } 1953 }
1956 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1954 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1957 if (!p) 1955 if (!p)
1958 return NULL; 1956 return NULL;
1959 p->kind = Attribute_kind; 1957 p->kind = Attribute_kind;
1960 p->v.Attribute.value = value; 1958 p->v.Attribute.value = value;
1961 p->v.Attribute.attr = attr; 1959 p->v.Attribute.attr = attr;
1962 p->v.Attribute.ctx = ctx; 1960 p->v.Attribute.ctx = ctx;
1963 p->lineno = lineno; 1961 p->lineno = lineno;
1964 p->col_offset = col_offset; 1962 p->col_offset = col_offset;
1965 return p; 1963 return p;
1966 } 1964 }
1967 1965
1968 expr_ty 1966 expr_ty
1969 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int 1967 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int
1970 col_offset, PyArena *arena) 1968 col_offset, PyArena *arena)
1971 { 1969 {
1972 expr_ty p; 1970 expr_ty p;
1973 if (!value) { 1971 if (!value) {
1974 PyErr_SetString(PyExc_ValueError, 1972 PyErr_SetString(PyExc_ValueError,
1975 "field value is required for Subscript"); 1973 "field value is required for Subscript");
1976 return NULL; 1974 return NULL;
1977 } 1975 }
1978 if (!slice) { 1976 if (!slice) {
1979 PyErr_SetString(PyExc_ValueError, 1977 PyErr_SetString(PyExc_ValueError,
1980 "field slice is required for Subscript"); 1978 "field slice is required for Subscript");
1981 return NULL; 1979 return NULL;
1982 } 1980 }
1983 if (!ctx) { 1981 if (!ctx) {
1984 PyErr_SetString(PyExc_ValueError, 1982 PyErr_SetString(PyExc_ValueError,
1985 "field ctx is required for Subscript"); 1983 "field ctx is required for Subscript");
1986 return NULL; 1984 return NULL;
1987 } 1985 }
1988 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 1986 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
1989 if (!p) 1987 if (!p)
1990 return NULL; 1988 return NULL;
1991 p->kind = Subscript_kind; 1989 p->kind = Subscript_kind;
1992 p->v.Subscript.value = value; 1990 p->v.Subscript.value = value;
1993 p->v.Subscript.slice = slice; 1991 p->v.Subscript.slice = slice;
1994 p->v.Subscript.ctx = ctx; 1992 p->v.Subscript.ctx = ctx;
1995 p->lineno = lineno; 1993 p->lineno = lineno;
1996 p->col_offset = col_offset; 1994 p->col_offset = col_offset;
1997 return p; 1995 return p;
1998 } 1996 }
1999 1997
2000 expr_ty 1998 expr_ty
2001 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena 1999 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena
2002 *arena) 2000 *arena)
2003 { 2001 {
2004 expr_ty p; 2002 expr_ty p;
2005 if (!value) { 2003 if (!value) {
2006 PyErr_SetString(PyExc_ValueError, 2004 PyErr_SetString(PyExc_ValueError,
2007 "field value is required for Starred"); 2005 "field value is required for Starred");
2008 return NULL; 2006 return NULL;
2009 } 2007 }
2010 if (!ctx) { 2008 if (!ctx) {
2011 PyErr_SetString(PyExc_ValueError, 2009 PyErr_SetString(PyExc_ValueError,
2012 "field ctx is required for Starred"); 2010 "field ctx is required for Starred");
2013 return NULL; 2011 return NULL;
2014 } 2012 }
2015 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 2013 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
2016 if (!p) 2014 if (!p)
2017 return NULL; 2015 return NULL;
2018 p->kind = Starred_kind; 2016 p->kind = Starred_kind;
2019 p->v.Starred.value = value; 2017 p->v.Starred.value = value;
2020 p->v.Starred.ctx = ctx; 2018 p->v.Starred.ctx = ctx;
2021 p->lineno = lineno; 2019 p->lineno = lineno;
2022 p->col_offset = col_offset; 2020 p->col_offset = col_offset;
2023 return p; 2021 return p;
2024 } 2022 }
2025 2023
2026 expr_ty 2024 expr_ty
2027 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena 2025 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena
2028 *arena) 2026 *arena)
2029 { 2027 {
2030 expr_ty p; 2028 expr_ty p;
2031 if (!id) { 2029 if (!id) {
2032 PyErr_SetString(PyExc_ValueError, 2030 PyErr_SetString(PyExc_ValueError,
2033 "field id is required for Name"); 2031 "field id is required for Name");
2034 return NULL; 2032 return NULL;
2035 } 2033 }
2036 if (!ctx) { 2034 if (!ctx) {
2037 PyErr_SetString(PyExc_ValueError, 2035 PyErr_SetString(PyExc_ValueError,
2038 "field ctx is required for Name"); 2036 "field ctx is required for Name");
2039 return NULL; 2037 return NULL;
2040 } 2038 }
2041 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 2039 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
2042 if (!p) 2040 if (!p)
2043 return NULL; 2041 return NULL;
2044 p->kind = Name_kind; 2042 p->kind = Name_kind;
2045 p->v.Name.id = id; 2043 p->v.Name.id = id;
2046 p->v.Name.ctx = ctx; 2044 p->v.Name.ctx = ctx;
2047 p->lineno = lineno; 2045 p->lineno = lineno;
2048 p->col_offset = col_offset; 2046 p->col_offset = col_offset;
2049 return p; 2047 return p;
2050 } 2048 }
2051 2049
2052 expr_ty 2050 expr_ty
2053 List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena 2051 List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
2054 *arena) 2052 *arena)
2055 { 2053 {
2056 expr_ty p; 2054 expr_ty p;
2057 if (!ctx) { 2055 if (!ctx) {
2058 PyErr_SetString(PyExc_ValueError, 2056 PyErr_SetString(PyExc_ValueError,
2059 "field ctx is required for List"); 2057 "field ctx is required for List");
2060 return NULL; 2058 return NULL;
2061 } 2059 }
2062 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 2060 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
2063 if (!p) 2061 if (!p)
2064 return NULL; 2062 return NULL;
2065 p->kind = List_kind; 2063 p->kind = List_kind;
2066 p->v.List.elts = elts; 2064 p->v.List.elts = elts;
2067 p->v.List.ctx = ctx; 2065 p->v.List.ctx = ctx;
2068 p->lineno = lineno; 2066 p->lineno = lineno;
2069 p->col_offset = col_offset; 2067 p->col_offset = col_offset;
2070 return p; 2068 return p;
2071 } 2069 }
2072 2070
2073 expr_ty 2071 expr_ty
2074 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena 2072 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
2075 *arena) 2073 *arena)
2076 { 2074 {
2077 expr_ty p; 2075 expr_ty p;
2078 if (!ctx) { 2076 if (!ctx) {
2079 PyErr_SetString(PyExc_ValueError, 2077 PyErr_SetString(PyExc_ValueError,
2080 "field ctx is required for Tuple"); 2078 "field ctx is required for Tuple");
2081 return NULL; 2079 return NULL;
2082 } 2080 }
2083 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); 2081 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
2084 if (!p) 2082 if (!p)
2085 return NULL; 2083 return NULL;
2086 p->kind = Tuple_kind; 2084 p->kind = Tuple_kind;
2087 p->v.Tuple.elts = elts; 2085 p->v.Tuple.elts = elts;
2088 p->v.Tuple.ctx = ctx; 2086 p->v.Tuple.ctx = ctx;
2089 p->lineno = lineno; 2087 p->lineno = lineno;
2090 p->col_offset = col_offset; 2088 p->col_offset = col_offset;
2091 return p; 2089 return p;
2092 } 2090 }
2093 2091
2094 slice_ty 2092 slice_ty
2095 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) 2093 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena)
2096 { 2094 {
2097 slice_ty p; 2095 slice_ty p;
2098 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); 2096 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
2099 if (!p) 2097 if (!p)
2100 return NULL; 2098 return NULL;
2101 p->kind = Slice_kind; 2099 p->kind = Slice_kind;
2102 p->v.Slice.lower = lower; 2100 p->v.Slice.lower = lower;
2103 p->v.Slice.upper = upper; 2101 p->v.Slice.upper = upper;
2104 p->v.Slice.step = step; 2102 p->v.Slice.step = step;
2105 return p; 2103 return p;
2106 } 2104 }
2107 2105
2108 slice_ty 2106 slice_ty
2109 ExtSlice(asdl_seq * dims, PyArena *arena) 2107 ExtSlice(asdl_seq * dims, PyArena *arena)
2110 { 2108 {
2111 slice_ty p; 2109 slice_ty p;
2112 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); 2110 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
2113 if (!p) 2111 if (!p)
2114 return NULL; 2112 return NULL;
2115 p->kind = ExtSlice_kind; 2113 p->kind = ExtSlice_kind;
2116 p->v.ExtSlice.dims = dims; 2114 p->v.ExtSlice.dims = dims;
2117 return p; 2115 return p;
2118 } 2116 }
2119 2117
2120 slice_ty 2118 slice_ty
2121 Index(expr_ty value, PyArena *arena) 2119 Index(expr_ty value, PyArena *arena)
2122 { 2120 {
2123 slice_ty p; 2121 slice_ty p;
2124 if (!value) { 2122 if (!value) {
2125 PyErr_SetString(PyExc_ValueError, 2123 PyErr_SetString(PyExc_ValueError,
2126 "field value is required for Index"); 2124 "field value is required for Index");
2127 return NULL; 2125 return NULL;
2128 } 2126 }
2129 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); 2127 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
2130 if (!p) 2128 if (!p)
2131 return NULL; 2129 return NULL;
2132 p->kind = Index_kind; 2130 p->kind = Index_kind;
2133 p->v.Index.value = value; 2131 p->v.Index.value = value;
2134 return p; 2132 return p;
2135 } 2133 }
2136 2134
2137 comprehension_ty 2135 comprehension_ty
2138 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) 2136 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena)
2139 { 2137 {
2140 comprehension_ty p; 2138 comprehension_ty p;
2141 if (!target) { 2139 if (!target) {
2142 PyErr_SetString(PyExc_ValueError, 2140 PyErr_SetString(PyExc_ValueError,
2143 "field target is required for comprehension"); 2141 "field target is required for comprehension");
2144 return NULL; 2142 return NULL;
2145 } 2143 }
2146 if (!iter) { 2144 if (!iter) {
2147 PyErr_SetString(PyExc_ValueError, 2145 PyErr_SetString(PyExc_ValueError,
2148 "field iter is required for comprehension"); 2146 "field iter is required for comprehension");
2149 return NULL; 2147 return NULL;
2150 } 2148 }
2151 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); 2149 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
2152 if (!p) 2150 if (!p)
2153 return NULL; 2151 return NULL;
2154 p->target = target; 2152 p->target = target;
2155 p->iter = iter; 2153 p->iter = iter;
2156 p->ifs = ifs; 2154 p->ifs = ifs;
2157 return p; 2155 return p;
2158 } 2156 }
2159 2157
2160 excepthandler_ty 2158 excepthandler_ty
2161 ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int 2159 ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int
2162 col_offset, PyArena *arena) 2160 col_offset, PyArena *arena)
2163 { 2161 {
2164 excepthandler_ty p; 2162 excepthandler_ty p;
2165 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); 2163 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p));
2166 if (!p) 2164 if (!p)
2167 return NULL; 2165 return NULL;
2168 p->kind = ExceptHandler_kind; 2166 p->kind = ExceptHandler_kind;
2169 p->v.ExceptHandler.type = type; 2167 p->v.ExceptHandler.type = type;
2170 p->v.ExceptHandler.name = name; 2168 p->v.ExceptHandler.name = name;
2171 p->v.ExceptHandler.body = body; 2169 p->v.ExceptHandler.body = body;
2172 p->lineno = lineno; 2170 p->lineno = lineno;
2173 p->col_offset = col_offset; 2171 p->col_offset = col_offset;
2174 return p; 2172 return p;
2175 } 2173 }
2176 2174
2177 arguments_ty 2175 arguments_ty
2178 arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation, 2176 arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation,
2179 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation, 2177 asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation,
2180 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) 2178 asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena)
2181 { 2179 {
2182 arguments_ty p; 2180 arguments_ty p;
2183 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); 2181 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p));
2184 if (!p) 2182 if (!p)
2185 return NULL; 2183 return NULL;
2186 p->args = args; 2184 p->args = args;
2187 p->vararg = vararg; 2185 p->vararg = vararg;
2188 p->varargannotation = varargannotation; 2186 p->varargannotation = varargannotation;
2189 p->kwonlyargs = kwonlyargs; 2187 p->kwonlyargs = kwonlyargs;
2190 p->kwarg = kwarg; 2188 p->kwarg = kwarg;
2191 p->kwargannotation = kwargannotation; 2189 p->kwargannotation = kwargannotation;
2192 p->defaults = defaults; 2190 p->defaults = defaults;
2193 p->kw_defaults = kw_defaults; 2191 p->kw_defaults = kw_defaults;
2194 return p; 2192 return p;
2195 } 2193 }
2196 2194
2197 arg_ty 2195 arg_ty
2198 arg(identifier arg, expr_ty annotation, PyArena *arena) 2196 arg(identifier arg, expr_ty annotation, PyArena *arena)
2199 { 2197 {
2200 arg_ty p; 2198 arg_ty p;
2201 if (!arg) { 2199 if (!arg) {
2202 PyErr_SetString(PyExc_ValueError, 2200 PyErr_SetString(PyExc_ValueError,
2203 "field arg is required for arg"); 2201 "field arg is required for arg");
2204 return NULL; 2202 return NULL;
2205 } 2203 }
2206 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); 2204 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
2207 if (!p) 2205 if (!p)
2208 return NULL; 2206 return NULL;
2209 p->arg = arg; 2207 p->arg = arg;
2210 p->annotation = annotation; 2208 p->annotation = annotation;
2211 return p; 2209 return p;
2212 } 2210 }
2213 2211
2214 keyword_ty 2212 keyword_ty
2215 keyword(identifier arg, expr_ty value, PyArena *arena) 2213 keyword(identifier arg, expr_ty value, PyArena *arena)
2216 { 2214 {
2217 keyword_ty p; 2215 keyword_ty p;
2218 if (!arg) { 2216 if (!arg) {
2219 PyErr_SetString(PyExc_ValueError, 2217 PyErr_SetString(PyExc_ValueError,
2220 "field arg is required for keyword"); 2218 "field arg is required for keyword");
2221 return NULL; 2219 return NULL;
2222 } 2220 }
2223 if (!value) { 2221 if (!value) {
2224 PyErr_SetString(PyExc_ValueError, 2222 PyErr_SetString(PyExc_ValueError,
2225 "field value is required for keyword"); 2223 "field value is required for keyword");
2226 return NULL; 2224 return NULL;
2227 } 2225 }
2228 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); 2226 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
2229 if (!p) 2227 if (!p)
2230 return NULL; 2228 return NULL;
2231 p->arg = arg; 2229 p->arg = arg;
2232 p->value = value; 2230 p->value = value;
2233 return p; 2231 return p;
2234 } 2232 }
2235 2233
2236 alias_ty 2234 alias_ty
2237 alias(identifier name, identifier asname, PyArena *arena) 2235 alias(identifier name, identifier asname, PyArena *arena)
2238 { 2236 {
2239 alias_ty p; 2237 alias_ty p;
2240 if (!name) { 2238 if (!name) {
2241 PyErr_SetString(PyExc_ValueError, 2239 PyErr_SetString(PyExc_ValueError,
2242 "field name is required for alias"); 2240 "field name is required for alias");
2243 return NULL; 2241 return NULL;
2244 } 2242 }
2245 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); 2243 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
2246 if (!p) 2244 if (!p)
2247 return NULL; 2245 return NULL;
2248 p->name = name; 2246 p->name = name;
2249 p->asname = asname; 2247 p->asname = asname;
2250 return p; 2248 return p;
2251 } 2249 }
2252 2250
2253 withitem_ty 2251 withitem_ty
2254 withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena) 2252 withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
2255 { 2253 {
2256 withitem_ty p; 2254 withitem_ty p;
2257 if (!context_expr) { 2255 if (!context_expr) {
2258 PyErr_SetString(PyExc_ValueError, 2256 PyErr_SetString(PyExc_ValueError,
2259 "field context_expr is required for withitem"); 2257 "field context_expr is required for withitem");
2260 return NULL; 2258 return NULL;
2261 } 2259 }
2262 p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p)); 2260 p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p));
2263 if (!p) 2261 if (!p)
2264 return NULL; 2262 return NULL;
2265 p->context_expr = context_expr; 2263 p->context_expr = context_expr;
2266 p->optional_vars = optional_vars; 2264 p->optional_vars = optional_vars;
2267 return p; 2265 return p;
2268 } 2266 }
2269 2267
2270 2268
2271 PyObject* 2269 PyObject*
2272 ast2obj_mod(void* _o) 2270 ast2obj_mod(void* _o)
2273 { 2271 {
2274 mod_ty o = (mod_ty)_o; 2272 mod_ty o = (mod_ty)_o;
2275 PyObject *result = NULL, *value = NULL; 2273 PyObject *result = NULL, *value = NULL;
2276 if (!o) { 2274 if (!o) {
2277 Py_INCREF(Py_None); 2275 Py_INCREF(Py_None);
2278 return Py_None; 2276 return Py_None;
2279 } 2277 }
2280 2278
2281 switch (o->kind) { 2279 switch (o->kind) {
2282 case Module_kind: 2280 case Module_kind:
2283 result = PyType_GenericNew(Module_type, NULL, NULL); 2281 result = PyType_GenericNew(Module_type, NULL, NULL);
2284 if (!result) goto failed; 2282 if (!result) goto failed;
2285 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); 2283 value = ast2obj_list(o->v.Module.body, ast2obj_stmt);
2286 if (!value) goto failed; 2284 if (!value) goto failed;
2287 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2285 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2288 goto failed; 2286 goto failed;
2289 Py_DECREF(value); 2287 Py_DECREF(value);
2290 break; 2288 break;
2291 case Interactive_kind: 2289 case Interactive_kind:
2292 result = PyType_GenericNew(Interactive_type, NULL, NULL); 2290 result = PyType_GenericNew(Interactive_type, NULL, NULL);
2293 if (!result) goto failed; 2291 if (!result) goto failed;
2294 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); 2292 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt);
2295 if (!value) goto failed; 2293 if (!value) goto failed;
2296 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2294 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2297 goto failed; 2295 goto failed;
2298 Py_DECREF(value); 2296 Py_DECREF(value);
2299 break; 2297 break;
2300 case Expression_kind: 2298 case Expression_kind:
2301 result = PyType_GenericNew(Expression_type, NULL, NULL); 2299 result = PyType_GenericNew(Expression_type, NULL, NULL);
2302 if (!result) goto failed; 2300 if (!result) goto failed;
2303 value = ast2obj_expr(o->v.Expression.body); 2301 value = ast2obj_expr(o->v.Expression.body);
2304 if (!value) goto failed; 2302 if (!value) goto failed;
2305 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2303 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2306 goto failed; 2304 goto failed;
2307 Py_DECREF(value); 2305 Py_DECREF(value);
2308 break; 2306 break;
2309 case Suite_kind: 2307 case Suite_kind:
2310 result = PyType_GenericNew(Suite_type, NULL, NULL); 2308 result = PyType_GenericNew(Suite_type, NULL, NULL);
2311 if (!result) goto failed; 2309 if (!result) goto failed;
2312 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); 2310 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt);
2313 if (!value) goto failed; 2311 if (!value) goto failed;
2314 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2312 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2315 goto failed; 2313 goto failed;
2316 Py_DECREF(value); 2314 Py_DECREF(value);
2317 break; 2315 break;
2318 } 2316 }
2319 return result; 2317 return result;
2320 failed: 2318 failed:
2321 Py_XDECREF(value); 2319 Py_XDECREF(value);
2322 Py_XDECREF(result); 2320 Py_XDECREF(result);
2323 return NULL; 2321 return NULL;
2324 } 2322 }
2325 2323
2326 PyObject* 2324 PyObject*
2327 ast2obj_stmt(void* _o) 2325 ast2obj_stmt(void* _o)
2328 { 2326 {
2329 stmt_ty o = (stmt_ty)_o; 2327 stmt_ty o = (stmt_ty)_o;
2330 PyObject *result = NULL, *value = NULL; 2328 PyObject *result = NULL, *value = NULL;
2331 if (!o) { 2329 if (!o) {
2332 Py_INCREF(Py_None); 2330 Py_INCREF(Py_None);
2333 return Py_None; 2331 return Py_None;
2334 } 2332 }
2335 2333
2336 switch (o->kind) { 2334 switch (o->kind) {
2337 case FunctionDef_kind: 2335 case FunctionDef_kind:
2338 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); 2336 result = PyType_GenericNew(FunctionDef_type, NULL, NULL);
2339 if (!result) goto failed; 2337 if (!result) goto failed;
2340 value = ast2obj_identifier(o->v.FunctionDef.name); 2338 value = ast2obj_identifier(o->v.FunctionDef.name);
2341 if (!value) goto failed; 2339 if (!value) goto failed;
2342 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) 2340 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
2343 goto failed; 2341 goto failed;
2344 Py_DECREF(value); 2342 Py_DECREF(value);
2345 value = ast2obj_arguments(o->v.FunctionDef.args); 2343 value = ast2obj_arguments(o->v.FunctionDef.args);
2346 if (!value) goto failed; 2344 if (!value) goto failed;
2347 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) 2345 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
2348 goto failed; 2346 goto failed;
2349 Py_DECREF(value); 2347 Py_DECREF(value);
2350 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); 2348 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt);
2351 if (!value) goto failed; 2349 if (!value) goto failed;
2352 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2350 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2353 goto failed; 2351 goto failed;
2354 Py_DECREF(value); 2352 Py_DECREF(value);
2355 value = ast2obj_list(o->v.FunctionDef.decorator_list, 2353 value = ast2obj_list(o->v.FunctionDef.decorator_list, ast2obj_expr);
2356 ast2obj_expr); 2354 if (!value) goto failed;
2357 if (!value) goto failed; 2355 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1)
2358 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == 2356 goto failed;
2359 -1) 2357 Py_DECREF(value);
2360 goto failed; 2358 value = ast2obj_expr(o->v.FunctionDef.returns);
2361 Py_DECREF(value); 2359 if (!value) goto failed;
2362 value = ast2obj_expr(o->v.FunctionDef.returns); 2360 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1)
2363 if (!value) goto failed; 2361 goto failed;
2364 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1) 2362 Py_DECREF(value);
2365 goto failed; 2363 break;
2366 Py_DECREF(value); 2364 case ClassDef_kind:
2367 break; 2365 result = PyType_GenericNew(ClassDef_type, NULL, NULL);
2368 case ClassDef_kind: 2366 if (!result) goto failed;
2369 result = PyType_GenericNew(ClassDef_type, NULL, NULL); 2367 value = ast2obj_identifier(o->v.ClassDef.name);
2370 if (!result) goto failed; 2368 if (!value) goto failed;
2371 value = ast2obj_identifier(o->v.ClassDef.name); 2369 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
2372 if (!value) goto failed; 2370 goto failed;
2373 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) 2371 Py_DECREF(value);
2374 goto failed; 2372 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr);
2375 Py_DECREF(value); 2373 if (!value) goto failed;
2376 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); 2374 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1)
2377 if (!value) goto failed; 2375 goto failed;
2378 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1) 2376 Py_DECREF(value);
2379 goto failed; 2377 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword);
2380 Py_DECREF(value); 2378 if (!value) goto failed;
2381 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword); 2379 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
2382 if (!value) goto failed; 2380 goto failed;
2383 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) 2381 Py_DECREF(value);
2384 goto failed; 2382 value = ast2obj_expr(o->v.ClassDef.starargs);
2385 Py_DECREF(value); 2383 if (!value) goto failed;
2386 value = ast2obj_expr(o->v.ClassDef.starargs); 2384 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
2387 if (!value) goto failed; 2385 goto failed;
2388 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) 2386 Py_DECREF(value);
2389 goto failed; 2387 value = ast2obj_expr(o->v.ClassDef.kwargs);
2390 Py_DECREF(value); 2388 if (!value) goto failed;
2391 value = ast2obj_expr(o->v.ClassDef.kwargs); 2389 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
2392 if (!value) goto failed; 2390 goto failed;
2393 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) 2391 Py_DECREF(value);
2394 goto failed; 2392 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt);
2395 Py_DECREF(value); 2393 if (!value) goto failed;
2396 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); 2394 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2397 if (!value) goto failed; 2395 goto failed;
2398 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2396 Py_DECREF(value);
2399 goto failed; 2397 value = ast2obj_list(o->v.ClassDef.decorator_list, ast2obj_expr);
2400 Py_DECREF(value); 2398 if (!value) goto failed;
2401 value = ast2obj_list(o->v.ClassDef.decorator_list, 2399 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1)
2402 ast2obj_expr); 2400 goto failed;
2403 if (!value) goto failed; 2401 Py_DECREF(value);
2404 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == 2402 break;
2405 -1) 2403 case Return_kind:
2406 goto failed; 2404 result = PyType_GenericNew(Return_type, NULL, NULL);
2407 Py_DECREF(value); 2405 if (!result) goto failed;
2408 break; 2406 value = ast2obj_expr(o->v.Return.value);
2409 case Return_kind: 2407 if (!value) goto failed;
2410 result = PyType_GenericNew(Return_type, NULL, NULL); 2408 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2411 if (!result) goto failed; 2409 goto failed;
2412 value = ast2obj_expr(o->v.Return.value); 2410 Py_DECREF(value);
2413 if (!value) goto failed; 2411 break;
2414 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2412 case Delete_kind:
2415 goto failed; 2413 result = PyType_GenericNew(Delete_type, NULL, NULL);
2416 Py_DECREF(value); 2414 if (!result) goto failed;
2417 break; 2415 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr);
2418 case Delete_kind: 2416 if (!value) goto failed;
2419 result = PyType_GenericNew(Delete_type, NULL, NULL); 2417 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
2420 if (!result) goto failed; 2418 goto failed;
2421 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); 2419 Py_DECREF(value);
2422 if (!value) goto failed; 2420 break;
2423 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) 2421 case Assign_kind:
2424 goto failed; 2422 result = PyType_GenericNew(Assign_type, NULL, NULL);
2425 Py_DECREF(value); 2423 if (!result) goto failed;
2426 break; 2424 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr);
2427 case Assign_kind: 2425 if (!value) goto failed;
2428 result = PyType_GenericNew(Assign_type, NULL, NULL); 2426 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
2429 if (!result) goto failed; 2427 goto failed;
2430 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); 2428 Py_DECREF(value);
2431 if (!value) goto failed; 2429 value = ast2obj_expr(o->v.Assign.value);
2432 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) 2430 if (!value) goto failed;
2433 goto failed; 2431 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2434 Py_DECREF(value); 2432 goto failed;
2435 value = ast2obj_expr(o->v.Assign.value); 2433 Py_DECREF(value);
2436 if (!value) goto failed; 2434 break;
2437 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2435 case AugAssign_kind:
2438 goto failed; 2436 result = PyType_GenericNew(AugAssign_type, NULL, NULL);
2439 Py_DECREF(value); 2437 if (!result) goto failed;
2440 break; 2438 value = ast2obj_expr(o->v.AugAssign.target);
2441 case AugAssign_kind: 2439 if (!value) goto failed;
2442 result = PyType_GenericNew(AugAssign_type, NULL, NULL); 2440 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
2443 if (!result) goto failed; 2441 goto failed;
2444 value = ast2obj_expr(o->v.AugAssign.target); 2442 Py_DECREF(value);
2445 if (!value) goto failed; 2443 value = ast2obj_operator(o->v.AugAssign.op);
2446 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) 2444 if (!value) goto failed;
2447 goto failed; 2445 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2448 Py_DECREF(value); 2446 goto failed;
2449 value = ast2obj_operator(o->v.AugAssign.op); 2447 Py_DECREF(value);
2450 if (!value) goto failed; 2448 value = ast2obj_expr(o->v.AugAssign.value);
2451 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) 2449 if (!value) goto failed;
2452 goto failed; 2450 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2453 Py_DECREF(value); 2451 goto failed;
2454 value = ast2obj_expr(o->v.AugAssign.value); 2452 Py_DECREF(value);
2455 if (!value) goto failed; 2453 break;
2456 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2454 case For_kind:
2457 goto failed; 2455 result = PyType_GenericNew(For_type, NULL, NULL);
2458 Py_DECREF(value); 2456 if (!result) goto failed;
2459 break; 2457 value = ast2obj_expr(o->v.For.target);
2460 case For_kind: 2458 if (!value) goto failed;
2461 result = PyType_GenericNew(For_type, NULL, NULL); 2459 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
2462 if (!result) goto failed; 2460 goto failed;
2463 value = ast2obj_expr(o->v.For.target); 2461 Py_DECREF(value);
2464 if (!value) goto failed; 2462 value = ast2obj_expr(o->v.For.iter);
2465 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) 2463 if (!value) goto failed;
2466 goto failed; 2464 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
2467 Py_DECREF(value); 2465 goto failed;
2468 value = ast2obj_expr(o->v.For.iter); 2466 Py_DECREF(value);
2469 if (!value) goto failed; 2467 value = ast2obj_list(o->v.For.body, ast2obj_stmt);
2470 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) 2468 if (!value) goto failed;
2471 goto failed; 2469 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2472 Py_DECREF(value); 2470 goto failed;
2473 value = ast2obj_list(o->v.For.body, ast2obj_stmt); 2471 Py_DECREF(value);
2474 if (!value) goto failed; 2472 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt);
2475 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2473 if (!value) goto failed;
2476 goto failed; 2474 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2477 Py_DECREF(value); 2475 goto failed;
2478 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); 2476 Py_DECREF(value);
2479 if (!value) goto failed; 2477 break;
2480 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) 2478 case While_kind:
2481 goto failed; 2479 result = PyType_GenericNew(While_type, NULL, NULL);
2482 Py_DECREF(value); 2480 if (!result) goto failed;
2483 break; 2481 value = ast2obj_expr(o->v.While.test);
2484 case While_kind: 2482 if (!value) goto failed;
2485 result = PyType_GenericNew(While_type, NULL, NULL); 2483 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2486 if (!result) goto failed; 2484 goto failed;
2487 value = ast2obj_expr(o->v.While.test); 2485 Py_DECREF(value);
2488 if (!value) goto failed; 2486 value = ast2obj_list(o->v.While.body, ast2obj_stmt);
2489 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) 2487 if (!value) goto failed;
2490 goto failed; 2488 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2491 Py_DECREF(value); 2489 goto failed;
2492 value = ast2obj_list(o->v.While.body, ast2obj_stmt); 2490 Py_DECREF(value);
2493 if (!value) goto failed; 2491 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt);
2494 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2492 if (!value) goto failed;
2495 goto failed; 2493 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2496 Py_DECREF(value); 2494 goto failed;
2497 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); 2495 Py_DECREF(value);
2498 if (!value) goto failed; 2496 break;
2499 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) 2497 case If_kind:
2500 goto failed; 2498 result = PyType_GenericNew(If_type, NULL, NULL);
2501 Py_DECREF(value); 2499 if (!result) goto failed;
2502 break; 2500 value = ast2obj_expr(o->v.If.test);
2503 case If_kind: 2501 if (!value) goto failed;
2504 result = PyType_GenericNew(If_type, NULL, NULL); 2502 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2505 if (!result) goto failed; 2503 goto failed;
2506 value = ast2obj_expr(o->v.If.test); 2504 Py_DECREF(value);
2507 if (!value) goto failed; 2505 value = ast2obj_list(o->v.If.body, ast2obj_stmt);
2508 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) 2506 if (!value) goto failed;
2509 goto failed; 2507 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2510 Py_DECREF(value); 2508 goto failed;
2511 value = ast2obj_list(o->v.If.body, ast2obj_stmt); 2509 Py_DECREF(value);
2512 if (!value) goto failed; 2510 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt);
2513 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2511 if (!value) goto failed;
2514 goto failed; 2512 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2515 Py_DECREF(value); 2513 goto failed;
2516 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); 2514 Py_DECREF(value);
2517 if (!value) goto failed; 2515 break;
2518 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) 2516 case With_kind:
2519 goto failed; 2517 result = PyType_GenericNew(With_type, NULL, NULL);
2520 Py_DECREF(value); 2518 if (!result) goto failed;
2521 break; 2519 value = ast2obj_list(o->v.With.items, ast2obj_withitem);
2522 case With_kind: 2520 if (!value) goto failed;
2523 result = PyType_GenericNew(With_type, NULL, NULL); 2521 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1)
2524 if (!result) goto failed; 2522 goto failed;
2525 value = ast2obj_list(o->v.With.items, ast2obj_withitem); 2523 Py_DECREF(value);
2526 if (!value) goto failed; 2524 value = ast2obj_list(o->v.With.body, ast2obj_stmt);
2527 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1) 2525 if (!value) goto failed;
2528 goto failed; 2526 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2529 Py_DECREF(value); 2527 goto failed;
2530 value = ast2obj_list(o->v.With.body, ast2obj_stmt); 2528 Py_DECREF(value);
2531 if (!value) goto failed; 2529 break;
2532 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2530 case Raise_kind:
2533 goto failed; 2531 result = PyType_GenericNew(Raise_type, NULL, NULL);
2534 Py_DECREF(value); 2532 if (!result) goto failed;
2535 break; 2533 value = ast2obj_expr(o->v.Raise.exc);
2536 case Raise_kind: 2534 if (!value) goto failed;
2537 result = PyType_GenericNew(Raise_type, NULL, NULL); 2535 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1)
2538 if (!result) goto failed; 2536 goto failed;
2539 value = ast2obj_expr(o->v.Raise.exc); 2537 Py_DECREF(value);
2540 if (!value) goto failed; 2538 value = ast2obj_expr(o->v.Raise.cause);
2541 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1) 2539 if (!value) goto failed;
2542 goto failed; 2540 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1)
2543 Py_DECREF(value); 2541 goto failed;
2544 value = ast2obj_expr(o->v.Raise.cause); 2542 Py_DECREF(value);
2545 if (!value) goto failed; 2543 break;
2546 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1) 2544 case Try_kind:
2547 goto failed; 2545 result = PyType_GenericNew(Try_type, NULL, NULL);
2548 Py_DECREF(value); 2546 if (!result) goto failed;
2549 break; 2547 value = ast2obj_list(o->v.Try.body, ast2obj_stmt);
2550 case Try_kind: 2548 if (!value) goto failed;
2551 result = PyType_GenericNew(Try_type, NULL, NULL); 2549 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2552 if (!result) goto failed; 2550 goto failed;
2553 value = ast2obj_list(o->v.Try.body, ast2obj_stmt); 2551 Py_DECREF(value);
2554 if (!value) goto failed; 2552 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler);
2555 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2553 if (!value) goto failed;
2556 goto failed; 2554 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1)
2557 Py_DECREF(value); 2555 goto failed;
2558 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler); 2556 Py_DECREF(value);
2559 if (!value) goto failed; 2557 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt);
2560 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1) 2558 if (!value) goto failed;
2561 goto failed; 2559 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2562 Py_DECREF(value); 2560 goto failed;
2563 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt); 2561 Py_DECREF(value);
2564 if (!value) goto failed; 2562 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt);
2565 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) 2563 if (!value) goto failed;
2566 goto failed; 2564 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1)
2567 Py_DECREF(value); 2565 goto failed;
2568 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt); 2566 Py_DECREF(value);
2569 if (!value) goto failed; 2567 break;
2570 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1) 2568 case Assert_kind:
2571 goto failed; 2569 result = PyType_GenericNew(Assert_type, NULL, NULL);
2572 Py_DECREF(value); 2570 if (!result) goto failed;
2573 break; 2571 value = ast2obj_expr(o->v.Assert.test);
2574 case Assert_kind: 2572 if (!value) goto failed;
2575 result = PyType_GenericNew(Assert_type, NULL, NULL); 2573 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2576 if (!result) goto failed; 2574 goto failed;
2577 value = ast2obj_expr(o->v.Assert.test); 2575 Py_DECREF(value);
2578 if (!value) goto failed; 2576 value = ast2obj_expr(o->v.Assert.msg);
2579 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) 2577 if (!value) goto failed;
2580 goto failed; 2578 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1)
2581 Py_DECREF(value); 2579 goto failed;
2582 value = ast2obj_expr(o->v.Assert.msg); 2580 Py_DECREF(value);
2583 if (!value) goto failed; 2581 break;
2584 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1) 2582 case Import_kind:
2585 goto failed; 2583 result = PyType_GenericNew(Import_type, NULL, NULL);
2586 Py_DECREF(value); 2584 if (!result) goto failed;
2587 break; 2585 value = ast2obj_list(o->v.Import.names, ast2obj_alias);
2588 case Import_kind: 2586 if (!value) goto failed;
2589 result = PyType_GenericNew(Import_type, NULL, NULL); 2587 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2590 if (!result) goto failed; 2588 goto failed;
2591 value = ast2obj_list(o->v.Import.names, ast2obj_alias); 2589 Py_DECREF(value);
2592 if (!value) goto failed; 2590 break;
2593 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) 2591 case ImportFrom_kind:
2594 goto failed; 2592 result = PyType_GenericNew(ImportFrom_type, NULL, NULL);
2595 Py_DECREF(value); 2593 if (!result) goto failed;
2596 break; 2594 value = ast2obj_identifier(o->v.ImportFrom.module);
2597 case ImportFrom_kind: 2595 if (!value) goto failed;
2598 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); 2596 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1)
2599 if (!result) goto failed; 2597 goto failed;
2600 value = ast2obj_identifier(o->v.ImportFrom.module); 2598 Py_DECREF(value);
2601 if (!value) goto failed; 2599 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias);
2602 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1) 2600 if (!value) goto failed;
2603 goto failed; 2601 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2604 Py_DECREF(value); 2602 goto failed;
2605 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); 2603 Py_DECREF(value);
2606 if (!value) goto failed; 2604 value = ast2obj_int(o->v.ImportFrom.level);
2607 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) 2605 if (!value) goto failed;
2608 goto failed; 2606 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1)
2609 Py_DECREF(value); 2607 goto failed;
2610 value = ast2obj_int(o->v.ImportFrom.level); 2608 Py_DECREF(value);
2611 if (!value) goto failed; 2609 break;
2612 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1) 2610 case Global_kind:
2613 goto failed; 2611 result = PyType_GenericNew(Global_type, NULL, NULL);
2614 Py_DECREF(value); 2612 if (!result) goto failed;
2615 break; 2613 value = ast2obj_list(o->v.Global.names, ast2obj_identifier);
2616 case Global_kind: 2614 if (!value) goto failed;
2617 result = PyType_GenericNew(Global_type, NULL, NULL); 2615 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2618 if (!result) goto failed; 2616 goto failed;
2619 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); 2617 Py_DECREF(value);
2620 if (!value) goto failed; 2618 break;
2621 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) 2619 case Nonlocal_kind:
2622 goto failed; 2620 result = PyType_GenericNew(Nonlocal_type, NULL, NULL);
2623 Py_DECREF(value); 2621 if (!result) goto failed;
2624 break; 2622 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier);
2625 case Nonlocal_kind: 2623 if (!value) goto failed;
2626 result = PyType_GenericNew(Nonlocal_type, NULL, NULL); 2624 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
2627 if (!result) goto failed; 2625 goto failed;
2628 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier); 2626 Py_DECREF(value);
2629 if (!value) goto failed; 2627 break;
2630 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) 2628 case Expr_kind:
2631 goto failed; 2629 result = PyType_GenericNew(Expr_type, NULL, NULL);
2632 Py_DECREF(value); 2630 if (!result) goto failed;
2633 break; 2631 value = ast2obj_expr(o->v.Expr.value);
2634 case Expr_kind: 2632 if (!value) goto failed;
2635 result = PyType_GenericNew(Expr_type, NULL, NULL); 2633 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2636 if (!result) goto failed; 2634 goto failed;
2637 value = ast2obj_expr(o->v.Expr.value); 2635 Py_DECREF(value);
2638 if (!value) goto failed; 2636 break;
2639 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2637 case Pass_kind:
2640 goto failed; 2638 result = PyType_GenericNew(Pass_type, NULL, NULL);
2641 Py_DECREF(value); 2639 if (!result) goto failed;
2642 break; 2640 break;
2643 case Pass_kind: 2641 case Break_kind:
2644 result = PyType_GenericNew(Pass_type, NULL, NULL); 2642 result = PyType_GenericNew(Break_type, NULL, NULL);
2645 if (!result) goto failed; 2643 if (!result) goto failed;
2646 break; 2644 break;
2647 case Break_kind: 2645 case Continue_kind:
2648 result = PyType_GenericNew(Break_type, NULL, NULL); 2646 result = PyType_GenericNew(Continue_type, NULL, NULL);
2649 if (!result) goto failed; 2647 if (!result) goto failed;
2650 break; 2648 break;
2651 case Continue_kind: 2649 }
2652 result = PyType_GenericNew(Continue_type, NULL, NULL); 2650 value = ast2obj_int(o->lineno);
2653 if (!result) goto failed; 2651 if (!value) goto failed;
2654 break; 2652 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
2655 } 2653 goto failed;
2656 value = ast2obj_int(o->lineno); 2654 Py_DECREF(value);
2657 if (!value) goto failed; 2655 value = ast2obj_int(o->col_offset);
2658 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) 2656 if (!value) goto failed;
2659 goto failed; 2657 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
2660 Py_DECREF(value); 2658 goto failed;
2661 value = ast2obj_int(o->col_offset); 2659 Py_DECREF(value);
2662 if (!value) goto failed; 2660 return result;
2663 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
2664 goto failed;
2665 Py_DECREF(value);
2666 return result;
2667 failed: 2661 failed:
2668 Py_XDECREF(value); 2662 Py_XDECREF(value);
2669 Py_XDECREF(result); 2663 Py_XDECREF(result);
2670 return NULL; 2664 return NULL;
2671 } 2665 }
2672 2666
2673 PyObject* 2667 PyObject*
2674 ast2obj_expr(void* _o) 2668 ast2obj_expr(void* _o)
2675 { 2669 {
2676 expr_ty o = (expr_ty)_o; 2670 expr_ty o = (expr_ty)_o;
2677 PyObject *result = NULL, *value = NULL; 2671 PyObject *result = NULL, *value = NULL;
2678 if (!o) { 2672 if (!o) {
2679 Py_INCREF(Py_None); 2673 Py_INCREF(Py_None);
2680 return Py_None; 2674 return Py_None;
2681 } 2675 }
2682 2676
2683 switch (o->kind) { 2677 switch (o->kind) {
2684 case BoolOp_kind: 2678 case BoolOp_kind:
2685 result = PyType_GenericNew(BoolOp_type, NULL, NULL); 2679 result = PyType_GenericNew(BoolOp_type, NULL, NULL);
2686 if (!result) goto failed; 2680 if (!result) goto failed;
2687 value = ast2obj_boolop(o->v.BoolOp.op); 2681 value = ast2obj_boolop(o->v.BoolOp.op);
2688 if (!value) goto failed; 2682 if (!value) goto failed;
2689 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) 2683 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2690 goto failed; 2684 goto failed;
2691 Py_DECREF(value); 2685 Py_DECREF(value);
2692 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); 2686 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr);
2693 if (!value) goto failed; 2687 if (!value) goto failed;
2694 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) 2688 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
2695 goto failed; 2689 goto failed;
2696 Py_DECREF(value); 2690 Py_DECREF(value);
2697 break; 2691 break;
2698 case BinOp_kind: 2692 case BinOp_kind:
2699 result = PyType_GenericNew(BinOp_type, NULL, NULL); 2693 result = PyType_GenericNew(BinOp_type, NULL, NULL);
2700 if (!result) goto failed; 2694 if (!result) goto failed;
2701 value = ast2obj_expr(o->v.BinOp.left); 2695 value = ast2obj_expr(o->v.BinOp.left);
2702 if (!value) goto failed; 2696 if (!value) goto failed;
2703 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) 2697 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
2704 goto failed; 2698 goto failed;
2705 Py_DECREF(value); 2699 Py_DECREF(value);
2706 value = ast2obj_operator(o->v.BinOp.op); 2700 value = ast2obj_operator(o->v.BinOp.op);
2707 if (!value) goto failed; 2701 if (!value) goto failed;
2708 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) 2702 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2709 goto failed; 2703 goto failed;
2710 Py_DECREF(value); 2704 Py_DECREF(value);
2711 value = ast2obj_expr(o->v.BinOp.right); 2705 value = ast2obj_expr(o->v.BinOp.right);
2712 if (!value) goto failed; 2706 if (!value) goto failed;
2713 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1) 2707 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1)
2714 goto failed; 2708 goto failed;
2715 Py_DECREF(value); 2709 Py_DECREF(value);
2716 break; 2710 break;
2717 case UnaryOp_kind: 2711 case UnaryOp_kind:
2718 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); 2712 result = PyType_GenericNew(UnaryOp_type, NULL, NULL);
2719 if (!result) goto failed; 2713 if (!result) goto failed;
2720 value = ast2obj_unaryop(o->v.UnaryOp.op); 2714 value = ast2obj_unaryop(o->v.UnaryOp.op);
2721 if (!value) goto failed; 2715 if (!value) goto failed;
2722 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) 2716 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
2723 goto failed; 2717 goto failed;
2724 Py_DECREF(value); 2718 Py_DECREF(value);
2725 value = ast2obj_expr(o->v.UnaryOp.operand); 2719 value = ast2obj_expr(o->v.UnaryOp.operand);
2726 if (!value) goto failed; 2720 if (!value) goto failed;
2727 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1) 2721 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1)
2728 goto failed; 2722 goto failed;
2729 Py_DECREF(value); 2723 Py_DECREF(value);
2730 break; 2724 break;
2731 case Lambda_kind: 2725 case Lambda_kind:
2732 result = PyType_GenericNew(Lambda_type, NULL, NULL); 2726 result = PyType_GenericNew(Lambda_type, NULL, NULL);
2733 if (!result) goto failed; 2727 if (!result) goto failed;
2734 value = ast2obj_arguments(o->v.Lambda.args); 2728 value = ast2obj_arguments(o->v.Lambda.args);
2735 if (!value) goto failed; 2729 if (!value) goto failed;
2736 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) 2730 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
2737 goto failed; 2731 goto failed;
2738 Py_DECREF(value); 2732 Py_DECREF(value);
2739 value = ast2obj_expr(o->v.Lambda.body); 2733 value = ast2obj_expr(o->v.Lambda.body);
2740 if (!value) goto failed; 2734 if (!value) goto failed;
2741 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2735 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2742 goto failed; 2736 goto failed;
2743 Py_DECREF(value); 2737 Py_DECREF(value);
2744 break; 2738 break;
2745 case IfExp_kind: 2739 case IfExp_kind:
2746 result = PyType_GenericNew(IfExp_type, NULL, NULL); 2740 result = PyType_GenericNew(IfExp_type, NULL, NULL);
2747 if (!result) goto failed; 2741 if (!result) goto failed;
2748 value = ast2obj_expr(o->v.IfExp.test); 2742 value = ast2obj_expr(o->v.IfExp.test);
2749 if (!value) goto failed; 2743 if (!value) goto failed;
2750 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) 2744 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
2751 goto failed; 2745 goto failed;
2752 Py_DECREF(value); 2746 Py_DECREF(value);
2753 value = ast2obj_expr(o->v.IfExp.body); 2747 value = ast2obj_expr(o->v.IfExp.body);
2754 if (!value) goto failed; 2748 if (!value) goto failed;
2755 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 2749 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
2756 goto failed; 2750 goto failed;
2757 Py_DECREF(value); 2751 Py_DECREF(value);
2758 value = ast2obj_expr(o->v.IfExp.orelse); 2752 value = ast2obj_expr(o->v.IfExp.orelse);
2759 if (!value) goto failed; 2753 if (!value) goto failed;
2760 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) 2754 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
2761 goto failed; 2755 goto failed;
2762 Py_DECREF(value); 2756 Py_DECREF(value);
2763 break; 2757 break;
2764 case Dict_kind: 2758 case Dict_kind:
2765 result = PyType_GenericNew(Dict_type, NULL, NULL); 2759 result = PyType_GenericNew(Dict_type, NULL, NULL);
2766 if (!result) goto failed; 2760 if (!result) goto failed;
2767 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); 2761 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr);
2768 if (!value) goto failed; 2762 if (!value) goto failed;
2769 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1) 2763 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1)
2770 goto failed; 2764 goto failed;
2771 Py_DECREF(value); 2765 Py_DECREF(value);
2772 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); 2766 value = ast2obj_list(o->v.Dict.values, ast2obj_expr);
2773 if (!value) goto failed; 2767 if (!value) goto failed;
2774 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) 2768 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
2775 goto failed; 2769 goto failed;
2776 Py_DECREF(value); 2770 Py_DECREF(value);
2777 break; 2771 break;
2778 case Set_kind: 2772 case Set_kind:
2779 result = PyType_GenericNew(Set_type, NULL, NULL); 2773 result = PyType_GenericNew(Set_type, NULL, NULL);
2780 if (!result) goto failed; 2774 if (!result) goto failed;
2781 value = ast2obj_list(o->v.Set.elts, ast2obj_expr); 2775 value = ast2obj_list(o->v.Set.elts, ast2obj_expr);
2782 if (!value) goto failed; 2776 if (!value) goto failed;
2783 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) 2777 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
2784 goto failed; 2778 goto failed;
2785 Py_DECREF(value); 2779 Py_DECREF(value);
2786 break; 2780 break;
2787 case ListComp_kind: 2781 case ListComp_kind:
2788 result = PyType_GenericNew(ListComp_type, NULL, NULL); 2782 result = PyType_GenericNew(ListComp_type, NULL, NULL);
2789 if (!result) goto failed; 2783 if (!result) goto failed;
2790 value = ast2obj_expr(o->v.ListComp.elt); 2784 value = ast2obj_expr(o->v.ListComp.elt);
2791 if (!value) goto failed; 2785 if (!value) goto failed;
2792 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) 2786 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
2793 goto failed; 2787 goto failed;
2794 Py_DECREF(value); 2788 Py_DECREF(value);
2795 value = ast2obj_list(o->v.ListComp.generators, 2789 value = ast2obj_list(o->v.ListComp.generators, ast2obj_comprehension);
2796 ast2obj_comprehension); 2790 if (!value) goto failed;
2797 if (!value) goto failed; 2791 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2798 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) 2792 goto failed;
2799 goto failed; 2793 Py_DECREF(value);
2800 Py_DECREF(value); 2794 break;
2801 break; 2795 case SetComp_kind:
2802 case SetComp_kind: 2796 result = PyType_GenericNew(SetComp_type, NULL, NULL);
2803 result = PyType_GenericNew(SetComp_type, NULL, NULL); 2797 if (!result) goto failed;
2804 if (!result) goto failed; 2798 value = ast2obj_expr(o->v.SetComp.elt);
2805 value = ast2obj_expr(o->v.SetComp.elt); 2799 if (!value) goto failed;
2806 if (!value) goto failed; 2800 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
2807 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) 2801 goto failed;
2808 goto failed; 2802 Py_DECREF(value);
2809 Py_DECREF(value); 2803 value = ast2obj_list(o->v.SetComp.generators, ast2obj_comprehension);
2810 value = ast2obj_list(o->v.SetComp.generators, 2804 if (!value) goto failed;
2811 ast2obj_comprehension); 2805 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2812 if (!value) goto failed; 2806 goto failed;
2813 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) 2807 Py_DECREF(value);
2814 goto failed; 2808 break;
2815 Py_DECREF(value); 2809 case DictComp_kind:
2816 break; 2810 result = PyType_GenericNew(DictComp_type, NULL, NULL);
2817 case DictComp_kind: 2811 if (!result) goto failed;
2818 result = PyType_GenericNew(DictComp_type, NULL, NULL); 2812 value = ast2obj_expr(o->v.DictComp.key);
2819 if (!result) goto failed; 2813 if (!value) goto failed;
2820 value = ast2obj_expr(o->v.DictComp.key); 2814 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1)
2821 if (!value) goto failed; 2815 goto failed;
2822 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1) 2816 Py_DECREF(value);
2823 goto failed; 2817 value = ast2obj_expr(o->v.DictComp.value);
2824 Py_DECREF(value); 2818 if (!value) goto failed;
2825 value = ast2obj_expr(o->v.DictComp.value); 2819 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2826 if (!value) goto failed; 2820 goto failed;
2827 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2821 Py_DECREF(value);
2828 goto failed; 2822 value = ast2obj_list(o->v.DictComp.generators, ast2obj_comprehension);
2829 Py_DECREF(value); 2823 if (!value) goto failed;
2830 value = ast2obj_list(o->v.DictComp.generators, 2824 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2831 ast2obj_comprehension); 2825 goto failed;
2832 if (!value) goto failed; 2826 Py_DECREF(value);
2833 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) 2827 break;
2834 goto failed; 2828 case GeneratorExp_kind:
2835 Py_DECREF(value); 2829 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL);
2836 break; 2830 if (!result) goto failed;
2837 case GeneratorExp_kind: 2831 value = ast2obj_expr(o->v.GeneratorExp.elt);
2838 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); 2832 if (!value) goto failed;
2839 if (!result) goto failed; 2833 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
2840 value = ast2obj_expr(o->v.GeneratorExp.elt); 2834 goto failed;
2841 if (!value) goto failed; 2835 Py_DECREF(value);
2842 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) 2836 value = ast2obj_list(o->v.GeneratorExp.generators,
2843 goto failed; 2837 ast2obj_comprehension);
2844 Py_DECREF(value); 2838 if (!value) goto failed;
2845 value = ast2obj_list(o->v.GeneratorExp.generators, 2839 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
2846 ast2obj_comprehension); 2840 goto failed;
2847 if (!value) goto failed; 2841 Py_DECREF(value);
2848 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) 2842 break;
2849 goto failed; 2843 case Yield_kind:
2850 Py_DECREF(value); 2844 result = PyType_GenericNew(Yield_type, NULL, NULL);
2851 break; 2845 if (!result) goto failed;
2852 case Yield_kind: 2846 value = ast2obj_expr(o->v.Yield.value);
2853 result = PyType_GenericNew(Yield_type, NULL, NULL); 2847 if (!value) goto failed;
2854 if (!result) goto failed; 2848 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2855 value = ast2obj_expr(o->v.Yield.value); 2849 goto failed;
2856 if (!value) goto failed; 2850 Py_DECREF(value);
2857 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2851 break;
2858 goto failed; 2852 case YieldFrom_kind:
2859 Py_DECREF(value); 2853 result = PyType_GenericNew(YieldFrom_type, NULL, NULL);
2860 break; 2854 if (!result) goto failed;
2861 case YieldFrom_kind: 2855 value = ast2obj_expr(o->v.YieldFrom.value);
2862 result = PyType_GenericNew(YieldFrom_type, NULL, NULL); 2856 if (!value) goto failed;
2863 if (!result) goto failed; 2857 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2864 value = ast2obj_expr(o->v.YieldFrom.value); 2858 goto failed;
2865 if (!value) goto failed; 2859 Py_DECREF(value);
2866 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2860 break;
2867 goto failed; 2861 case Compare_kind:
2868 Py_DECREF(value); 2862 result = PyType_GenericNew(Compare_type, NULL, NULL);
2869 break; 2863 if (!result) goto failed;
2870 case Compare_kind: 2864 value = ast2obj_expr(o->v.Compare.left);
2871 result = PyType_GenericNew(Compare_type, NULL, NULL); 2865 if (!value) goto failed;
2872 if (!result) goto failed; 2866 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
2873 value = ast2obj_expr(o->v.Compare.left); 2867 goto failed;
2874 if (!value) goto failed; 2868 Py_DECREF(value);
2875 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) 2869 {
2876 goto failed; 2870 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
2877 Py_DECREF(value); 2871 value = PyList_New(n);
2878 { 2872 if (!value) goto failed;
2879 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops); 2873 for(i = 0; i < n; i++)
2880 value = PyList_New(n); 2874 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
2881 if (!value) goto failed; 2875 }
2882 for(i = 0; i < n; i++) 2876 if (!value) goto failed;
2883 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i))); 2877 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1)
2884 } 2878 goto failed;
2885 if (!value) goto failed; 2879 Py_DECREF(value);
2886 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1) 2880 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr);
2887 goto failed; 2881 if (!value) goto failed;
2888 Py_DECREF(value); 2882 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1)
2889 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); 2883 goto failed;
2890 if (!value) goto failed; 2884 Py_DECREF(value);
2891 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1) 2885 break;
2892 goto failed; 2886 case Call_kind:
2893 Py_DECREF(value); 2887 result = PyType_GenericNew(Call_type, NULL, NULL);
2894 break; 2888 if (!result) goto failed;
2895 case Call_kind: 2889 value = ast2obj_expr(o->v.Call.func);
2896 result = PyType_GenericNew(Call_type, NULL, NULL); 2890 if (!value) goto failed;
2897 if (!result) goto failed; 2891 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1)
2898 value = ast2obj_expr(o->v.Call.func); 2892 goto failed;
2899 if (!value) goto failed; 2893 Py_DECREF(value);
2900 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1) 2894 value = ast2obj_list(o->v.Call.args, ast2obj_expr);
2901 goto failed; 2895 if (!value) goto failed;
2902 Py_DECREF(value); 2896 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
2903 value = ast2obj_list(o->v.Call.args, ast2obj_expr); 2897 goto failed;
2904 if (!value) goto failed; 2898 Py_DECREF(value);
2905 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) 2899 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword);
2906 goto failed; 2900 if (!value) goto failed;
2907 Py_DECREF(value); 2901 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
2908 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); 2902 goto failed;
2909 if (!value) goto failed; 2903 Py_DECREF(value);
2910 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) 2904 value = ast2obj_expr(o->v.Call.starargs);
2911 goto failed; 2905 if (!value) goto failed;
2912 Py_DECREF(value); 2906 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
2913 value = ast2obj_expr(o->v.Call.starargs); 2907 goto failed;
2914 if (!value) goto failed; 2908 Py_DECREF(value);
2915 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) 2909 value = ast2obj_expr(o->v.Call.kwargs);
2916 goto failed; 2910 if (!value) goto failed;
2917 Py_DECREF(value); 2911 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
2918 value = ast2obj_expr(o->v.Call.kwargs); 2912 goto failed;
2919 if (!value) goto failed; 2913 Py_DECREF(value);
2920 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) 2914 break;
2921 goto failed; 2915 case Num_kind:
2922 Py_DECREF(value); 2916 result = PyType_GenericNew(Num_type, NULL, NULL);
2923 break; 2917 if (!result) goto failed;
2924 case Num_kind: 2918 value = ast2obj_object(o->v.Num.n);
2925 result = PyType_GenericNew(Num_type, NULL, NULL); 2919 if (!value) goto failed;
2926 if (!result) goto failed; 2920 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1)
2927 value = ast2obj_object(o->v.Num.n); 2921 goto failed;
2928 if (!value) goto failed; 2922 Py_DECREF(value);
2929 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1) 2923 break;
2930 goto failed; 2924 case Str_kind:
2931 Py_DECREF(value); 2925 result = PyType_GenericNew(Str_type, NULL, NULL);
2932 break; 2926 if (!result) goto failed;
2933 case Str_kind: 2927 value = ast2obj_string(o->v.Str.s);
2934 result = PyType_GenericNew(Str_type, NULL, NULL); 2928 if (!value) goto failed;
2935 if (!result) goto failed; 2929 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
2936 value = ast2obj_string(o->v.Str.s); 2930 goto failed;
2937 if (!value) goto failed; 2931 Py_DECREF(value);
2938 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) 2932 break;
2939 goto failed; 2933 case Bytes_kind:
2940 Py_DECREF(value); 2934 result = PyType_GenericNew(Bytes_type, NULL, NULL);
2941 break; 2935 if (!result) goto failed;
2942 case Bytes_kind: 2936 value = ast2obj_bytes(o->v.Bytes.s);
2943 result = PyType_GenericNew(Bytes_type, NULL, NULL); 2937 if (!value) goto failed;
2944 if (!result) goto failed; 2938 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
2945 value = ast2obj_bytes(o->v.Bytes.s); 2939 goto failed;
2946 if (!value) goto failed; 2940 Py_DECREF(value);
2947 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) 2941 break;
2948 goto failed; 2942 case Ellipsis_kind:
2949 Py_DECREF(value); 2943 result = PyType_GenericNew(Ellipsis_type, NULL, NULL);
2950 break; 2944 if (!result) goto failed;
2951 case Ellipsis_kind: 2945 break;
2952 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); 2946 case Attribute_kind:
2953 if (!result) goto failed; 2947 result = PyType_GenericNew(Attribute_type, NULL, NULL);
2954 break; 2948 if (!result) goto failed;
2955 case Attribute_kind: 2949 value = ast2obj_expr(o->v.Attribute.value);
2956 result = PyType_GenericNew(Attribute_type, NULL, NULL); 2950 if (!value) goto failed;
2957 if (!result) goto failed; 2951 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2958 value = ast2obj_expr(o->v.Attribute.value); 2952 goto failed;
2959 if (!value) goto failed; 2953 Py_DECREF(value);
2960 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2954 value = ast2obj_identifier(o->v.Attribute.attr);
2961 goto failed; 2955 if (!value) goto failed;
2962 Py_DECREF(value); 2956 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1)
2963 value = ast2obj_identifier(o->v.Attribute.attr); 2957 goto failed;
2964 if (!value) goto failed; 2958 Py_DECREF(value);
2965 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1) 2959 value = ast2obj_expr_context(o->v.Attribute.ctx);
2966 goto failed; 2960 if (!value) goto failed;
2967 Py_DECREF(value); 2961 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2968 value = ast2obj_expr_context(o->v.Attribute.ctx); 2962 goto failed;
2969 if (!value) goto failed; 2963 Py_DECREF(value);
2970 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) 2964 break;
2971 goto failed; 2965 case Subscript_kind:
2972 Py_DECREF(value); 2966 result = PyType_GenericNew(Subscript_type, NULL, NULL);
2973 break; 2967 if (!result) goto failed;
2974 case Subscript_kind: 2968 value = ast2obj_expr(o->v.Subscript.value);
2975 result = PyType_GenericNew(Subscript_type, NULL, NULL); 2969 if (!value) goto failed;
2976 if (!result) goto failed; 2970 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2977 value = ast2obj_expr(o->v.Subscript.value); 2971 goto failed;
2978 if (!value) goto failed; 2972 Py_DECREF(value);
2979 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2973 value = ast2obj_slice(o->v.Subscript.slice);
2980 goto failed; 2974 if (!value) goto failed;
2981 Py_DECREF(value); 2975 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1)
2982 value = ast2obj_slice(o->v.Subscript.slice); 2976 goto failed;
2983 if (!value) goto failed; 2977 Py_DECREF(value);
2984 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1) 2978 value = ast2obj_expr_context(o->v.Subscript.ctx);
2985 goto failed; 2979 if (!value) goto failed;
2986 Py_DECREF(value); 2980 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
2987 value = ast2obj_expr_context(o->v.Subscript.ctx); 2981 goto failed;
2988 if (!value) goto failed; 2982 Py_DECREF(value);
2989 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) 2983 break;
2990 goto failed; 2984 case Starred_kind:
2991 Py_DECREF(value); 2985 result = PyType_GenericNew(Starred_type, NULL, NULL);
2992 break; 2986 if (!result) goto failed;
2993 case Starred_kind: 2987 value = ast2obj_expr(o->v.Starred.value);
2994 result = PyType_GenericNew(Starred_type, NULL, NULL); 2988 if (!value) goto failed;
2995 if (!result) goto failed; 2989 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
2996 value = ast2obj_expr(o->v.Starred.value); 2990 goto failed;
2997 if (!value) goto failed; 2991 Py_DECREF(value);
2998 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 2992 value = ast2obj_expr_context(o->v.Starred.ctx);
2999 goto failed; 2993 if (!value) goto failed;
3000 Py_DECREF(value); 2994 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
3001 value = ast2obj_expr_context(o->v.Starred.ctx); 2995 goto failed;
3002 if (!value) goto failed; 2996 Py_DECREF(value);
3003 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) 2997 break;
3004 goto failed; 2998 case Name_kind:
3005 Py_DECREF(value); 2999 result = PyType_GenericNew(Name_type, NULL, NULL);
3006 break; 3000 if (!result) goto failed;
3007 case Name_kind: 3001 value = ast2obj_identifier(o->v.Name.id);
3008 result = PyType_GenericNew(Name_type, NULL, NULL); 3002 if (!value) goto failed;
3009 if (!result) goto failed; 3003 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1)
3010 value = ast2obj_identifier(o->v.Name.id); 3004 goto failed;
3011 if (!value) goto failed; 3005 Py_DECREF(value);
3012 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1) 3006 value = ast2obj_expr_context(o->v.Name.ctx);
3013 goto failed; 3007 if (!value) goto failed;
3014 Py_DECREF(value); 3008 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
3015 value = ast2obj_expr_context(o->v.Name.ctx); 3009 goto failed;
3016 if (!value) goto failed; 3010 Py_DECREF(value);
3017 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) 3011 break;
3018 goto failed; 3012 case List_kind:
3019 Py_DECREF(value); 3013 result = PyType_GenericNew(List_type, NULL, NULL);
3020 break; 3014 if (!result) goto failed;
3021 case List_kind: 3015 value = ast2obj_list(o->v.List.elts, ast2obj_expr);
3022 result = PyType_GenericNew(List_type, NULL, NULL); 3016 if (!value) goto failed;
3023 if (!result) goto failed; 3017 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
3024 value = ast2obj_list(o->v.List.elts, ast2obj_expr); 3018 goto failed;
3025 if (!value) goto failed; 3019 Py_DECREF(value);
3026 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) 3020 value = ast2obj_expr_context(o->v.List.ctx);
3027 goto failed; 3021 if (!value) goto failed;
3028 Py_DECREF(value); 3022 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
3029 value = ast2obj_expr_context(o->v.List.ctx); 3023 goto failed;
3030 if (!value) goto failed; 3024 Py_DECREF(value);
3031 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) 3025 break;
3032 goto failed; 3026 case Tuple_kind:
3033 Py_DECREF(value); 3027 result = PyType_GenericNew(Tuple_type, NULL, NULL);
3034 break; 3028 if (!result) goto failed;
3035 case Tuple_kind: 3029 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr);
3036 result = PyType_GenericNew(Tuple_type, NULL, NULL); 3030 if (!value) goto failed;
3037 if (!result) goto failed; 3031 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
3038 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); 3032 goto failed;
3039 if (!value) goto failed; 3033 Py_DECREF(value);
3040 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) 3034 value = ast2obj_expr_context(o->v.Tuple.ctx);
3041 goto failed; 3035 if (!value) goto failed;
3042 Py_DECREF(value); 3036 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
3043 value = ast2obj_expr_context(o->v.Tuple.ctx); 3037 goto failed;
3044 if (!value) goto failed; 3038 Py_DECREF(value);
3045 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) 3039 break;
3046 goto failed; 3040 }
3047 Py_DECREF(value); 3041 value = ast2obj_int(o->lineno);
3048 break; 3042 if (!value) goto failed;
3049 } 3043 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
3050 value = ast2obj_int(o->lineno); 3044 goto failed;
3051 if (!value) goto failed; 3045 Py_DECREF(value);
3052 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) 3046 value = ast2obj_int(o->col_offset);
3053 goto failed; 3047 if (!value) goto failed;
3054 Py_DECREF(value); 3048 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
3055 value = ast2obj_int(o->col_offset); 3049 goto failed;
3056 if (!value) goto failed; 3050 Py_DECREF(value);
3057 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) 3051 return result;
3058 goto failed;
3059 Py_DECREF(value);
3060 return result;
3061 failed: 3052 failed:
3062 Py_XDECREF(value); 3053 Py_XDECREF(value);
3063 Py_XDECREF(result); 3054 Py_XDECREF(result);
3064 return NULL; 3055 return NULL;
3065 } 3056 }
3066 3057
3067 PyObject* ast2obj_expr_context(expr_context_ty o) 3058 PyObject* ast2obj_expr_context(expr_context_ty o)
3068 { 3059 {
3069 switch(o) { 3060 switch(o) {
3070 case Load: 3061 case Load:
3071 Py_INCREF(Load_singleton); 3062 Py_INCREF(Load_singleton);
3072 return Load_singleton; 3063 return Load_singleton;
3073 case Store: 3064 case Store:
3074 Py_INCREF(Store_singleton); 3065 Py_INCREF(Store_singleton);
3075 return Store_singleton; 3066 return Store_singleton;
3076 case Del: 3067 case Del:
3077 Py_INCREF(Del_singleton); 3068 Py_INCREF(Del_singleton);
3078 return Del_singleton; 3069 return Del_singleton;
3079 case AugLoad: 3070 case AugLoad:
3080 Py_INCREF(AugLoad_singleton); 3071 Py_INCREF(AugLoad_singleton);
3081 return AugLoad_singleton; 3072 return AugLoad_singleton;
3082 case AugStore: 3073 case AugStore:
3083 Py_INCREF(AugStore_singleton); 3074 Py_INCREF(AugStore_singleton);
3084 return AugStore_singleton; 3075 return AugStore_singleton;
3085 case Param: 3076 case Param:
3086 Py_INCREF(Param_singleton); 3077 Py_INCREF(Param_singleton);
3087 return Param_singleton; 3078 return Param_singleton;
3088 default: 3079 default:
3089 /* should never happen, but just in case ... */ 3080 /* should never happen, but just in case ... */
3090 PyErr_Format(PyExc_SystemError, "unknown expr_context found"); 3081 PyErr_Format(PyExc_SystemError, "unknown expr_context found");
3091 return NULL; 3082 return NULL;
3092 } 3083 }
3093 } 3084 }
3094 PyObject* 3085 PyObject*
3095 ast2obj_slice(void* _o) 3086 ast2obj_slice(void* _o)
3096 { 3087 {
3097 slice_ty o = (slice_ty)_o; 3088 slice_ty o = (slice_ty)_o;
3098 PyObject *result = NULL, *value = NULL; 3089 PyObject *result = NULL, *value = NULL;
3099 if (!o) { 3090 if (!o) {
3100 Py_INCREF(Py_None); 3091 Py_INCREF(Py_None);
3101 return Py_None; 3092 return Py_None;
3102 } 3093 }
3103 3094
3104 switch (o->kind) { 3095 switch (o->kind) {
3105 case Slice_kind: 3096 case Slice_kind:
3106 result = PyType_GenericNew(Slice_type, NULL, NULL); 3097 result = PyType_GenericNew(Slice_type, NULL, NULL);
3107 if (!result) goto failed; 3098 if (!result) goto failed;
3108 value = ast2obj_expr(o->v.Slice.lower); 3099 value = ast2obj_expr(o->v.Slice.lower);
3109 if (!value) goto failed; 3100 if (!value) goto failed;
3110 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1) 3101 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1)
3111 goto failed; 3102 goto failed;
3112 Py_DECREF(value); 3103 Py_DECREF(value);
3113 value = ast2obj_expr(o->v.Slice.upper); 3104 value = ast2obj_expr(o->v.Slice.upper);
3114 if (!value) goto failed; 3105 if (!value) goto failed;
3115 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1) 3106 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1)
3116 goto failed; 3107 goto failed;
3117 Py_DECREF(value); 3108 Py_DECREF(value);
3118 value = ast2obj_expr(o->v.Slice.step); 3109 value = ast2obj_expr(o->v.Slice.step);
3119 if (!value) goto failed; 3110 if (!value) goto failed;
3120 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1) 3111 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1)
3121 goto failed; 3112 goto failed;
3122 Py_DECREF(value); 3113 Py_DECREF(value);
3123 break; 3114 break;
3124 case ExtSlice_kind: 3115 case ExtSlice_kind:
3125 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); 3116 result = PyType_GenericNew(ExtSlice_type, NULL, NULL);
3126 if (!result) goto failed; 3117 if (!result) goto failed;
3127 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); 3118 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);
3128 if (!value) goto failed; 3119 if (!value) goto failed;
3129 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1) 3120 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1)
3130 goto failed; 3121 goto failed;
3131 Py_DECREF(value); 3122 Py_DECREF(value);
3132 break; 3123 break;
3133 case Index_kind: 3124 case Index_kind:
3134 result = PyType_GenericNew(Index_type, NULL, NULL); 3125 result = PyType_GenericNew(Index_type, NULL, NULL);
3135 if (!result) goto failed; 3126 if (!result) goto failed;
3136 value = ast2obj_expr(o->v.Index.value); 3127 value = ast2obj_expr(o->v.Index.value);
3137 if (!value) goto failed; 3128 if (!value) goto failed;
3138 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 3129 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
3139 goto failed; 3130 goto failed;
3140 Py_DECREF(value); 3131 Py_DECREF(value);
3141 break; 3132 break;
3142 } 3133 }
3143 return result; 3134 return result;
3144 failed: 3135 failed:
3145 Py_XDECREF(value); 3136 Py_XDECREF(value);
3146 Py_XDECREF(result); 3137 Py_XDECREF(result);
3147 return NULL; 3138 return NULL;
3148 } 3139 }
3149 3140
3150 PyObject* ast2obj_boolop(boolop_ty o) 3141 PyObject* ast2obj_boolop(boolop_ty o)
3151 { 3142 {
3152 switch(o) { 3143 switch(o) {
3153 case And: 3144 case And:
3154 Py_INCREF(And_singleton); 3145 Py_INCREF(And_singleton);
3155 return And_singleton; 3146 return And_singleton;
3156 case Or: 3147 case Or:
3157 Py_INCREF(Or_singleton); 3148 Py_INCREF(Or_singleton);
3158 return Or_singleton; 3149 return Or_singleton;
3159 default: 3150 default:
3160 /* should never happen, but just in case ... */ 3151 /* should never happen, but just in case ... */
3161 PyErr_Format(PyExc_SystemError, "unknown boolop found"); 3152 PyErr_Format(PyExc_SystemError, "unknown boolop found");
3162 return NULL; 3153 return NULL;
3163 } 3154 }
3164 } 3155 }
3165 PyObject* ast2obj_operator(operator_ty o) 3156 PyObject* ast2obj_operator(operator_ty o)
3166 { 3157 {
3167 switch(o) { 3158 switch(o) {
3168 case Add: 3159 case Add:
3169 Py_INCREF(Add_singleton); 3160 Py_INCREF(Add_singleton);
3170 return Add_singleton; 3161 return Add_singleton;
3171 case Sub: 3162 case Sub:
3172 Py_INCREF(Sub_singleton); 3163 Py_INCREF(Sub_singleton);
3173 return Sub_singleton; 3164 return Sub_singleton;
3174 case Mult: 3165 case Mult:
3175 Py_INCREF(Mult_singleton); 3166 Py_INCREF(Mult_singleton);
3176 return Mult_singleton; 3167 return Mult_singleton;
3177 case Div: 3168 case Div:
3178 Py_INCREF(Div_singleton); 3169 Py_INCREF(Div_singleton);
3179 return Div_singleton; 3170 return Div_singleton;
3180 case Mod: 3171 case Mod:
3181 Py_INCREF(Mod_singleton); 3172 Py_INCREF(Mod_singleton);
3182 return Mod_singleton; 3173 return Mod_singleton;
3183 case Pow: 3174 case Pow:
3184 Py_INCREF(Pow_singleton); 3175 Py_INCREF(Pow_singleton);
3185 return Pow_singleton; 3176 return Pow_singleton;
3186 case LShift: 3177 case LShift:
3187 Py_INCREF(LShift_singleton); 3178 Py_INCREF(LShift_singleton);
3188 return LShift_singleton; 3179 return LShift_singleton;
3189 case RShift: 3180 case RShift:
3190 Py_INCREF(RShift_singleton); 3181 Py_INCREF(RShift_singleton);
3191 return RShift_singleton; 3182 return RShift_singleton;
3192 case BitOr: 3183 case BitOr:
3193 Py_INCREF(BitOr_singleton); 3184 Py_INCREF(BitOr_singleton);
3194 return BitOr_singleton; 3185 return BitOr_singleton;
3195 case BitXor: 3186 case BitXor:
3196 Py_INCREF(BitXor_singleton); 3187 Py_INCREF(BitXor_singleton);
3197 return BitXor_singleton; 3188 return BitXor_singleton;
3198 case BitAnd: 3189 case BitAnd:
3199 Py_INCREF(BitAnd_singleton); 3190 Py_INCREF(BitAnd_singleton);
3200 return BitAnd_singleton; 3191 return BitAnd_singleton;
3201 case FloorDiv: 3192 case FloorDiv:
3202 Py_INCREF(FloorDiv_singleton); 3193 Py_INCREF(FloorDiv_singleton);
3203 return FloorDiv_singleton; 3194 return FloorDiv_singleton;
3204 default: 3195 default:
3205 /* should never happen, but just in case ... */ 3196 /* should never happen, but just in case ... */
3206 PyErr_Format(PyExc_SystemError, "unknown operator found"); 3197 PyErr_Format(PyExc_SystemError, "unknown operator found");
3207 return NULL; 3198 return NULL;
3208 } 3199 }
3209 } 3200 }
3210 PyObject* ast2obj_unaryop(unaryop_ty o) 3201 PyObject* ast2obj_unaryop(unaryop_ty o)
3211 { 3202 {
3212 switch(o) { 3203 switch(o) {
3213 case Invert: 3204 case Invert:
3214 Py_INCREF(Invert_singleton); 3205 Py_INCREF(Invert_singleton);
3215 return Invert_singleton; 3206 return Invert_singleton;
3216 case Not: 3207 case Not:
3217 Py_INCREF(Not_singleton); 3208 Py_INCREF(Not_singleton);
3218 return Not_singleton; 3209 return Not_singleton;
3219 case UAdd: 3210 case UAdd:
3220 Py_INCREF(UAdd_singleton); 3211 Py_INCREF(UAdd_singleton);
3221 return UAdd_singleton; 3212 return UAdd_singleton;
3222 case USub: 3213 case USub:
3223 Py_INCREF(USub_singleton); 3214 Py_INCREF(USub_singleton);
3224 return USub_singleton; 3215 return USub_singleton;
3225 default: 3216 default:
3226 /* should never happen, but just in case ... */ 3217 /* should never happen, but just in case ... */
3227 PyErr_Format(PyExc_SystemError, "unknown unaryop found"); 3218 PyErr_Format(PyExc_SystemError, "unknown unaryop found");
3228 return NULL; 3219 return NULL;
3229 } 3220 }
3230 } 3221 }
3231 PyObject* ast2obj_cmpop(cmpop_ty o) 3222 PyObject* ast2obj_cmpop(cmpop_ty o)
3232 { 3223 {
3233 switch(o) { 3224 switch(o) {
3234 case Eq: 3225 case Eq:
3235 Py_INCREF(Eq_singleton); 3226 Py_INCREF(Eq_singleton);
3236 return Eq_singleton; 3227 return Eq_singleton;
3237 case NotEq: 3228 case NotEq:
3238 Py_INCREF(NotEq_singleton); 3229 Py_INCREF(NotEq_singleton);
3239 return NotEq_singleton; 3230 return NotEq_singleton;
3240 case Lt: 3231 case Lt:
3241 Py_INCREF(Lt_singleton); 3232 Py_INCREF(Lt_singleton);
3242 return Lt_singleton; 3233 return Lt_singleton;
3243 case LtE: 3234 case LtE:
3244 Py_INCREF(LtE_singleton); 3235 Py_INCREF(LtE_singleton);
3245 return LtE_singleton; 3236 return LtE_singleton;
3246 case Gt: 3237 case Gt:
3247 Py_INCREF(Gt_singleton); 3238 Py_INCREF(Gt_singleton);
3248 return Gt_singleton; 3239 return Gt_singleton;
3249 case GtE: 3240 case GtE:
3250 Py_INCREF(GtE_singleton); 3241 Py_INCREF(GtE_singleton);
3251 return GtE_singleton; 3242 return GtE_singleton;
3252 case Is: 3243 case Is:
3253 Py_INCREF(Is_singleton); 3244 Py_INCREF(Is_singleton);
3254 return Is_singleton; 3245 return Is_singleton;
3255 case IsNot: 3246 case IsNot:
3256 Py_INCREF(IsNot_singleton); 3247 Py_INCREF(IsNot_singleton);
3257 return IsNot_singleton; 3248 return IsNot_singleton;
3258 case In: 3249 case In:
3259 Py_INCREF(In_singleton); 3250 Py_INCREF(In_singleton);
3260 return In_singleton; 3251 return In_singleton;
3261 case NotIn: 3252 case NotIn:
3262 Py_INCREF(NotIn_singleton); 3253 Py_INCREF(NotIn_singleton);
3263 return NotIn_singleton; 3254 return NotIn_singleton;
3264 default: 3255 default:
3265 /* should never happen, but just in case ... */ 3256 /* should never happen, but just in case ... */
3266 PyErr_Format(PyExc_SystemError, "unknown cmpop found"); 3257 PyErr_Format(PyExc_SystemError, "unknown cmpop found");
3267 return NULL; 3258 return NULL;
3268 } 3259 }
3269 } 3260 }
3270 PyObject* 3261 PyObject*
3271 ast2obj_comprehension(void* _o) 3262 ast2obj_comprehension(void* _o)
3272 { 3263 {
3273 comprehension_ty o = (comprehension_ty)_o; 3264 comprehension_ty o = (comprehension_ty)_o;
3274 PyObject *result = NULL, *value = NULL; 3265 PyObject *result = NULL, *value = NULL;
3275 if (!o) { 3266 if (!o) {
3276 Py_INCREF(Py_None); 3267 Py_INCREF(Py_None);
3277 return Py_None; 3268 return Py_None;
3278 } 3269 }
3279 3270
3280 result = PyType_GenericNew(comprehension_type, NULL, NULL); 3271 result = PyType_GenericNew(comprehension_type, NULL, NULL);
3281 if (!result) return NULL; 3272 if (!result) return NULL;
3282 value = ast2obj_expr(o->target); 3273 value = ast2obj_expr(o->target);
3283 if (!value) goto failed; 3274 if (!value) goto failed;
3284 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) 3275 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
3285 goto failed; 3276 goto failed;
3286 Py_DECREF(value); 3277 Py_DECREF(value);
3287 value = ast2obj_expr(o->iter); 3278 value = ast2obj_expr(o->iter);
3288 if (!value) goto failed; 3279 if (!value) goto failed;
3289 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) 3280 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
3290 goto failed; 3281 goto failed;
3291 Py_DECREF(value); 3282 Py_DECREF(value);
3292 value = ast2obj_list(o->ifs, ast2obj_expr); 3283 value = ast2obj_list(o->ifs, ast2obj_expr);
3293 if (!value) goto failed; 3284 if (!value) goto failed;
3294 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1) 3285 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1)
3295 goto failed; 3286 goto failed;
3296 Py_DECREF(value); 3287 Py_DECREF(value);
3297 return result; 3288 return result;
3298 failed: 3289 failed:
3299 Py_XDECREF(value); 3290 Py_XDECREF(value);
3300 Py_XDECREF(result); 3291 Py_XDECREF(result);
3301 return NULL; 3292 return NULL;
3302 } 3293 }
3303 3294
3304 PyObject* 3295 PyObject*
3305 ast2obj_excepthandler(void* _o) 3296 ast2obj_excepthandler(void* _o)
3306 { 3297 {
3307 excepthandler_ty o = (excepthandler_ty)_o; 3298 excepthandler_ty o = (excepthandler_ty)_o;
3308 PyObject *result = NULL, *value = NULL; 3299 PyObject *result = NULL, *value = NULL;
3309 if (!o) { 3300 if (!o) {
3310 Py_INCREF(Py_None); 3301 Py_INCREF(Py_None);
3311 return Py_None; 3302 return Py_None;
3312 } 3303 }
3313 3304
3314 switch (o->kind) { 3305 switch (o->kind) {
3315 case ExceptHandler_kind: 3306 case ExceptHandler_kind:
3316 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL); 3307 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL);
3317 if (!result) goto failed; 3308 if (!result) goto failed;
3318 value = ast2obj_expr(o->v.ExceptHandler.type); 3309 value = ast2obj_expr(o->v.ExceptHandler.type);
3319 if (!value) goto failed; 3310 if (!value) goto failed;
3320 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1) 3311 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1)
3321 goto failed; 3312 goto failed;
3322 Py_DECREF(value); 3313 Py_DECREF(value);
3323 value = ast2obj_identifier(o->v.ExceptHandler.name); 3314 value = ast2obj_identifier(o->v.ExceptHandler.name);
3324 if (!value) goto failed; 3315 if (!value) goto failed;
3325 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) 3316 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
3326 goto failed; 3317 goto failed;
3327 Py_DECREF(value); 3318 Py_DECREF(value);
3328 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt); 3319 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt);
3329 if (!value) goto failed; 3320 if (!value) goto failed;
3330 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) 3321 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
3331 goto failed; 3322 goto failed;
3332 Py_DECREF(value); 3323 Py_DECREF(value);
3333 break; 3324 break;
3334 } 3325 }
3335 value = ast2obj_int(o->lineno); 3326 value = ast2obj_int(o->lineno);
3336 if (!value) goto failed; 3327 if (!value) goto failed;
3337 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) 3328 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
3338 goto failed; 3329 goto failed;
3339 Py_DECREF(value); 3330 Py_DECREF(value);
3340 value = ast2obj_int(o->col_offset); 3331 value = ast2obj_int(o->col_offset);
3341 if (!value) goto failed; 3332 if (!value) goto failed;
3342 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) 3333 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
3343 goto failed; 3334 goto failed;
3344 Py_DECREF(value); 3335 Py_DECREF(value);
3345 return result; 3336 return result;
3346 failed: 3337 failed:
3347 Py_XDECREF(value); 3338 Py_XDECREF(value);
3348 Py_XDECREF(result); 3339 Py_XDECREF(result);
3349 return NULL; 3340 return NULL;
3350 } 3341 }
3351 3342
3352 PyObject* 3343 PyObject*
3353 ast2obj_arguments(void* _o) 3344 ast2obj_arguments(void* _o)
3354 { 3345 {
3355 arguments_ty o = (arguments_ty)_o; 3346 arguments_ty o = (arguments_ty)_o;
3356 PyObject *result = NULL, *value = NULL; 3347 PyObject *result = NULL, *value = NULL;
3357 if (!o) { 3348 if (!o) {
3358 Py_INCREF(Py_None); 3349 Py_INCREF(Py_None);
3359 return Py_None; 3350 return Py_None;
3360 } 3351 }
3361 3352
3362 result = PyType_GenericNew(arguments_type, NULL, NULL); 3353 result = PyType_GenericNew(arguments_type, NULL, NULL);
3363 if (!result) return NULL; 3354 if (!result) return NULL;
3364 value = ast2obj_list(o->args, ast2obj_arg); 3355 value = ast2obj_list(o->args, ast2obj_arg);
3365 if (!value) goto failed; 3356 if (!value) goto failed;
3366 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) 3357 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
3367 goto failed; 3358 goto failed;
3368 Py_DECREF(value); 3359 Py_DECREF(value);
3369 value = ast2obj_identifier(o->vararg); 3360 value = ast2obj_identifier(o->vararg);
3370 if (!value) goto failed; 3361 if (!value) goto failed;
3371 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1) 3362 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1)
3372 goto failed; 3363 goto failed;
3373 Py_DECREF(value); 3364 Py_DECREF(value);
3374 value = ast2obj_expr(o->varargannotation); 3365 value = ast2obj_expr(o->varargannotation);
3375 if (!value) goto failed; 3366 if (!value) goto failed;
3376 if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1) 3367 if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1)
3377 goto failed; 3368 goto failed;
3378 Py_DECREF(value); 3369 Py_DECREF(value);
3379 value = ast2obj_list(o->kwonlyargs, ast2obj_arg); 3370 value = ast2obj_list(o->kwonlyargs, ast2obj_arg);
3380 if (!value) goto failed; 3371 if (!value) goto failed;
3381 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1) 3372 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1)
3382 goto failed; 3373 goto failed;
3383 Py_DECREF(value); 3374 Py_DECREF(value);
3384 value = ast2obj_identifier(o->kwarg); 3375 value = ast2obj_identifier(o->kwarg);
3385 if (!value) goto failed; 3376 if (!value) goto failed;
3386 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1) 3377 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1)
3387 goto failed; 3378 goto failed;
3388 Py_DECREF(value); 3379 Py_DECREF(value);
3389 value = ast2obj_expr(o->kwargannotation); 3380 value = ast2obj_expr(o->kwargannotation);
3390 if (!value) goto failed; 3381 if (!value) goto failed;
3391 if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1) 3382 if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1)
3392 goto failed; 3383 goto failed;
3393 Py_DECREF(value); 3384 Py_DECREF(value);
3394 value = ast2obj_list(o->defaults, ast2obj_expr); 3385 value = ast2obj_list(o->defaults, ast2obj_expr);
3395 if (!value) goto failed; 3386 if (!value) goto failed;
3396 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1) 3387 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1)
3397 goto failed; 3388 goto failed;
3398 Py_DECREF(value); 3389 Py_DECREF(value);
3399 value = ast2obj_list(o->kw_defaults, ast2obj_expr); 3390 value = ast2obj_list(o->kw_defaults, ast2obj_expr);
3400 if (!value) goto failed; 3391 if (!value) goto failed;
3401 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1) 3392 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)
3402 goto failed; 3393 goto failed;
3403 Py_DECREF(value); 3394 Py_DECREF(value);
3404 return result; 3395 return result;
3405 failed: 3396 failed:
3406 Py_XDECREF(value); 3397 Py_XDECREF(value);
3407 Py_XDECREF(result); 3398 Py_XDECREF(result);
3408 return NULL; 3399 return NULL;
3409 } 3400 }
3410 3401
3411 PyObject* 3402 PyObject*
3412 ast2obj_arg(void* _o) 3403 ast2obj_arg(void* _o)
3413 { 3404 {
3414 arg_ty o = (arg_ty)_o; 3405 arg_ty o = (arg_ty)_o;
3415 PyObject *result = NULL, *value = NULL; 3406 PyObject *result = NULL, *value = NULL;
3416 if (!o) { 3407 if (!o) {
3417 Py_INCREF(Py_None); 3408 Py_INCREF(Py_None);
3418 return Py_None; 3409 return Py_None;
3419 } 3410 }
3420 3411
3421 result = PyType_GenericNew(arg_type, NULL, NULL); 3412 result = PyType_GenericNew(arg_type, NULL, NULL);
3422 if (!result) return NULL; 3413 if (!result) return NULL;
3423 value = ast2obj_identifier(o->arg); 3414 value = ast2obj_identifier(o->arg);
3424 if (!value) goto failed; 3415 if (!value) goto failed;
3425 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) 3416 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
3426 goto failed; 3417 goto failed;
3427 Py_DECREF(value); 3418 Py_DECREF(value);
3428 value = ast2obj_expr(o->annotation); 3419 value = ast2obj_expr(o->annotation);
3429 if (!value) goto failed; 3420 if (!value) goto failed;
3430 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1) 3421 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1)
3431 goto failed; 3422 goto failed;
3432 Py_DECREF(value); 3423 Py_DECREF(value);
3433 return result; 3424 return result;
3434 failed: 3425 failed:
3435 Py_XDECREF(value); 3426 Py_XDECREF(value);
3436 Py_XDECREF(result); 3427 Py_XDECREF(result);
3437 return NULL; 3428 return NULL;
3438 } 3429 }
3439 3430
3440 PyObject* 3431 PyObject*
3441 ast2obj_keyword(void* _o) 3432 ast2obj_keyword(void* _o)
3442 { 3433 {
3443 keyword_ty o = (keyword_ty)_o; 3434 keyword_ty o = (keyword_ty)_o;
3444 PyObject *result = NULL, *value = NULL; 3435 PyObject *result = NULL, *value = NULL;
3445 if (!o) { 3436 if (!o) {
3446 Py_INCREF(Py_None); 3437 Py_INCREF(Py_None);
3447 return Py_None; 3438 return Py_None;
3448 } 3439 }
3449 3440
3450 result = PyType_GenericNew(keyword_type, NULL, NULL); 3441 result = PyType_GenericNew(keyword_type, NULL, NULL);
3451 if (!result) return NULL; 3442 if (!result) return NULL;
3452 value = ast2obj_identifier(o->arg); 3443 value = ast2obj_identifier(o->arg);
3453 if (!value) goto failed; 3444 if (!value) goto failed;
3454 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) 3445 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
3455 goto failed; 3446 goto failed;
3456 Py_DECREF(value); 3447 Py_DECREF(value);
3457 value = ast2obj_expr(o->value); 3448 value = ast2obj_expr(o->value);
3458 if (!value) goto failed; 3449 if (!value) goto failed;
3459 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) 3450 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
3460 goto failed; 3451 goto failed;
3461 Py_DECREF(value); 3452 Py_DECREF(value);
3462 return result; 3453 return result;
3463 failed: 3454 failed:
3464 Py_XDECREF(value); 3455 Py_XDECREF(value);
3465 Py_XDECREF(result); 3456 Py_XDECREF(result);
3466 return NULL; 3457 return NULL;
3467 } 3458 }
3468 3459
3469 PyObject* 3460 PyObject*
3470 ast2obj_alias(void* _o) 3461 ast2obj_alias(void* _o)
3471 { 3462 {
3472 alias_ty o = (alias_ty)_o; 3463 alias_ty o = (alias_ty)_o;
3473 PyObject *result = NULL, *value = NULL; 3464 PyObject *result = NULL, *value = NULL;
3474 if (!o) { 3465 if (!o) {
3475 Py_INCREF(Py_None); 3466 Py_INCREF(Py_None);
3476 return Py_None; 3467 return Py_None;
3477 } 3468 }
3478 3469
3479 result = PyType_GenericNew(alias_type, NULL, NULL); 3470 result = PyType_GenericNew(alias_type, NULL, NULL);
3480 if (!result) return NULL; 3471 if (!result) return NULL;
3481 value = ast2obj_identifier(o->name); 3472 value = ast2obj_identifier(o->name);
3482 if (!value) goto failed; 3473 if (!value) goto failed;
3483 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) 3474 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
3484 goto failed; 3475 goto failed;
3485 Py_DECREF(value); 3476 Py_DECREF(value);
3486 value = ast2obj_identifier(o->asname); 3477 value = ast2obj_identifier(o->asname);
3487 if (!value) goto failed; 3478 if (!value) goto failed;
3488 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1) 3479 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1)
3489 goto failed; 3480 goto failed;
3490 Py_DECREF(value); 3481 Py_DECREF(value);
3491 return result; 3482 return result;
3492 failed: 3483 failed:
3493 Py_XDECREF(value); 3484 Py_XDECREF(value);
3494 Py_XDECREF(result); 3485 Py_XDECREF(result);
3495 return NULL; 3486 return NULL;
3496 } 3487 }
3497 3488
3498 PyObject* 3489 PyObject*
3499 ast2obj_withitem(void* _o) 3490 ast2obj_withitem(void* _o)
3500 { 3491 {
3501 withitem_ty o = (withitem_ty)_o; 3492 withitem_ty o = (withitem_ty)_o;
3502 PyObject *result = NULL, *value = NULL; 3493 PyObject *result = NULL, *value = NULL;
3503 if (!o) { 3494 if (!o) {
3504 Py_INCREF(Py_None); 3495 Py_INCREF(Py_None);
3505 return Py_None; 3496 return Py_None;
3506 } 3497 }
3507 3498
3508 result = PyType_GenericNew(withitem_type, NULL, NULL); 3499 result = PyType_GenericNew(withitem_type, NULL, NULL);
3509 if (!result) return NULL; 3500 if (!result) return NULL;
3510 value = ast2obj_expr(o->context_expr); 3501 value = ast2obj_expr(o->context_expr);
3511 if (!value) goto failed; 3502 if (!value) goto failed;
3512 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1) 3503 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)
3513 goto failed; 3504 goto failed;
3514 Py_DECREF(value); 3505 Py_DECREF(value);
3515 value = ast2obj_expr(o->optional_vars); 3506 value = ast2obj_expr(o->optional_vars);
3516 if (!value) goto failed; 3507 if (!value) goto failed;
3517 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1) 3508 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)
3518 goto failed; 3509 goto failed;
3519 Py_DECREF(value); 3510 Py_DECREF(value);
3520 return result; 3511 return result;
3521 failed: 3512 failed:
3522 Py_XDECREF(value); 3513 Py_XDECREF(value);
3523 Py_XDECREF(result); 3514 Py_XDECREF(result);
3524 return NULL; 3515 return NULL;
3525 } 3516 }
3526 3517
3527 3518
3528 int 3519 int
3529 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) 3520 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
3530 { 3521 {
3531 int isinstance; 3522 int isinstance;
3532 3523
3533 PyObject *tmp = NULL; 3524 PyObject *tmp = NULL;
3534 3525
3535 if (obj == Py_None) { 3526 if (obj == Py_None) {
3536 *out = NULL; 3527 *out = NULL;
3537 return 0; 3528 return 0;
3538 } 3529 }
3539 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); 3530 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);
3540 if (isinstance == -1) { 3531 if (isinstance == -1) {
3541 return 1; 3532 return 1;
3542 } 3533 }
3543 if (isinstance) { 3534 if (isinstance) {
3544 asdl_seq* body; 3535 asdl_seq* body;
3545 3536
3546 if (_PyObject_HasAttrId(obj, &PyId_body)) { 3537 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3547 int res; 3538 int res;
3548 Py_ssize_t len; 3539 Py_ssize_t len;
3549 Py_ssize_t i; 3540 Py_ssize_t i;
3550 tmp = _PyObject_GetAttrId(obj, &PyId_body); 3541 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3551 if (tmp == NULL) goto failed; 3542 if (tmp == NULL) goto failed;
3552 if (!PyList_Check(tmp)) { 3543 if (!PyList_Check(tmp)) {
3553 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3544 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3554 goto failed; 3545 goto failed;
3555 } 3546 }
3556 len = PyList_GET_SIZE(tmp); 3547 len = PyList_GET_SIZE(tmp);
3557 body = asdl_seq_new(len, arena); 3548 body = asdl_seq_new(len, arena);
3558 if (body == NULL) goto failed; 3549 if (body == NULL) goto failed;
3559 for (i = 0; i < len; i++) { 3550 for (i = 0; i < len; i++) {
3560 stmt_ty value; 3551 stmt_ty value;
3561 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); 3552 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
3562 if (res != 0) goto failed; 3553 if (res != 0) goto failed;
3563 asdl_seq_SET(body, i, value); 3554 asdl_seq_SET(body, i, value);
3564 } 3555 }
3565 Py_XDECREF(tmp); 3556 Py_XDECREF(tmp);
3566 tmp = NULL; 3557 tmp = NULL;
3567 } else { 3558 } else {
3568 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module"); 3559 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
3569 return 1; 3560 return 1;
3570 } 3561 }
3571 *out = Module(body, arena); 3562 *out = Module(body, arena);
3572 if (*out == NULL) goto failed; 3563 if (*out == NULL) goto failed;
3573 return 0; 3564 return 0;
3574 } 3565 }
3575 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); 3566 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);
3576 if (isinstance == -1) { 3567 if (isinstance == -1) {
3577 return 1; 3568 return 1;
3578 } 3569 }
3579 if (isinstance) { 3570 if (isinstance) {
3580 asdl_seq* body; 3571 asdl_seq* body;
3581 3572
3582 if (_PyObject_HasAttrId(obj, &PyId_body)) { 3573 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3583 int res; 3574 int res;
3584 Py_ssize_t len; 3575 Py_ssize_t len;
3585 Py_ssize_t i; 3576 Py_ssize_t i;
3586 tmp = _PyObject_GetAttrId(obj, &PyId_body); 3577 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3587 if (tmp == NULL) goto failed; 3578 if (tmp == NULL) goto failed;
3588 if (!PyList_Check(tmp)) { 3579 if (!PyList_Check(tmp)) {
3589 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3580 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3590 goto failed; 3581 goto failed;
3591 } 3582 }
3592 len = PyList_GET_SIZE(tmp); 3583 len = PyList_GET_SIZE(tmp);
3593 body = asdl_seq_new(len, arena); 3584 body = asdl_seq_new(len, arena);
3594 if (body == NULL) goto failed; 3585 if (body == NULL) goto failed;
3595 for (i = 0; i < len; i++) { 3586 for (i = 0; i < len; i++) {
3596 stmt_ty value; 3587 stmt_ty value;
3597 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); 3588 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
3598 if (res != 0) goto failed; 3589 if (res != 0) goto failed;
3599 asdl_seq_SET(body, i, value); 3590 asdl_seq_SET(body, i, value);
3600 } 3591 }
3601 Py_XDECREF(tmp); 3592 Py_XDECREF(tmp);
3602 tmp = NULL; 3593 tmp = NULL;
3603 } else { 3594 } else {
3604 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive"); 3595 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
3605 return 1; 3596 return 1;
3606 } 3597 }
3607 *out = Interactive(body, arena); 3598 *out = Interactive(body, arena);
3608 if (*out == NULL) goto failed; 3599 if (*out == NULL) goto failed;
3609 return 0; 3600 return 0;
3610 } 3601 }
3611 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); 3602 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);
3612 if (isinstance == -1) { 3603 if (isinstance == -1) {
3613 return 1; 3604 return 1;
3614 } 3605 }
3615 if (isinstance) { 3606 if (isinstance) {
3616 expr_ty body; 3607 expr_ty body;
3617 3608
3618 if (_PyObject_HasAttrId(obj, &PyId_body)) { 3609 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3619 int res; 3610 int res;
3620 tmp = _PyObject_GetAttrId(obj, &PyId_body); 3611 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3621 if (tmp == NULL) goto failed; 3612 if (tmp == NULL) goto failed;
3622 res = obj2ast_expr(tmp, &body, arena); 3613 res = obj2ast_expr(tmp, &body, arena);
3623 if (res != 0) goto failed; 3614 if (res != 0) goto failed;
3624 Py_XDECREF(tmp); 3615 Py_XDECREF(tmp);
3625 tmp = NULL; 3616 tmp = NULL;
3626 } else { 3617 } else {
3627 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression"); 3618 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
3628 return 1; 3619 return 1;
3629 } 3620 }
3630 *out = Expression(body, arena); 3621 *out = Expression(body, arena);
3631 if (*out == NULL) goto failed; 3622 if (*out == NULL) goto failed;
3632 return 0; 3623 return 0;
3633 } 3624 }
3634 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); 3625 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);
3635 if (isinstance == -1) { 3626 if (isinstance == -1) {
3636 return 1; 3627 return 1;
3637 } 3628 }
3638 if (isinstance) { 3629 if (isinstance) {
3639 asdl_seq* body; 3630 asdl_seq* body;
3640 3631
3641 if (_PyObject_HasAttrId(obj, &PyId_body)) { 3632 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3642 int res; 3633 int res;
3643 Py_ssize_t len; 3634 Py_ssize_t len;
3644 Py_ssize_t i; 3635 Py_ssize_t i;
3645 tmp = _PyObject_GetAttrId(obj, &PyId_body); 3636 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3646 if (tmp == NULL) goto failed; 3637 if (tmp == NULL) goto failed;
3647 if (!PyList_Check(tmp)) { 3638 if (!PyList_Check(tmp)) {
3648 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3639 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3649 goto failed; 3640 goto failed;
3650 } 3641 }
3651 len = PyList_GET_SIZE(tmp); 3642 len = PyList_GET_SIZE(tmp);
3652 body = asdl_seq_new(len, arena); 3643 body = asdl_seq_new(len, arena);
3653 if (body == NULL) goto failed; 3644 if (body == NULL) goto failed;
3654 for (i = 0; i < len; i++) { 3645 for (i = 0; i < len; i++) {
3655 stmt_ty value; 3646 stmt_ty value;
3656 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); 3647 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
3657 if (res != 0) goto failed; 3648 if (res != 0) goto failed;
3658 asdl_seq_SET(body, i, value); 3649 asdl_seq_SET(body, i, value);
3659 } 3650 }
3660 Py_XDECREF(tmp); 3651 Py_XDECREF(tmp);
3661 tmp = NULL; 3652 tmp = NULL;
3662 } else { 3653 } else {
3663 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite"); 3654 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
3664 return 1; 3655 return 1;
3665 } 3656 }
3666 *out = Suite(body, arena); 3657 *out = Suite(body, arena);
3667 if (*out == NULL) goto failed; 3658 if (*out == NULL) goto failed;
3668 return 0; 3659 return 0;
3669 } 3660 }
3670 3661
3671 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj); 3662 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
3672 failed: 3663 failed:
3673 Py_XDECREF(tmp); 3664 Py_XDECREF(tmp);
3674 return 1; 3665 return 1;
3675 } 3666 }
3676 3667
3677 int 3668 int
3678 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) 3669 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
3679 { 3670 {
3680 int isinstance; 3671 int isinstance;
3681 3672
3682 PyObject *tmp = NULL; 3673 PyObject *tmp = NULL;
3683 int lineno; 3674 int lineno;
3684 int col_offset; 3675 int col_offset;
3685 3676
3686 if (obj == Py_None) { 3677 if (obj == Py_None) {
3687 *out = NULL; 3678 *out = NULL;
3688 return 0; 3679 return 0;
3689 } 3680 }
3690 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { 3681 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
3691 int res; 3682 int res;
3692 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); 3683 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
3693 if (tmp == NULL) goto failed; 3684 if (tmp == NULL) goto failed;
3694 res = obj2ast_int(tmp, &lineno, arena); 3685 res = obj2ast_int(tmp, &lineno, arena);
3686 if (res != 0) goto failed;
3687 Py_XDECREF(tmp);
3688 tmp = NULL;
3689 } else {
3690 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
3691 return 1;
3692 }
3693 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
3694 int res;
3695 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
3696 if (tmp == NULL) goto failed;
3697 res = obj2ast_int(tmp, &col_offset, arena);
3698 if (res != 0) goto failed;
3699 Py_XDECREF(tmp);
3700 tmp = NULL;
3701 } else {
3702 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
3703 return 1;
3704 }
3705 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type);
3706 if (isinstance == -1) {
3707 return 1;
3708 }
3709 if (isinstance) {
3710 identifier name;
3711 arguments_ty args;
3712 asdl_seq* body;
3713 asdl_seq* decorator_list;
3714 expr_ty returns;
3715
3716 if (_PyObject_HasAttrId(obj, &PyId_name)) {
3717 int res;
3718 tmp = _PyObject_GetAttrId(obj, &PyId_name);
3719 if (tmp == NULL) goto failed;
3720 res = obj2ast_identifier(tmp, &name, arena);
3721 if (res != 0) goto failed;
3722 Py_XDECREF(tmp);
3723 tmp = NULL;
3724 } else {
3725 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
3726 return 1;
3727 }
3728 if (_PyObject_HasAttrId(obj, &PyId_args)) {
3729 int res;
3730 tmp = _PyObject_GetAttrId(obj, &PyId_args);
3731 if (tmp == NULL) goto failed;
3732 res = obj2ast_arguments(tmp, &args, arena);
3733 if (res != 0) goto failed;
3734 Py_XDECREF(tmp);
3735 tmp = NULL;
3736 } else {
3737 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
3738 return 1;
3739 }
3740 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3741 int res;
3742 Py_ssize_t len;
3743 Py_ssize_t i;
3744 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3745 if (tmp == NULL) goto failed;
3746 if (!PyList_Check(tmp)) {
3747 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3748 goto failed;
3749 }
3750 len = PyList_GET_SIZE(tmp);
3751 body = asdl_seq_new(len, arena);
3752 if (body == NULL) goto failed;
3753 for (i = 0; i < len; i++) {
3754 stmt_ty value;
3755 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
3695 if (res != 0) goto failed; 3756 if (res != 0) goto failed;
3696 Py_XDECREF(tmp); 3757 asdl_seq_SET(body, i, value);
3697 tmp = NULL; 3758 }
3698 } else { 3759 Py_XDECREF(tmp);
3699 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt"); 3760 tmp = NULL;
3700 return 1; 3761 } else {
3701 } 3762 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
3702 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { 3763 return 1;
3703 int res; 3764 }
3704 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); 3765 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
3705 if (tmp == NULL) goto failed; 3766 int res;
3706 res = obj2ast_int(tmp, &col_offset, arena); 3767 Py_ssize_t len;
3768 Py_ssize_t i;
3769 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
3770 if (tmp == NULL) goto failed;
3771 if (!PyList_Check(tmp)) {
3772 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3773 goto failed;
3774 }
3775 len = PyList_GET_SIZE(tmp);
3776 decorator_list = asdl_seq_new(len, arena);
3777 if (decorator_list == NULL) goto failed;
3778 for (i = 0; i < len; i++) {
3779 expr_ty value;
3780 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
3707 if (res != 0) goto failed; 3781 if (res != 0) goto failed;
3708 Py_XDECREF(tmp); 3782 asdl_seq_SET(decorator_list, i, value);
3709 tmp = NULL; 3783 }
3710 } else { 3784 Py_XDECREF(tmp);
3711 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); 3785 tmp = NULL;
3712 return 1; 3786 } else {
3713 } 3787 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
3714 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); 3788 return 1;
3715 if (isinstance == -1) { 3789 }
3716 return 1; 3790 if (_PyObject_HasAttrId(obj, &PyId_returns)) {
3717 } 3791 int res;
3718 if (isinstance) { 3792 tmp = _PyObject_GetAttrId(obj, &PyId_returns);
3719 identifier name; 3793 if (tmp == NULL) goto failed;
3720 arguments_ty args; 3794 res = obj2ast_expr(tmp, &returns, arena);
3721 asdl_seq* body; 3795 if (res != 0) goto failed;
3722 asdl_seq* decorator_list; 3796 Py_XDECREF(tmp);
3723 expr_ty returns; 3797 tmp = NULL;
3724 3798 } else {
3725 if (_PyObject_HasAttrId(obj, &PyId_name)) { 3799 returns = NULL;
3726 int res; 3800 }
3727 tmp = _PyObject_GetAttrId(obj, &PyId_name); 3801 *out = FunctionDef(name, args, body, decorator_list, returns, lineno,
3728 if (tmp == NULL) goto failed; 3802 col_offset, arena);
3729 res = obj2ast_identifier(tmp, &name, arena); 3803 if (*out == NULL) goto failed;
3730 if (res != 0) goto failed; 3804 return 0;
3731 Py_XDECREF(tmp); 3805 }
3732 tmp = NULL; 3806 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type);
3733 } else { 3807 if (isinstance == -1) {
3734 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef"); 3808 return 1;
3735 return 1; 3809 }
3736 } 3810 if (isinstance) {
3737 if (_PyObject_HasAttrId(obj, &PyId_args)) { 3811 identifier name;
3738 int res; 3812 asdl_seq* bases;
3739 tmp = _PyObject_GetAttrId(obj, &PyId_args); 3813 asdl_seq* keywords;
3740 if (tmp == NULL) goto failed; 3814 expr_ty starargs;
3741 res = obj2ast_arguments(tmp, &args, arena); 3815 expr_ty kwargs;
3742 if (res != 0) goto failed; 3816 asdl_seq* body;
3743 Py_XDECREF(tmp); 3817 asdl_seq* decorator_list;
3744 tmp = NULL; 3818
3745 } else { 3819 if (_PyObject_HasAttrId(obj, &PyId_name)) {
3746 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef"); 3820 int res;
3747 return 1; 3821 tmp = _PyObject_GetAttrId(obj, &PyId_name);
3748 } 3822 if (tmp == NULL) goto failed;
3749 if (_PyObject_HasAttrId(obj, &PyId_body)) { 3823 res = obj2ast_identifier(tmp, &name, arena);
3750 int res; 3824 if (res != 0) goto failed;
3751 Py_ssize_t len; 3825 Py_XDECREF(tmp);
3752 Py_ssize_t i; 3826 tmp = NULL;
3753 tmp = _PyObject_GetAttrId(obj, &PyId_body); 3827 } else {
3754 if (tmp == NULL) goto failed; 3828 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
3755 if (!PyList_Check(tmp)) { 3829 return 1;
3756 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3830 }
3757 goto failed; 3831 if (_PyObject_HasAttrId(obj, &PyId_bases)) {
3758 } 3832 int res;
3759 len = PyList_GET_SIZE(tmp); 3833 Py_ssize_t len;
3760 body = asdl_seq_new(len, arena); 3834 Py_ssize_t i;
3761 if (body == NULL) goto failed; 3835 tmp = _PyObject_GetAttrId(obj, &PyId_bases);
3762 for (i = 0; i < len; i++) { 3836 if (tmp == NULL) goto failed;
3763 stmt_ty value; 3837 if (!PyList_Check(tmp)) {
3764 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); 3838 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3765 if (res != 0) goto failed; 3839 goto failed;
3766 asdl_seq_SET(body, i, value); 3840 }
3767 } 3841 len = PyList_GET_SIZE(tmp);
3768 Py_XDECREF(tmp); 3842 bases = asdl_seq_new(len, arena);
3769 tmp = NULL; 3843 if (bases == NULL) goto failed;
3770 } else { 3844 for (i = 0; i < len; i++) {
3771 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
3772 return 1;
3773 }
3774 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
3775 int res;
3776 Py_ssize_t len;
3777 Py_ssize_t i;
3778 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
3779 if (tmp == NULL) goto failed;
3780 if (!PyList_Check(tmp)) {
3781 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3782 goto failed;
3783 }
3784 len = PyList_GET_SIZE(tmp);
3785 decorator_list = asdl_seq_new(len, arena);
3786 if (decorator_list == NULL) goto failed;
3787 for (i = 0; i < len; i++) {
3788 expr_ty value;
3789 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
3790 if (res != 0) goto failed;
3791 asdl_seq_SET(decorator_list, i, value);
3792 }
3793 Py_XDECREF(tmp);
3794 tmp = NULL;
3795 } else {
3796 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
3797 return 1;
3798 }
3799 if (_PyObject_HasAttrId(obj, &PyId_returns)) {
3800 int res;
3801 tmp = _PyObject_GetAttrId(obj, &PyId_returns);
3802 if (tmp == NULL) goto failed;
3803 res = obj2ast_expr(tmp, &returns, arena);
3804 if (res != 0) goto failed;
3805 Py_XDECREF(tmp);
3806 tmp = NULL;
3807 } else {
3808 returns = NULL;
3809 }
3810 *out = FunctionDef(name, args, body, decorator_list, returns,
3811 lineno, col_offset, arena);
3812 if (*out == NULL) goto failed;
3813 return 0;
3814 }
3815 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type);
3816 if (isinstance == -1) {
3817 return 1;
3818 }
3819 if (isinstance) {
3820 identifier name;
3821 asdl_seq* bases;
3822 asdl_seq* keywords;
3823 expr_ty starargs;
3824 expr_ty kwargs;
3825 asdl_seq* body;
3826 asdl_seq* decorator_list;
3827
3828 if (_PyObject_HasAttrId(obj, &PyId_name)) {
3829 int res;
3830 tmp = _PyObject_GetAttrId(obj, &PyId_name);
3831 if (tmp == NULL) goto failed;
3832 res = obj2ast_identifier(tmp, &name, arena);
3833 if (res != 0) goto failed;
3834 Py_XDECREF(tmp);
3835 tmp = NULL;
3836 } else {
3837 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
3838 return 1;
3839 }
3840 if (_PyObject_HasAttrId(obj, &PyId_bases)) {
3841 int res;
3842 Py_ssize_t len;
3843 Py_ssize_t i;
3844 tmp = _PyObject_GetAttrId(obj, &PyId_bases);
3845 if (tmp == NULL) goto failed;
3846 if (!PyList_Check(tmp)) {
3847 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3848 goto failed;
3849 }
3850 len = PyList_GET_SIZE(tmp);
3851 bases = asdl_seq_new(len, arena);
3852 if (bases == NULL) goto failed;
3853 for (i = 0; i < len; i++) {
3854 expr_ty value;
3855 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
3856 if (res != 0) goto failed;
3857 asdl_seq_SET(bases, i, value);
3858 }
3859 Py_XDECREF(tmp);
3860 tmp = NULL;
3861 } else {
3862 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
3863 return 1;
3864 }
3865 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
3866 int res;
3867 Py_ssize_t len;
3868 Py_ssize_t i;
3869 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
3870 if (tmp == NULL) goto failed;
3871 if (!PyList_Check(tmp)) {
3872 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3873 goto failed;
3874 }
3875 len = PyList_GET_SIZE(tmp);
3876 keywords = asdl_seq_new(len, arena);
3877 if (keywords == NULL) goto failed;
3878 for (i = 0; i < len; i++) {
3879 keyword_ty value;
3880 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
3881 if (res != 0) goto failed;
3882 asdl_seq_SET(keywords, i, value);
3883 }
3884 Py_XDECREF(tmp);
3885 tmp = NULL;
3886 } else {
3887 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
3888 return 1;
3889 }
3890 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
3891 int res;
3892 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
3893 if (tmp == NULL) goto failed;
3894 res = obj2ast_expr(tmp, &starargs, arena);
3895 if (res != 0) goto failed;
3896 Py_XDECREF(tmp);
3897 tmp = NULL;
3898 } else {
3899 starargs = NULL;
3900 }
3901 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
3902 int res;
3903 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
3904 if (tmp == NULL) goto failed;
3905 res = obj2ast_expr(tmp, &kwargs, arena);
3906 if (res != 0) goto failed;
3907 Py_XDECREF(tmp);
3908 tmp = NULL;
3909 } else {
3910 kwargs = NULL;
3911 }
3912 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3913 int res;
3914 Py_ssize_t len;
3915 Py_ssize_t i;
3916 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3917 if (tmp == NULL) goto failed;
3918 if (!PyList_Check(tmp)) {
3919 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3920 goto failed;
3921 }
3922 len = PyList_GET_SIZE(tmp);
3923 body = asdl_seq_new(len, arena);
3924 if (body == NULL) goto failed;
3925 for (i = 0; i < len; i++) {
3926 stmt_ty value;
3927 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
3928 if (res != 0) goto failed;
3929 asdl_seq_SET(body, i, value);
3930 }
3931 Py_XDECREF(tmp);
3932 tmp = NULL;
3933 } else {
3934 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
3935 return 1;
3936 }
3937 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
3938 int res;
3939 Py_ssize_t len;
3940 Py_ssize_t i;
3941 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
3942 if (tmp == NULL) goto failed;
3943 if (!PyList_Check(tmp)) {
3944 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3945 goto failed;
3946 }
3947 len = PyList_GET_SIZE(tmp);
3948 decorator_list = asdl_seq_new(len, arena);
3949 if (decorator_list == NULL) goto failed;
3950 for (i = 0; i < len; i++) {
3951 expr_ty value;
3952 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
3953 if (res != 0) goto failed;
3954 asdl_seq_SET(decorator_list, i, value);
3955 }
3956 Py_XDECREF(tmp);
3957 tmp = NULL;
3958 } else {
3959 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
3960 return 1;
3961 }
3962 *out = ClassDef(name, bases, keywords, starargs, kwargs, body,
3963 decorator_list, lineno, col_offset, arena);
3964 if (*out == NULL) goto failed;
3965 return 0;
3966 }
3967 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type);
3968 if (isinstance == -1) {
3969 return 1;
3970 }
3971 if (isinstance) {
3972 expr_ty value; 3845 expr_ty value;
3973 3846 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
3974 if (_PyObject_HasAttrId(obj, &PyId_value)) { 3847 if (res != 0) goto failed;
3975 int res; 3848 asdl_seq_SET(bases, i, value);
3976 tmp = _PyObject_GetAttrId(obj, &PyId_value); 3849 }
3977 if (tmp == NULL) goto failed; 3850 Py_XDECREF(tmp);
3978 res = obj2ast_expr(tmp, &value, arena); 3851 tmp = NULL;
3979 if (res != 0) goto failed; 3852 } else {
3980 Py_XDECREF(tmp); 3853 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
3981 tmp = NULL; 3854 return 1;
3982 } else { 3855 }
3983 value = NULL; 3856 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
3984 } 3857 int res;
3985 *out = Return(value, lineno, col_offset, arena); 3858 Py_ssize_t len;
3986 if (*out == NULL) goto failed; 3859 Py_ssize_t i;
3987 return 0; 3860 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
3988 } 3861 if (tmp == NULL) goto failed;
3989 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); 3862 if (!PyList_Check(tmp)) {
3990 if (isinstance == -1) { 3863 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3991 return 1; 3864 goto failed;
3992 } 3865 }
3993 if (isinstance) { 3866 len = PyList_GET_SIZE(tmp);
3994 asdl_seq* targets; 3867 keywords = asdl_seq_new(len, arena);
3995 3868 if (keywords == NULL) goto failed;
3996 if (_PyObject_HasAttrId(obj, &PyId_targets)) { 3869 for (i = 0; i < len; i++) {
3997 int res; 3870 keyword_ty value;
3998 Py_ssize_t len; 3871 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
3999 Py_ssize_t i; 3872 if (res != 0) goto failed;
4000 tmp = _PyObject_GetAttrId(obj, &PyId_targets); 3873 asdl_seq_SET(keywords, i, value);
4001 if (tmp == NULL) goto failed; 3874 }
4002 if (!PyList_Check(tmp)) { 3875 Py_XDECREF(tmp);
4003 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3876 tmp = NULL;
4004 goto failed; 3877 } else {
4005 } 3878 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
4006 len = PyList_GET_SIZE(tmp); 3879 return 1;
4007 targets = asdl_seq_new(len, arena); 3880 }
4008 if (targets == NULL) goto failed; 3881 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
4009 for (i = 0; i < len; i++) { 3882 int res;
4010 expr_ty value; 3883 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
4011 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); 3884 if (tmp == NULL) goto failed;
4012 if (res != 0) goto failed; 3885 res = obj2ast_expr(tmp, &starargs, arena);
4013 asdl_seq_SET(targets, i, value); 3886 if (res != 0) goto failed;
4014 } 3887 Py_XDECREF(tmp);
4015 Py_XDECREF(tmp); 3888 tmp = NULL;
4016 tmp = NULL; 3889 } else {
4017 } else { 3890 starargs = NULL;
4018 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete"); 3891 }
4019 return 1; 3892 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
4020 } 3893 int res;
4021 *out = Delete(targets, lineno, col_offset, arena); 3894 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
4022 if (*out == NULL) goto failed; 3895 if (tmp == NULL) goto failed;
4023 return 0; 3896 res = obj2ast_expr(tmp, &kwargs, arena);
4024 } 3897 if (res != 0) goto failed;
4025 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); 3898 Py_XDECREF(tmp);
4026 if (isinstance == -1) { 3899 tmp = NULL;
4027 return 1; 3900 } else {
4028 } 3901 kwargs = NULL;
4029 if (isinstance) { 3902 }
4030 asdl_seq* targets; 3903 if (_PyObject_HasAttrId(obj, &PyId_body)) {
3904 int res;
3905 Py_ssize_t len;
3906 Py_ssize_t i;
3907 tmp = _PyObject_GetAttrId(obj, &PyId_body);
3908 if (tmp == NULL) goto failed;
3909 if (!PyList_Check(tmp)) {
3910 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3911 goto failed;
3912 }
3913 len = PyList_GET_SIZE(tmp);
3914 body = asdl_seq_new(len, arena);
3915 if (body == NULL) goto failed;
3916 for (i = 0; i < len; i++) {
3917 stmt_ty value;
3918 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
3919 if (res != 0) goto failed;
3920 asdl_seq_SET(body, i, value);
3921 }
3922 Py_XDECREF(tmp);
3923 tmp = NULL;
3924 } else {
3925 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
3926 return 1;
3927 }
3928 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
3929 int res;
3930 Py_ssize_t len;
3931 Py_ssize_t i;
3932 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
3933 if (tmp == NULL) goto failed;
3934 if (!PyList_Check(tmp)) {
3935 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3936 goto failed;
3937 }
3938 len = PyList_GET_SIZE(tmp);
3939 decorator_list = asdl_seq_new(len, arena);
3940 if (decorator_list == NULL) goto failed;
3941 for (i = 0; i < len; i++) {
4031 expr_ty value; 3942 expr_ty value;
4032 3943 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
4033 if (_PyObject_HasAttrId(obj, &PyId_targets)) { 3944 if (res != 0) goto failed;
4034 int res; 3945 asdl_seq_SET(decorator_list, i, value);
4035 Py_ssize_t len; 3946 }
4036 Py_ssize_t i; 3947 Py_XDECREF(tmp);
4037 tmp = _PyObject_GetAttrId(obj, &PyId_targets); 3948 tmp = NULL;
4038 if (tmp == NULL) goto failed; 3949 } else {
4039 if (!PyList_Check(tmp)) { 3950 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
4040 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); 3951 return 1;
4041 goto failed; 3952 }
4042 } 3953 *out = ClassDef(name, bases, keywords, starargs, kwargs, body,
4043 len = PyList_GET_SIZE(tmp); 3954 decorator_list, lineno, col_offset, arena);
4044 targets = asdl_seq_new(len, arena); 3955 if (*out == NULL) goto failed;
4045 if (targets == NULL) goto failed; 3956 return 0;
4046 for (i = 0; i < len; i++) { 3957 }
4047 expr_ty value; 3958 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type);
4048 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); 3959 if (isinstance == -1) {
4049 if (res != 0) goto failed; 3960 return 1;
4050 asdl_seq_SET(targets, i, value); 3961 }
4051 } 3962 if (isinstance) {
4052 Py_XDECREF(tmp); 3963 expr_ty value;
4053 tmp = NULL; 3964
4054 } else { 3965 if (_PyObject_HasAttrId(obj, &PyId_value)) {
4055 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign"); 3966 int res;
4056 return 1; 3967 tmp = _PyObject_GetAttrId(obj, &PyId_value);
4057 } 3968 if (tmp == NULL) goto failed;
4058 if (_PyObject_HasAttrId(obj, &PyId_value)) { 3969 res = obj2ast_expr(tmp, &value, arena);
4059 int res; 3970 if (res != 0) goto failed;
4060 tmp = _PyObject_GetAttrId(obj, &PyId_value); 3971 Py_XDECREF(tmp);
4061 if (tmp == NULL) goto failed; 3972 tmp = NULL;
4062 res = obj2ast_expr(tmp, &value, arena); 3973 } else {
4063 if (res != 0) goto failed; 3974 value = NULL;
4064 Py_XDECREF(tmp); 3975 }
4065 tmp = NULL; 3976 *out = Return(value, lineno, col_offset, arena);
4066 } else { 3977 if (*out == NULL) goto failed;
4067 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign"); 3978 return 0;
4068 return 1; 3979 }
4069 } 3980 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type);
4070 *out = Assign(targets, value, lineno, col_offset, arena); 3981 if (isinstance == -1) {
4071 if (*out == NULL) goto failed; 3982 return 1;
4072 return 0; 3983 }
4073 } 3984 if (isinstance) {
4074 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); 3985 asdl_seq* targets;
4075 if (isinstance == -1) { 3986
4076 return 1; 3987 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
4077 } 3988 int res;
4078 if (isinstance) { 3989 Py_ssize_t len;
4079 expr_ty target; 3990 Py_ssize_t i;
4080 operator_ty op; 3991 tmp = _PyObject_GetAttrId(obj, &PyId_targets);
3992 if (tmp == NULL) goto failed;
3993 if (!PyList_Check(tmp)) {
3994 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
3995 goto failed;
3996 }
3997 len = PyList_GET_SIZE(tmp);
3998 targets = asdl_seq_new(len, arena);
3999 if (targets == NULL) goto failed;
4000 for (i = 0; i < len; i++) {
4081 expr_ty value; 4001 expr_ty value;
4082 4002 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
4083 if (_PyObject_HasAttrId(obj, &PyId_target)) { 4003 if (res != 0) goto failed;
4084 int res; 4004 asdl_seq_SET(targets, i, value);
4085 tmp = _PyObject_GetAttrId(obj, &PyId_target); 4005 }
4086 if (tmp == NULL) goto failed; 4006 Py_XDECREF(tmp);
4087 res = obj2ast_expr(tmp, &target, arena); 4007 tmp = NULL;
4088 if (res != 0) goto failed; 4008 } else {
4089 Py_XDECREF(tmp); 4009 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
4090 tmp = NULL; 4010 return 1;
4091 } else { 4011 }
4092 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign"); 4012 *out = Delete(targets, lineno, col_offset, arena);
4093 return 1; 4013 if (*out == NULL) goto failed;
4094 } 4014 return 0;
4095 if (_PyObject_HasAttrId(obj, &PyId_op)) { 4015 }
4096 int res; 4016 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type);
4097 tmp = _PyObject_GetAttrId(obj, &PyId_op); 4017 if (isinstance == -1) {
4098 if (tmp == NULL) goto failed; 4018 return 1;
4099 res = obj2ast_operator(tmp, &op, arena); 4019 }
4100 if (res != 0) goto failed; 4020 if (isinstance) {
4101 Py_XDECREF(tmp); 4021 asdl_seq* targets;
4102 tmp = NULL; 4022 expr_ty value;
4103 } else { 4023
4104 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); 4024 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
4105 return 1; 4025 int res;
4106 } 4026 Py_ssize_t len;
4107 if (_PyObject_HasAttrId(obj, &PyId_value)) { 4027 Py_ssize_t i;
4108 int res; 4028 tmp = _PyObject_GetAttrId(obj, &PyId_targets);
4109 tmp = _PyObject_GetAttrId(obj, &PyId_value); 4029 if (tmp == NULL) goto failed;
4110 if (tmp == NULL) goto failed; 4030 if (!PyList_Check(tmp)) {
4111 res = obj2ast_expr(tmp, &value, arena); 4031 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4112 if (res != 0) goto failed; 4032 goto failed;
4113 Py_XDECREF(tmp); 4033 }
4114 tmp = NULL; 4034 len = PyList_GET_SIZE(tmp);
4115 } else { 4035 targets = asdl_seq_new(len, arena);
4116 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign"); 4036 if (targets == NULL) goto failed;
4117 return 1; 4037 for (i = 0; i < len; i++) {
4118 }
4119 *out = AugAssign(target, op, value, lineno, col_offset, arena);
4120 if (*out == NULL) goto failed;
4121 return 0;
4122 }
4123 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type);
4124 if (isinstance == -1) {
4125 return 1;
4126 }
4127 if (isinstance) {
4128 expr_ty target;
4129 expr_ty iter;
4130 asdl_seq* body;
4131 asdl_seq* orelse;
4132
4133 if (_PyObject_HasAttrId(obj, &PyId_target)) {
4134 int res;
4135 tmp = _PyObject_GetAttrId(obj, &PyId_target);
4136 if (tmp == NULL) goto failed;
4137 res = obj2ast_expr(tmp, &target, arena);
4138 if (res != 0) goto failed;
4139 Py_XDECREF(tmp);
4140 tmp = NULL;
4141 } else {
4142 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
4143 return 1;
4144 }
4145 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
4146 int res;
4147 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
4148 if (tmp == NULL) goto failed;
4149 res = obj2ast_expr(tmp, &iter, arena);
4150 if (res != 0) goto failed;
4151 Py_XDECREF(tmp);
4152 tmp = NULL;
4153 } else {
4154 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
4155 return 1;
4156 }
4157 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4158 int res;
4159 Py_ssize_t len;
4160 Py_ssize_t i;
4161 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4162 if (tmp == NULL) goto failed;
4163 if (!PyList_Check(tmp)) {
4164 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4165 goto failed;
4166 }
4167 len = PyList_GET_SIZE(tmp);
4168 body = asdl_seq_new(len, arena);
4169 if (body == NULL) goto failed;
4170 for (i = 0; i < len; i++) {
4171 stmt_ty value;
4172 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4173 if (res != 0) goto failed;
4174 asdl_seq_SET(body, i, value);
4175 }
4176 Py_XDECREF(tmp);
4177 tmp = NULL;
4178 } else {
4179 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
4180 return 1;
4181 }
4182 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4183 int res;
4184 Py_ssize_t len;
4185 Py_ssize_t i;
4186 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4187 if (tmp == NULL) goto failed;
4188 if (!PyList_Check(tmp)) {
4189 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4190 goto failed;
4191 }
4192 len = PyList_GET_SIZE(tmp);
4193 orelse = asdl_seq_new(len, arena);
4194 if (orelse == NULL) goto failed;
4195 for (i = 0; i < len; i++) {
4196 stmt_ty value;
4197 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4198 if (res != 0) goto failed;
4199 asdl_seq_SET(orelse, i, value);
4200 }
4201 Py_XDECREF(tmp);
4202 tmp = NULL;
4203 } else {
4204 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
4205 return 1;
4206 }
4207 *out = For(target, iter, body, orelse, lineno, col_offset,
4208 arena);
4209 if (*out == NULL) goto failed;
4210 return 0;
4211 }
4212 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type);
4213 if (isinstance == -1) {
4214 return 1;
4215 }
4216 if (isinstance) {
4217 expr_ty test;
4218 asdl_seq* body;
4219 asdl_seq* orelse;
4220
4221 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4222 int res;
4223 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4224 if (tmp == NULL) goto failed;
4225 res = obj2ast_expr(tmp, &test, arena);
4226 if (res != 0) goto failed;
4227 Py_XDECREF(tmp);
4228 tmp = NULL;
4229 } else {
4230 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
4231 return 1;
4232 }
4233 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4234 int res;
4235 Py_ssize_t len;
4236 Py_ssize_t i;
4237 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4238 if (tmp == NULL) goto failed;
4239 if (!PyList_Check(tmp)) {
4240 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4241 goto failed;
4242 }
4243 len = PyList_GET_SIZE(tmp);
4244 body = asdl_seq_new(len, arena);
4245 if (body == NULL) goto failed;
4246 for (i = 0; i < len; i++) {
4247 stmt_ty value;
4248 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4249 if (res != 0) goto failed;
4250 asdl_seq_SET(body, i, value);
4251 }
4252 Py_XDECREF(tmp);
4253 tmp = NULL;
4254 } else {
4255 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
4256 return 1;
4257 }
4258 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4259 int res;
4260 Py_ssize_t len;
4261 Py_ssize_t i;
4262 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4263 if (tmp == NULL) goto failed;
4264 if (!PyList_Check(tmp)) {
4265 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4266 goto failed;
4267 }
4268 len = PyList_GET_SIZE(tmp);
4269 orelse = asdl_seq_new(len, arena);
4270 if (orelse == NULL) goto failed;
4271 for (i = 0; i < len; i++) {
4272 stmt_ty value;
4273 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4274 if (res != 0) goto failed;
4275 asdl_seq_SET(orelse, i, value);
4276 }
4277 Py_XDECREF(tmp);
4278 tmp = NULL;
4279 } else {
4280 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
4281 return 1;
4282 }
4283 *out = While(test, body, orelse, lineno, col_offset, arena);
4284 if (*out == NULL) goto failed;
4285 return 0;
4286 }
4287 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type);
4288 if (isinstance == -1) {
4289 return 1;
4290 }
4291 if (isinstance) {
4292 expr_ty test;
4293 asdl_seq* body;
4294 asdl_seq* orelse;
4295
4296 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4297 int res;
4298 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4299 if (tmp == NULL) goto failed;
4300 res = obj2ast_expr(tmp, &test, arena);
4301 if (res != 0) goto failed;
4302 Py_XDECREF(tmp);
4303 tmp = NULL;
4304 } else {
4305 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
4306 return 1;
4307 }
4308 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4309 int res;
4310 Py_ssize_t len;
4311 Py_ssize_t i;
4312 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4313 if (tmp == NULL) goto failed;
4314 if (!PyList_Check(tmp)) {
4315 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4316 goto failed;
4317 }
4318 len = PyList_GET_SIZE(tmp);
4319 body = asdl_seq_new(len, arena);
4320 if (body == NULL) goto failed;
4321 for (i = 0; i < len; i++) {
4322 stmt_ty value;
4323 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4324 if (res != 0) goto failed;
4325 asdl_seq_SET(body, i, value);
4326 }
4327 Py_XDECREF(tmp);
4328 tmp = NULL;
4329 } else {
4330 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
4331 return 1;
4332 }
4333 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4334 int res;
4335 Py_ssize_t len;
4336 Py_ssize_t i;
4337 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4338 if (tmp == NULL) goto failed;
4339 if (!PyList_Check(tmp)) {
4340 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4341 goto failed;
4342 }
4343 len = PyList_GET_SIZE(tmp);
4344 orelse = asdl_seq_new(len, arena);
4345 if (orelse == NULL) goto failed;
4346 for (i = 0; i < len; i++) {
4347 stmt_ty value;
4348 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4349 if (res != 0) goto failed;
4350 asdl_seq_SET(orelse, i, value);
4351 }
4352 Py_XDECREF(tmp);
4353 tmp = NULL;
4354 } else {
4355 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
4356 return 1;
4357 }
4358 *out = If(test, body, orelse, lineno, col_offset, arena);
4359 if (*out == NULL) goto failed;
4360 return 0;
4361 }
4362 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type);
4363 if (isinstance == -1) {
4364 return 1;
4365 }
4366 if (isinstance) {
4367 asdl_seq* items;
4368 asdl_seq* body;
4369
4370 if (_PyObject_HasAttrId(obj, &PyId_items)) {
4371 int res;
4372 Py_ssize_t len;
4373 Py_ssize_t i;
4374 tmp = _PyObject_GetAttrId(obj, &PyId_items);
4375 if (tmp == NULL) goto failed;
4376 if (!PyList_Check(tmp)) {
4377 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4378 goto failed;
4379 }
4380 len = PyList_GET_SIZE(tmp);
4381 items = asdl_seq_new(len, arena);
4382 if (items == NULL) goto failed;
4383 for (i = 0; i < len; i++) {
4384 withitem_ty value;
4385 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
4386 if (res != 0) goto failed;
4387 asdl_seq_SET(items, i, value);
4388 }
4389 Py_XDECREF(tmp);
4390 tmp = NULL;
4391 } else {
4392 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
4393 return 1;
4394 }
4395 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4396 int res;
4397 Py_ssize_t len;
4398 Py_ssize_t i;
4399 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4400 if (tmp == NULL) goto failed;
4401 if (!PyList_Check(tmp)) {
4402 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4403 goto failed;
4404 }
4405 len = PyList_GET_SIZE(tmp);
4406 body = asdl_seq_new(len, arena);
4407 if (body == NULL) goto failed;
4408 for (i = 0; i < len; i++) {
4409 stmt_ty value;
4410 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4411 if (res != 0) goto failed;
4412 asdl_seq_SET(body, i, value);
4413 }
4414 Py_XDECREF(tmp);
4415 tmp = NULL;
4416 } else {
4417 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
4418 return 1;
4419 }
4420 *out = With(items, body, lineno, col_offset, arena);
4421 if (*out == NULL) goto failed;
4422 return 0;
4423 }
4424 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type);
4425 if (isinstance == -1) {
4426 return 1;
4427 }
4428 if (isinstance) {
4429 expr_ty exc;
4430 expr_ty cause;
4431
4432 if (_PyObject_HasAttrId(obj, &PyId_exc)) {
4433 int res;
4434 tmp = _PyObject_GetAttrId(obj, &PyId_exc);
4435 if (tmp == NULL) goto failed;
4436 res = obj2ast_expr(tmp, &exc, arena);
4437 if (res != 0) goto failed;
4438 Py_XDECREF(tmp);
4439 tmp = NULL;
4440 } else {
4441 exc = NULL;
4442 }
4443 if (_PyObject_HasAttrId(obj, &PyId_cause)) {
4444 int res;
4445 tmp = _PyObject_GetAttrId(obj, &PyId_cause);
4446 if (tmp == NULL) goto failed;
4447 res = obj2ast_expr(tmp, &cause, arena);
4448 if (res != 0) goto failed;
4449 Py_XDECREF(tmp);
4450 tmp = NULL;
4451 } else {
4452 cause = NULL;
4453 }
4454 *out = Raise(exc, cause, lineno, col_offset, arena);
4455 if (*out == NULL) goto failed;
4456 return 0;
4457 }
4458 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type);
4459 if (isinstance == -1) {
4460 return 1;
4461 }
4462 if (isinstance) {
4463 asdl_seq* body;
4464 asdl_seq* handlers;
4465 asdl_seq* orelse;
4466 asdl_seq* finalbody;
4467
4468 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4469 int res;
4470 Py_ssize_t len;
4471 Py_ssize_t i;
4472 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4473 if (tmp == NULL) goto failed;
4474 if (!PyList_Check(tmp)) {
4475 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4476 goto failed;
4477 }
4478 len = PyList_GET_SIZE(tmp);
4479 body = asdl_seq_new(len, arena);
4480 if (body == NULL) goto failed;
4481 for (i = 0; i < len; i++) {
4482 stmt_ty value;
4483 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4484 if (res != 0) goto failed;
4485 asdl_seq_SET(body, i, value);
4486 }
4487 Py_XDECREF(tmp);
4488 tmp = NULL;
4489 } else {
4490 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
4491 return 1;
4492 }
4493 if (_PyObject_HasAttrId(obj, &PyId_handlers)) {
4494 int res;
4495 Py_ssize_t len;
4496 Py_ssize_t i;
4497 tmp = _PyObject_GetAttrId(obj, &PyId_handlers);
4498 if (tmp == NULL) goto failed;
4499 if (!PyList_Check(tmp)) {
4500 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4501 goto failed;
4502 }
4503 len = PyList_GET_SIZE(tmp);
4504 handlers = asdl_seq_new(len, arena);
4505 if (handlers == NULL) goto failed;
4506 for (i = 0; i < len; i++) {
4507 excepthandler_ty value;
4508 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena);
4509 if (res != 0) goto failed;
4510 asdl_seq_SET(handlers, i, value);
4511 }
4512 Py_XDECREF(tmp);
4513 tmp = NULL;
4514 } else {
4515 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
4516 return 1;
4517 }
4518 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4519 int res;
4520 Py_ssize_t len;
4521 Py_ssize_t i;
4522 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4523 if (tmp == NULL) goto failed;
4524 if (!PyList_Check(tmp)) {
4525 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4526 goto failed;
4527 }
4528 len = PyList_GET_SIZE(tmp);
4529 orelse = asdl_seq_new(len, arena);
4530 if (orelse == NULL) goto failed;
4531 for (i = 0; i < len; i++) {
4532 stmt_ty value;
4533 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4534 if (res != 0) goto failed;
4535 asdl_seq_SET(orelse, i, value);
4536 }
4537 Py_XDECREF(tmp);
4538 tmp = NULL;
4539 } else {
4540 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
4541 return 1;
4542 }
4543 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) {
4544 int res;
4545 Py_ssize_t len;
4546 Py_ssize_t i;
4547 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody);
4548 if (tmp == NULL) goto failed;
4549 if (!PyList_Check(tmp)) {
4550 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4551 goto failed;
4552 }
4553 len = PyList_GET_SIZE(tmp);
4554 finalbody = asdl_seq_new(len, arena);
4555 if (finalbody == NULL) goto failed;
4556 for (i = 0; i < len; i++) {
4557 stmt_ty value;
4558 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4559 if (res != 0) goto failed;
4560 asdl_seq_SET(finalbody, i, value);
4561 }
4562 Py_XDECREF(tmp);
4563 tmp = NULL;
4564 } else {
4565 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
4566 return 1;
4567 }
4568 *out = Try(body, handlers, orelse, finalbody, lineno,
4569 col_offset, arena);
4570 if (*out == NULL) goto failed;
4571 return 0;
4572 }
4573 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type);
4574 if (isinstance == -1) {
4575 return 1;
4576 }
4577 if (isinstance) {
4578 expr_ty test;
4579 expr_ty msg;
4580
4581 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4582 int res;
4583 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4584 if (tmp == NULL) goto failed;
4585 res = obj2ast_expr(tmp, &test, arena);
4586 if (res != 0) goto failed;
4587 Py_XDECREF(tmp);
4588 tmp = NULL;
4589 } else {
4590 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
4591 return 1;
4592 }
4593 if (_PyObject_HasAttrId(obj, &PyId_msg)) {
4594 int res;
4595 tmp = _PyObject_GetAttrId(obj, &PyId_msg);
4596 if (tmp == NULL) goto failed;
4597 res = obj2ast_expr(tmp, &msg, arena);
4598 if (res != 0) goto failed;
4599 Py_XDECREF(tmp);
4600 tmp = NULL;
4601 } else {
4602 msg = NULL;
4603 }
4604 *out = Assert(test, msg, lineno, col_offset, arena);
4605 if (*out == NULL) goto failed;
4606 return 0;
4607 }
4608 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type);
4609 if (isinstance == -1) {
4610 return 1;
4611 }
4612 if (isinstance) {
4613 asdl_seq* names;
4614
4615 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4616 int res;
4617 Py_ssize_t len;
4618 Py_ssize_t i;
4619 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4620 if (tmp == NULL) goto failed;
4621 if (!PyList_Check(tmp)) {
4622 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4623 goto failed;
4624 }
4625 len = PyList_GET_SIZE(tmp);
4626 names = asdl_seq_new(len, arena);
4627 if (names == NULL) goto failed;
4628 for (i = 0; i < len; i++) {
4629 alias_ty value;
4630 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
4631 if (res != 0) goto failed;
4632 asdl_seq_SET(names, i, value);
4633 }
4634 Py_XDECREF(tmp);
4635 tmp = NULL;
4636 } else {
4637 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
4638 return 1;
4639 }
4640 *out = Import(names, lineno, col_offset, arena);
4641 if (*out == NULL) goto failed;
4642 return 0;
4643 }
4644 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type);
4645 if (isinstance == -1) {
4646 return 1;
4647 }
4648 if (isinstance) {
4649 identifier module;
4650 asdl_seq* names;
4651 int level;
4652
4653 if (_PyObject_HasAttrId(obj, &PyId_module)) {
4654 int res;
4655 tmp = _PyObject_GetAttrId(obj, &PyId_module);
4656 if (tmp == NULL) goto failed;
4657 res = obj2ast_identifier(tmp, &module, arena);
4658 if (res != 0) goto failed;
4659 Py_XDECREF(tmp);
4660 tmp = NULL;
4661 } else {
4662 module = NULL;
4663 }
4664 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4665 int res;
4666 Py_ssize_t len;
4667 Py_ssize_t i;
4668 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4669 if (tmp == NULL) goto failed;
4670 if (!PyList_Check(tmp)) {
4671 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4672 goto failed;
4673 }
4674 len = PyList_GET_SIZE(tmp);
4675 names = asdl_seq_new(len, arena);
4676 if (names == NULL) goto failed;
4677 for (i = 0; i < len; i++) {
4678 alias_ty value;
4679 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
4680 if (res != 0) goto failed;
4681 asdl_seq_SET(names, i, value);
4682 }
4683 Py_XDECREF(tmp);
4684 tmp = NULL;
4685 } else {
4686 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
4687 return 1;
4688 }
4689 if (_PyObject_HasAttrId(obj, &PyId_level)) {
4690 int res;
4691 tmp = _PyObject_GetAttrId(obj, &PyId_level);
4692 if (tmp == NULL) goto failed;
4693 res = obj2ast_int(tmp, &level, arena);
4694 if (res != 0) goto failed;
4695 Py_XDECREF(tmp);
4696 tmp = NULL;
4697 } else {
4698 level = 0;
4699 }
4700 *out = ImportFrom(module, names, level, lineno, col_offset,
4701 arena);
4702 if (*out == NULL) goto failed;
4703 return 0;
4704 }
4705 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type);
4706 if (isinstance == -1) {
4707 return 1;
4708 }
4709 if (isinstance) {
4710 asdl_seq* names;
4711
4712 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4713 int res;
4714 Py_ssize_t len;
4715 Py_ssize_t i;
4716 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4717 if (tmp == NULL) goto failed;
4718 if (!PyList_Check(tmp)) {
4719 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4720 goto failed;
4721 }
4722 len = PyList_GET_SIZE(tmp);
4723 names = asdl_seq_new(len, arena);
4724 if (names == NULL) goto failed;
4725 for (i = 0; i < len; i++) {
4726 identifier value;
4727 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
4728 if (res != 0) goto failed;
4729 asdl_seq_SET(names, i, value);
4730 }
4731 Py_XDECREF(tmp);
4732 tmp = NULL;
4733 } else {
4734 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
4735 return 1;
4736 }
4737 *out = Global(names, lineno, col_offset, arena);
4738 if (*out == NULL) goto failed;
4739 return 0;
4740 }
4741 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type);
4742 if (isinstance == -1) {
4743 return 1;
4744 }
4745 if (isinstance) {
4746 asdl_seq* names;
4747
4748 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4749 int res;
4750 Py_ssize_t len;
4751 Py_ssize_t i;
4752 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4753 if (tmp == NULL) goto failed;
4754 if (!PyList_Check(tmp)) {
4755 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4756 goto failed;
4757 }
4758 len = PyList_GET_SIZE(tmp);
4759 names = asdl_seq_new(len, arena);
4760 if (names == NULL) goto failed;
4761 for (i = 0; i < len; i++) {
4762 identifier value;
4763 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
4764 if (res != 0) goto failed;
4765 asdl_seq_SET(names, i, value);
4766 }
4767 Py_XDECREF(tmp);
4768 tmp = NULL;
4769 } else {
4770 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
4771 return 1;
4772 }
4773 *out = Nonlocal(names, lineno, col_offset, arena);
4774 if (*out == NULL) goto failed;
4775 return 0;
4776 }
4777 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type);
4778 if (isinstance == -1) {
4779 return 1;
4780 }
4781 if (isinstance) {
4782 expr_ty value; 4038 expr_ty value;
4783 4039 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
4784 if (_PyObject_HasAttrId(obj, &PyId_value)) { 4040 if (res != 0) goto failed;
4785 int res; 4041 asdl_seq_SET(targets, i, value);
4786 tmp = _PyObject_GetAttrId(obj, &PyId_value); 4042 }
4787 if (tmp == NULL) goto failed; 4043 Py_XDECREF(tmp);
4788 res = obj2ast_expr(tmp, &value, arena); 4044 tmp = NULL;
4789 if (res != 0) goto failed; 4045 } else {
4790 Py_XDECREF(tmp); 4046 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
4791 tmp = NULL; 4047 return 1;
4792 } else { 4048 }
4793 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr"); 4049 if (_PyObject_HasAttrId(obj, &PyId_value)) {
4794 return 1; 4050 int res;
4795 } 4051 tmp = _PyObject_GetAttrId(obj, &PyId_value);
4796 *out = Expr(value, lineno, col_offset, arena); 4052 if (tmp == NULL) goto failed;
4797 if (*out == NULL) goto failed; 4053 res = obj2ast_expr(tmp, &value, arena);
4798 return 0; 4054 if (res != 0) goto failed;
4799 } 4055 Py_XDECREF(tmp);
4800 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); 4056 tmp = NULL;
4801 if (isinstance == -1) { 4057 } else {
4802 return 1; 4058 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
4803 } 4059 return 1;
4804 if (isinstance) { 4060 }
4805 4061 *out = Assign(targets, value, lineno, col_offset, arena);
4806 *out = Pass(lineno, col_offset, arena); 4062 if (*out == NULL) goto failed;
4807 if (*out == NULL) goto failed; 4063 return 0;
4808 return 0; 4064 }
4809 } 4065 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type);
4810 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); 4066 if (isinstance == -1) {
4811 if (isinstance == -1) { 4067 return 1;
4812 return 1; 4068 }
4813 } 4069 if (isinstance) {
4814 if (isinstance) { 4070 expr_ty target;
4815 4071 operator_ty op;
4816 *out = Break(lineno, col_offset, arena); 4072 expr_ty value;
4817 if (*out == NULL) goto failed; 4073
4818 return 0; 4074 if (_PyObject_HasAttrId(obj, &PyId_target)) {
4819 } 4075 int res;
4820 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); 4076 tmp = _PyObject_GetAttrId(obj, &PyId_target);
4821 if (isinstance == -1) { 4077 if (tmp == NULL) goto failed;
4822 return 1; 4078 res = obj2ast_expr(tmp, &target, arena);
4823 } 4079 if (res != 0) goto failed;
4824 if (isinstance) { 4080 Py_XDECREF(tmp);
4825 4081 tmp = NULL;
4826 *out = Continue(lineno, col_offset, arena); 4082 } else {
4827 if (*out == NULL) goto failed; 4083 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
4828 return 0; 4084 return 1;
4829 } 4085 }
4830 4086 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4831 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj); 4087 int res;
4832 failed: 4088 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4833 Py_XDECREF(tmp); 4089 if (tmp == NULL) goto failed;
4834 return 1; 4090 res = obj2ast_operator(tmp, &op, arena);
4091 if (res != 0) goto failed;
4092 Py_XDECREF(tmp);
4093 tmp = NULL;
4094 } else {
4095 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
4096 return 1;
4097 }
4098 if (_PyObject_HasAttrId(obj, &PyId_value)) {
4099 int res;
4100 tmp = _PyObject_GetAttrId(obj, &PyId_value);
4101 if (tmp == NULL) goto failed;
4102 res = obj2ast_expr(tmp, &value, arena);
4103 if (res != 0) goto failed;
4104 Py_XDECREF(tmp);
4105 tmp = NULL;
4106 } else {
4107 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
4108 return 1;
4109 }
4110 *out = AugAssign(target, op, value, lineno, col_offset, arena);
4111 if (*out == NULL) goto failed;
4112 return 0;
4113 }
4114 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type);
4115 if (isinstance == -1) {
4116 return 1;
4117 }
4118 if (isinstance) {
4119 expr_ty target;
4120 expr_ty iter;
4121 asdl_seq* body;
4122 asdl_seq* orelse;
4123
4124 if (_PyObject_HasAttrId(obj, &PyId_target)) {
4125 int res;
4126 tmp = _PyObject_GetAttrId(obj, &PyId_target);
4127 if (tmp == NULL) goto failed;
4128 res = obj2ast_expr(tmp, &target, arena);
4129 if (res != 0) goto failed;
4130 Py_XDECREF(tmp);
4131 tmp = NULL;
4132 } else {
4133 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
4134 return 1;
4135 }
4136 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
4137 int res;
4138 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
4139 if (tmp == NULL) goto failed;
4140 res = obj2ast_expr(tmp, &iter, arena);
4141 if (res != 0) goto failed;
4142 Py_XDECREF(tmp);
4143 tmp = NULL;
4144 } else {
4145 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
4146 return 1;
4147 }
4148 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4149 int res;
4150 Py_ssize_t len;
4151 Py_ssize_t i;
4152 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4153 if (tmp == NULL) goto failed;
4154 if (!PyList_Check(tmp)) {
4155 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4156 goto failed;
4157 }
4158 len = PyList_GET_SIZE(tmp);
4159 body = asdl_seq_new(len, arena);
4160 if (body == NULL) goto failed;
4161 for (i = 0; i < len; i++) {
4162 stmt_ty value;
4163 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4164 if (res != 0) goto failed;
4165 asdl_seq_SET(body, i, value);
4166 }
4167 Py_XDECREF(tmp);
4168 tmp = NULL;
4169 } else {
4170 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
4171 return 1;
4172 }
4173 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4174 int res;
4175 Py_ssize_t len;
4176 Py_ssize_t i;
4177 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4178 if (tmp == NULL) goto failed;
4179 if (!PyList_Check(tmp)) {
4180 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4181 goto failed;
4182 }
4183 len = PyList_GET_SIZE(tmp);
4184 orelse = asdl_seq_new(len, arena);
4185 if (orelse == NULL) goto failed;
4186 for (i = 0; i < len; i++) {
4187 stmt_ty value;
4188 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4189 if (res != 0) goto failed;
4190 asdl_seq_SET(orelse, i, value);
4191 }
4192 Py_XDECREF(tmp);
4193 tmp = NULL;
4194 } else {
4195 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
4196 return 1;
4197 }
4198 *out = For(target, iter, body, orelse, lineno, col_offset, arena);
4199 if (*out == NULL) goto failed;
4200 return 0;
4201 }
4202 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type);
4203 if (isinstance == -1) {
4204 return 1;
4205 }
4206 if (isinstance) {
4207 expr_ty test;
4208 asdl_seq* body;
4209 asdl_seq* orelse;
4210
4211 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4212 int res;
4213 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4214 if (tmp == NULL) goto failed;
4215 res = obj2ast_expr(tmp, &test, arena);
4216 if (res != 0) goto failed;
4217 Py_XDECREF(tmp);
4218 tmp = NULL;
4219 } else {
4220 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
4221 return 1;
4222 }
4223 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4224 int res;
4225 Py_ssize_t len;
4226 Py_ssize_t i;
4227 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4228 if (tmp == NULL) goto failed;
4229 if (!PyList_Check(tmp)) {
4230 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4231 goto failed;
4232 }
4233 len = PyList_GET_SIZE(tmp);
4234 body = asdl_seq_new(len, arena);
4235 if (body == NULL) goto failed;
4236 for (i = 0; i < len; i++) {
4237 stmt_ty value;
4238 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4239 if (res != 0) goto failed;
4240 asdl_seq_SET(body, i, value);
4241 }
4242 Py_XDECREF(tmp);
4243 tmp = NULL;
4244 } else {
4245 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
4246 return 1;
4247 }
4248 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4249 int res;
4250 Py_ssize_t len;
4251 Py_ssize_t i;
4252 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4253 if (tmp == NULL) goto failed;
4254 if (!PyList_Check(tmp)) {
4255 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4256 goto failed;
4257 }
4258 len = PyList_GET_SIZE(tmp);
4259 orelse = asdl_seq_new(len, arena);
4260 if (orelse == NULL) goto failed;
4261 for (i = 0; i < len; i++) {
4262 stmt_ty value;
4263 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4264 if (res != 0) goto failed;
4265 asdl_seq_SET(orelse, i, value);
4266 }
4267 Py_XDECREF(tmp);
4268 tmp = NULL;
4269 } else {
4270 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
4271 return 1;
4272 }
4273 *out = While(test, body, orelse, lineno, col_offset, arena);
4274 if (*out == NULL) goto failed;
4275 return 0;
4276 }
4277 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type);
4278 if (isinstance == -1) {
4279 return 1;
4280 }
4281 if (isinstance) {
4282 expr_ty test;
4283 asdl_seq* body;
4284 asdl_seq* orelse;
4285
4286 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4287 int res;
4288 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4289 if (tmp == NULL) goto failed;
4290 res = obj2ast_expr(tmp, &test, arena);
4291 if (res != 0) goto failed;
4292 Py_XDECREF(tmp);
4293 tmp = NULL;
4294 } else {
4295 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
4296 return 1;
4297 }
4298 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4299 int res;
4300 Py_ssize_t len;
4301 Py_ssize_t i;
4302 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4303 if (tmp == NULL) goto failed;
4304 if (!PyList_Check(tmp)) {
4305 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4306 goto failed;
4307 }
4308 len = PyList_GET_SIZE(tmp);
4309 body = asdl_seq_new(len, arena);
4310 if (body == NULL) goto failed;
4311 for (i = 0; i < len; i++) {
4312 stmt_ty value;
4313 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4314 if (res != 0) goto failed;
4315 asdl_seq_SET(body, i, value);
4316 }
4317 Py_XDECREF(tmp);
4318 tmp = NULL;
4319 } else {
4320 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
4321 return 1;
4322 }
4323 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4324 int res;
4325 Py_ssize_t len;
4326 Py_ssize_t i;
4327 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4328 if (tmp == NULL) goto failed;
4329 if (!PyList_Check(tmp)) {
4330 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4331 goto failed;
4332 }
4333 len = PyList_GET_SIZE(tmp);
4334 orelse = asdl_seq_new(len, arena);
4335 if (orelse == NULL) goto failed;
4336 for (i = 0; i < len; i++) {
4337 stmt_ty value;
4338 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4339 if (res != 0) goto failed;
4340 asdl_seq_SET(orelse, i, value);
4341 }
4342 Py_XDECREF(tmp);
4343 tmp = NULL;
4344 } else {
4345 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
4346 return 1;
4347 }
4348 *out = If(test, body, orelse, lineno, col_offset, arena);
4349 if (*out == NULL) goto failed;
4350 return 0;
4351 }
4352 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type);
4353 if (isinstance == -1) {
4354 return 1;
4355 }
4356 if (isinstance) {
4357 asdl_seq* items;
4358 asdl_seq* body;
4359
4360 if (_PyObject_HasAttrId(obj, &PyId_items)) {
4361 int res;
4362 Py_ssize_t len;
4363 Py_ssize_t i;
4364 tmp = _PyObject_GetAttrId(obj, &PyId_items);
4365 if (tmp == NULL) goto failed;
4366 if (!PyList_Check(tmp)) {
4367 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4368 goto failed;
4369 }
4370 len = PyList_GET_SIZE(tmp);
4371 items = asdl_seq_new(len, arena);
4372 if (items == NULL) goto failed;
4373 for (i = 0; i < len; i++) {
4374 withitem_ty value;
4375 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
4376 if (res != 0) goto failed;
4377 asdl_seq_SET(items, i, value);
4378 }
4379 Py_XDECREF(tmp);
4380 tmp = NULL;
4381 } else {
4382 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
4383 return 1;
4384 }
4385 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4386 int res;
4387 Py_ssize_t len;
4388 Py_ssize_t i;
4389 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4390 if (tmp == NULL) goto failed;
4391 if (!PyList_Check(tmp)) {
4392 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4393 goto failed;
4394 }
4395 len = PyList_GET_SIZE(tmp);
4396 body = asdl_seq_new(len, arena);
4397 if (body == NULL) goto failed;
4398 for (i = 0; i < len; i++) {
4399 stmt_ty value;
4400 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4401 if (res != 0) goto failed;
4402 asdl_seq_SET(body, i, value);
4403 }
4404 Py_XDECREF(tmp);
4405 tmp = NULL;
4406 } else {
4407 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
4408 return 1;
4409 }
4410 *out = With(items, body, lineno, col_offset, arena);
4411 if (*out == NULL) goto failed;
4412 return 0;
4413 }
4414 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type);
4415 if (isinstance == -1) {
4416 return 1;
4417 }
4418 if (isinstance) {
4419 expr_ty exc;
4420 expr_ty cause;
4421
4422 if (_PyObject_HasAttrId(obj, &PyId_exc)) {
4423 int res;
4424 tmp = _PyObject_GetAttrId(obj, &PyId_exc);
4425 if (tmp == NULL) goto failed;
4426 res = obj2ast_expr(tmp, &exc, arena);
4427 if (res != 0) goto failed;
4428 Py_XDECREF(tmp);
4429 tmp = NULL;
4430 } else {
4431 exc = NULL;
4432 }
4433 if (_PyObject_HasAttrId(obj, &PyId_cause)) {
4434 int res;
4435 tmp = _PyObject_GetAttrId(obj, &PyId_cause);
4436 if (tmp == NULL) goto failed;
4437 res = obj2ast_expr(tmp, &cause, arena);
4438 if (res != 0) goto failed;
4439 Py_XDECREF(tmp);
4440 tmp = NULL;
4441 } else {
4442 cause = NULL;
4443 }
4444 *out = Raise(exc, cause, lineno, col_offset, arena);
4445 if (*out == NULL) goto failed;
4446 return 0;
4447 }
4448 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type);
4449 if (isinstance == -1) {
4450 return 1;
4451 }
4452 if (isinstance) {
4453 asdl_seq* body;
4454 asdl_seq* handlers;
4455 asdl_seq* orelse;
4456 asdl_seq* finalbody;
4457
4458 if (_PyObject_HasAttrId(obj, &PyId_body)) {
4459 int res;
4460 Py_ssize_t len;
4461 Py_ssize_t i;
4462 tmp = _PyObject_GetAttrId(obj, &PyId_body);
4463 if (tmp == NULL) goto failed;
4464 if (!PyList_Check(tmp)) {
4465 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4466 goto failed;
4467 }
4468 len = PyList_GET_SIZE(tmp);
4469 body = asdl_seq_new(len, arena);
4470 if (body == NULL) goto failed;
4471 for (i = 0; i < len; i++) {
4472 stmt_ty value;
4473 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4474 if (res != 0) goto failed;
4475 asdl_seq_SET(body, i, value);
4476 }
4477 Py_XDECREF(tmp);
4478 tmp = NULL;
4479 } else {
4480 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
4481 return 1;
4482 }
4483 if (_PyObject_HasAttrId(obj, &PyId_handlers)) {
4484 int res;
4485 Py_ssize_t len;
4486 Py_ssize_t i;
4487 tmp = _PyObject_GetAttrId(obj, &PyId_handlers);
4488 if (tmp == NULL) goto failed;
4489 if (!PyList_Check(tmp)) {
4490 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4491 goto failed;
4492 }
4493 len = PyList_GET_SIZE(tmp);
4494 handlers = asdl_seq_new(len, arena);
4495 if (handlers == NULL) goto failed;
4496 for (i = 0; i < len; i++) {
4497 excepthandler_ty value;
4498 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena);
4499 if (res != 0) goto failed;
4500 asdl_seq_SET(handlers, i, value);
4501 }
4502 Py_XDECREF(tmp);
4503 tmp = NULL;
4504 } else {
4505 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
4506 return 1;
4507 }
4508 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
4509 int res;
4510 Py_ssize_t len;
4511 Py_ssize_t i;
4512 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
4513 if (tmp == NULL) goto failed;
4514 if (!PyList_Check(tmp)) {
4515 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4516 goto failed;
4517 }
4518 len = PyList_GET_SIZE(tmp);
4519 orelse = asdl_seq_new(len, arena);
4520 if (orelse == NULL) goto failed;
4521 for (i = 0; i < len; i++) {
4522 stmt_ty value;
4523 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4524 if (res != 0) goto failed;
4525 asdl_seq_SET(orelse, i, value);
4526 }
4527 Py_XDECREF(tmp);
4528 tmp = NULL;
4529 } else {
4530 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
4531 return 1;
4532 }
4533 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) {
4534 int res;
4535 Py_ssize_t len;
4536 Py_ssize_t i;
4537 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody);
4538 if (tmp == NULL) goto failed;
4539 if (!PyList_Check(tmp)) {
4540 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4541 goto failed;
4542 }
4543 len = PyList_GET_SIZE(tmp);
4544 finalbody = asdl_seq_new(len, arena);
4545 if (finalbody == NULL) goto failed;
4546 for (i = 0; i < len; i++) {
4547 stmt_ty value;
4548 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
4549 if (res != 0) goto failed;
4550 asdl_seq_SET(finalbody, i, value);
4551 }
4552 Py_XDECREF(tmp);
4553 tmp = NULL;
4554 } else {
4555 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
4556 return 1;
4557 }
4558 *out = Try(body, handlers, orelse, finalbody, lineno, col_offset,
4559 arena);
4560 if (*out == NULL) goto failed;
4561 return 0;
4562 }
4563 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type);
4564 if (isinstance == -1) {
4565 return 1;
4566 }
4567 if (isinstance) {
4568 expr_ty test;
4569 expr_ty msg;
4570
4571 if (_PyObject_HasAttrId(obj, &PyId_test)) {
4572 int res;
4573 tmp = _PyObject_GetAttrId(obj, &PyId_test);
4574 if (tmp == NULL) goto failed;
4575 res = obj2ast_expr(tmp, &test, arena);
4576 if (res != 0) goto failed;
4577 Py_XDECREF(tmp);
4578 tmp = NULL;
4579 } else {
4580 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
4581 return 1;
4582 }
4583 if (_PyObject_HasAttrId(obj, &PyId_msg)) {
4584 int res;
4585 tmp = _PyObject_GetAttrId(obj, &PyId_msg);
4586 if (tmp == NULL) goto failed;
4587 res = obj2ast_expr(tmp, &msg, arena);
4588 if (res != 0) goto failed;
4589 Py_XDECREF(tmp);
4590 tmp = NULL;
4591 } else {
4592 msg = NULL;
4593 }
4594 *out = Assert(test, msg, lineno, col_offset, arena);
4595 if (*out == NULL) goto failed;
4596 return 0;
4597 }
4598 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type);
4599 if (isinstance == -1) {
4600 return 1;
4601 }
4602 if (isinstance) {
4603 asdl_seq* names;
4604
4605 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4606 int res;
4607 Py_ssize_t len;
4608 Py_ssize_t i;
4609 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4610 if (tmp == NULL) goto failed;
4611 if (!PyList_Check(tmp)) {
4612 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4613 goto failed;
4614 }
4615 len = PyList_GET_SIZE(tmp);
4616 names = asdl_seq_new(len, arena);
4617 if (names == NULL) goto failed;
4618 for (i = 0; i < len; i++) {
4619 alias_ty value;
4620 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
4621 if (res != 0) goto failed;
4622 asdl_seq_SET(names, i, value);
4623 }
4624 Py_XDECREF(tmp);
4625 tmp = NULL;
4626 } else {
4627 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
4628 return 1;
4629 }
4630 *out = Import(names, lineno, col_offset, arena);
4631 if (*out == NULL) goto failed;
4632 return 0;
4633 }
4634 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type);
4635 if (isinstance == -1) {
4636 return 1;
4637 }
4638 if (isinstance) {
4639 identifier module;
4640 asdl_seq* names;
4641 int level;
4642
4643 if (_PyObject_HasAttrId(obj, &PyId_module)) {
4644 int res;
4645 tmp = _PyObject_GetAttrId(obj, &PyId_module);
4646 if (tmp == NULL) goto failed;
4647 res = obj2ast_identifier(tmp, &module, arena);
4648 if (res != 0) goto failed;
4649 Py_XDECREF(tmp);
4650 tmp = NULL;
4651 } else {
4652 module = NULL;
4653 }
4654 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4655 int res;
4656 Py_ssize_t len;
4657 Py_ssize_t i;
4658 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4659 if (tmp == NULL) goto failed;
4660 if (!PyList_Check(tmp)) {
4661 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4662 goto failed;
4663 }
4664 len = PyList_GET_SIZE(tmp);
4665 names = asdl_seq_new(len, arena);
4666 if (names == NULL) goto failed;
4667 for (i = 0; i < len; i++) {
4668 alias_ty value;
4669 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
4670 if (res != 0) goto failed;
4671 asdl_seq_SET(names, i, value);
4672 }
4673 Py_XDECREF(tmp);
4674 tmp = NULL;
4675 } else {
4676 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
4677 return 1;
4678 }
4679 if (_PyObject_HasAttrId(obj, &PyId_level)) {
4680 int res;
4681 tmp = _PyObject_GetAttrId(obj, &PyId_level);
4682 if (tmp == NULL) goto failed;
4683 res = obj2ast_int(tmp, &level, arena);
4684 if (res != 0) goto failed;
4685 Py_XDECREF(tmp);
4686 tmp = NULL;
4687 } else {
4688 level = 0;
4689 }
4690 *out = ImportFrom(module, names, level, lineno, col_offset, arena);
4691 if (*out == NULL) goto failed;
4692 return 0;
4693 }
4694 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type);
4695 if (isinstance == -1) {
4696 return 1;
4697 }
4698 if (isinstance) {
4699 asdl_seq* names;
4700
4701 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4702 int res;
4703 Py_ssize_t len;
4704 Py_ssize_t i;
4705 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4706 if (tmp == NULL) goto failed;
4707 if (!PyList_Check(tmp)) {
4708 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4709 goto failed;
4710 }
4711 len = PyList_GET_SIZE(tmp);
4712 names = asdl_seq_new(len, arena);
4713 if (names == NULL) goto failed;
4714 for (i = 0; i < len; i++) {
4715 identifier value;
4716 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
4717 if (res != 0) goto failed;
4718 asdl_seq_SET(names, i, value);
4719 }
4720 Py_XDECREF(tmp);
4721 tmp = NULL;
4722 } else {
4723 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
4724 return 1;
4725 }
4726 *out = Global(names, lineno, col_offset, arena);
4727 if (*out == NULL) goto failed;
4728 return 0;
4729 }
4730 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type);
4731 if (isinstance == -1) {
4732 return 1;
4733 }
4734 if (isinstance) {
4735 asdl_seq* names;
4736
4737 if (_PyObject_HasAttrId(obj, &PyId_names)) {
4738 int res;
4739 Py_ssize_t len;
4740 Py_ssize_t i;
4741 tmp = _PyObject_GetAttrId(obj, &PyId_names);
4742 if (tmp == NULL) goto failed;
4743 if (!PyList_Check(tmp)) {
4744 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4745 goto failed;
4746 }
4747 len = PyList_GET_SIZE(tmp);
4748 names = asdl_seq_new(len, arena);
4749 if (names == NULL) goto failed;
4750 for (i = 0; i < len; i++) {
4751 identifier value;
4752 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
4753 if (res != 0) goto failed;
4754 asdl_seq_SET(names, i, value);
4755 }
4756 Py_XDECREF(tmp);
4757 tmp = NULL;
4758 } else {
4759 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
4760 return 1;
4761 }
4762 *out = Nonlocal(names, lineno, col_offset, arena);
4763 if (*out == NULL) goto failed;
4764 return 0;
4765 }
4766 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type);
4767 if (isinstance == -1) {
4768 return 1;
4769 }
4770 if (isinstance) {
4771 expr_ty value;
4772
4773 if (_PyObject_HasAttrId(obj, &PyId_value)) {
4774 int res;
4775 tmp = _PyObject_GetAttrId(obj, &PyId_value);
4776 if (tmp == NULL) goto failed;
4777 res = obj2ast_expr(tmp, &value, arena);
4778 if (res != 0) goto failed;
4779 Py_XDECREF(tmp);
4780 tmp = NULL;
4781 } else {
4782 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
4783 return 1;
4784 }
4785 *out = Expr(value, lineno, col_offset, arena);
4786 if (*out == NULL) goto failed;
4787 return 0;
4788 }
4789 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type);
4790 if (isinstance == -1) {
4791 return 1;
4792 }
4793 if (isinstance) {
4794
4795 *out = Pass(lineno, col_offset, arena);
4796 if (*out == NULL) goto failed;
4797 return 0;
4798 }
4799 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type);
4800 if (isinstance == -1) {
4801 return 1;
4802 }
4803 if (isinstance) {
4804
4805 *out = Break(lineno, col_offset, arena);
4806 if (*out == NULL) goto failed;
4807 return 0;
4808 }
4809 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type);
4810 if (isinstance == -1) {
4811 return 1;
4812 }
4813 if (isinstance) {
4814
4815 *out = Continue(lineno, col_offset, arena);
4816 if (*out == NULL) goto failed;
4817 return 0;
4818 }
4819
4820 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
4821 failed:
4822 Py_XDECREF(tmp);
4823 return 1;
4835 } 4824 }
4836 4825
4837 int 4826 int
4838 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) 4827 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
4839 { 4828 {
4840 int isinstance; 4829 int isinstance;
4841 4830
4842 PyObject *tmp = NULL; 4831 PyObject *tmp = NULL;
4843 int lineno; 4832 int lineno;
4844 int col_offset; 4833 int col_offset;
4845 4834
4846 if (obj == Py_None) { 4835 if (obj == Py_None) {
4847 *out = NULL; 4836 *out = NULL;
4848 return 0; 4837 return 0;
4849 } 4838 }
4850 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { 4839 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
4851 int res; 4840 int res;
4852 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); 4841 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
4853 if (tmp == NULL) goto failed; 4842 if (tmp == NULL) goto failed;
4854 res = obj2ast_int(tmp, &lineno, arena); 4843 res = obj2ast_int(tmp, &lineno, arena);
4844 if (res != 0) goto failed;
4845 Py_XDECREF(tmp);
4846 tmp = NULL;
4847 } else {
4848 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
4849 return 1;
4850 }
4851 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
4852 int res;
4853 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
4854 if (tmp == NULL) goto failed;
4855 res = obj2ast_int(tmp, &col_offset, arena);
4856 if (res != 0) goto failed;
4857 Py_XDECREF(tmp);
4858 tmp = NULL;
4859 } else {
4860 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
4861 return 1;
4862 }
4863 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type);
4864 if (isinstance == -1) {
4865 return 1;
4866 }
4867 if (isinstance) {
4868 boolop_ty op;
4869 asdl_seq* values;
4870
4871 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4872 int res;
4873 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4874 if (tmp == NULL) goto failed;
4875 res = obj2ast_boolop(tmp, &op, arena);
4876 if (res != 0) goto failed;
4877 Py_XDECREF(tmp);
4878 tmp = NULL;
4879 } else {
4880 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
4881 return 1;
4882 }
4883 if (_PyObject_HasAttrId(obj, &PyId_values)) {
4884 int res;
4885 Py_ssize_t len;
4886 Py_ssize_t i;
4887 tmp = _PyObject_GetAttrId(obj, &PyId_values);
4888 if (tmp == NULL) goto failed;
4889 if (!PyList_Check(tmp)) {
4890 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4891 goto failed;
4892 }
4893 len = PyList_GET_SIZE(tmp);
4894 values = asdl_seq_new(len, arena);
4895 if (values == NULL) goto failed;
4896 for (i = 0; i < len; i++) {
4897 expr_ty value;
4898 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
4855 if (res != 0) goto failed; 4899 if (res != 0) goto failed;
4856 Py_XDECREF(tmp); 4900 asdl_seq_SET(values, i, value);
4857 tmp = NULL; 4901 }
4858 } else { 4902 Py_XDECREF(tmp);
4859 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr"); 4903 tmp = NULL;
4860 return 1; 4904 } else {
4861 } 4905 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
4862 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { 4906 return 1;
4863 int res; 4907 }
4864 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); 4908 *out = BoolOp(op, values, lineno, col_offset, arena);
4865 if (tmp == NULL) goto failed; 4909 if (*out == NULL) goto failed;
4866 res = obj2ast_int(tmp, &col_offset, arena); 4910 return 0;
4911 }
4912 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type);
4913 if (isinstance == -1) {
4914 return 1;
4915 }
4916 if (isinstance) {
4917 expr_ty left;
4918 operator_ty op;
4919 expr_ty right;
4920
4921 if (_PyObject_HasAttrId(obj, &PyId_left)) {
4922 int res;
4923 tmp = _PyObject_GetAttrId(obj, &PyId_left);
4924 if (tmp == NULL) goto failed;
4925 res = obj2ast_expr(tmp, &left, arena);
4926 if (res != 0) goto failed;
4927 Py_XDECREF(tmp);
4928 tmp = NULL;
4929 } else {
4930 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
4931 return 1;
4932 }
4933 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4934 int res;
4935 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4936 if (tmp == NULL) goto failed;
4937 res = obj2ast_operator(tmp, &op, arena);
4938 if (res != 0) goto failed;
4939 Py_XDECREF(tmp);
4940 tmp = NULL;
4941 } else {
4942 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
4943 return 1;
4944 }
4945 if (_PyObject_HasAttrId(obj, &PyId_right)) {
4946 int res;
4947 tmp = _PyObject_GetAttrId(obj, &PyId_right);
4948 if (tmp == NULL) goto failed;
4949 res = obj2ast_expr(tmp, &right, arena);
4950 if (res != 0) goto failed;
4951 Py_XDECREF(tmp);
4952 tmp = NULL;
4953 } else {
4954 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
4955 return 1;
4956 }
4957 *out = BinOp(left, op, right, lineno, col_offset, arena);
4958 if (*out == NULL) goto failed;
4959 return 0;
4960 }
4961 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type);
4962 if (isinstance == -1) {
4963 return 1;
4964 }
4965 if (isinstance) {
4966 unaryop_ty op;
4967 expr_ty operand;
4968
4969 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4970 int res;
4971 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4972 if (tmp == NULL) goto failed;
4973 res = obj2ast_unaryop(tmp, &op, arena);
4974 if (res != 0) goto failed;
4975 Py_XDECREF(tmp);
4976 tmp = NULL;
4977 } else {
4978 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
4979 return 1;
4980 }
4981 if (_PyObject_HasAttrId(obj, &PyId_operand)) {
4982 int res;
4983 tmp = _PyObject_GetAttrId(obj, &PyId_operand);
4984 if (tmp == NULL) goto failed;
4985 res = obj2ast_expr(tmp, &operand, arena);
4986 if (res != 0) goto failed;
4987 Py_XDECREF(tmp);
4988 tmp = NULL;
4989 } else {
4990 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
4991 return 1;
4992 }
4993 *out = UnaryOp(op, operand, lineno, col_offset, arena);
4994 if (*out == NULL) goto failed;
4995 return 0;
4996 }
4997 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type);
4998 if (isinstance == -1) {
4999 return 1;
5000 }
5001 if (isinstance) {
5002 arguments_ty args;
5003 expr_ty body;
5004
5005 if (_PyObject_HasAttrId(obj, &PyId_args)) {
5006 int res;
5007 tmp = _PyObject_GetAttrId(obj, &PyId_args);
5008 if (tmp == NULL) goto failed;
5009 res = obj2ast_arguments(tmp, &args, arena);
5010 if (res != 0) goto failed;
5011 Py_XDECREF(tmp);
5012 tmp = NULL;
5013 } else {
5014 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
5015 return 1;
5016 }
5017 if (_PyObject_HasAttrId(obj, &PyId_body)) {
5018 int res;
5019 tmp = _PyObject_GetAttrId(obj, &PyId_body);
5020 if (tmp == NULL) goto failed;
5021 res = obj2ast_expr(tmp, &body, arena);
5022 if (res != 0) goto failed;
5023 Py_XDECREF(tmp);
5024 tmp = NULL;
5025 } else {
5026 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
5027 return 1;
5028 }
5029 *out = Lambda(args, body, lineno, col_offset, arena);
5030 if (*out == NULL) goto failed;
5031 return 0;
5032 }
5033 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type);
5034 if (isinstance == -1) {
5035 return 1;
5036 }
5037 if (isinstance) {
5038 expr_ty test;
5039 expr_ty body;
5040 expr_ty orelse;
5041
5042 if (_PyObject_HasAttrId(obj, &PyId_test)) {
5043 int res;
5044 tmp = _PyObject_GetAttrId(obj, &PyId_test);
5045 if (tmp == NULL) goto failed;
5046 res = obj2ast_expr(tmp, &test, arena);
5047 if (res != 0) goto failed;
5048 Py_XDECREF(tmp);
5049 tmp = NULL;
5050 } else {
5051 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
5052 return 1;
5053 }
5054 if (_PyObject_HasAttrId(obj, &PyId_body)) {
5055 int res;
5056 tmp = _PyObject_GetAttrId(obj, &PyId_body);
5057 if (tmp == NULL) goto failed;
5058 res = obj2ast_expr(tmp, &body, arena);
5059 if (res != 0) goto failed;
5060 Py_XDECREF(tmp);
5061 tmp = NULL;
5062 } else {
5063 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
5064 return 1;
5065 }
5066 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
5067 int res;
5068 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
5069 if (tmp == NULL) goto failed;
5070 res = obj2ast_expr(tmp, &orelse, arena);
5071 if (res != 0) goto failed;
5072 Py_XDECREF(tmp);
5073 tmp = NULL;
5074 } else {
5075 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
5076 return 1;
5077 }
5078 *out = IfExp(test, body, orelse, lineno, col_offset, arena);
5079 if (*out == NULL) goto failed;
5080 return 0;
5081 }
5082 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type);
5083 if (isinstance == -1) {
5084 return 1;
5085 }
5086 if (isinstance) {
5087 asdl_seq* keys;
5088 asdl_seq* values;
5089
5090 if (_PyObject_HasAttrId(obj, &PyId_keys)) {
5091 int res;
5092 Py_ssize_t len;
5093 Py_ssize_t i;
5094 tmp = _PyObject_GetAttrId(obj, &PyId_keys);
5095 if (tmp == NULL) goto failed;
5096 if (!PyList_Check(tmp)) {
5097 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5098 goto failed;
5099 }
5100 len = PyList_GET_SIZE(tmp);
5101 keys = asdl_seq_new(len, arena);
5102 if (keys == NULL) goto failed;
5103 for (i = 0; i < len; i++) {
5104 expr_ty value;
5105 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
4867 if (res != 0) goto failed; 5106 if (res != 0) goto failed;
4868 Py_XDECREF(tmp); 5107 asdl_seq_SET(keys, i, value);
4869 tmp = NULL; 5108 }
4870 } else { 5109 Py_XDECREF(tmp);
4871 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); 5110 tmp = NULL;
4872 return 1; 5111 } else {
4873 } 5112 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
4874 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); 5113 return 1;
4875 if (isinstance == -1) { 5114 }
4876 return 1; 5115 if (_PyObject_HasAttrId(obj, &PyId_values)) {
4877 } 5116 int res;
4878 if (isinstance) { 5117 Py_ssize_t len;
4879 boolop_ty op; 5118 Py_ssize_t i;
4880 asdl_seq* values; 5119 tmp = _PyObject_GetAttrId(obj, &PyId_values);
4881 5120 if (tmp == NULL) goto failed;
4882 if (_PyObject_HasAttrId(obj, &PyId_op)) { 5121 if (!PyList_Check(tmp)) {
4883 int res; 5122 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4884 tmp = _PyObject_GetAttrId(obj, &PyId_op); 5123 goto failed;
4885 if (tmp == NULL) goto failed; 5124 }
4886 res = obj2ast_boolop(tmp, &op, arena); 5125 len = PyList_GET_SIZE(tmp);
4887 if (res != 0) goto failed; 5126 values = asdl_seq_new(len, arena);
4888 Py_XDECREF(tmp); 5127 if (values == NULL) goto failed;
4889 tmp = NULL; 5128 for (i = 0; i < len; i++) {
4890 } else {
4891 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
4892 return 1;
4893 }
4894 if (_PyObject_HasAttrId(obj, &PyId_values)) {
4895 int res;
4896 Py_ssize_t len;
4897 Py_ssize_t i;
4898 tmp = _PyObject_GetAttrId(obj, &PyId_values);
4899 if (tmp == NULL) goto failed;
4900 if (!PyList_Check(tmp)) {
4901 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
4902 goto failed;
4903 }
4904 len = PyList_GET_SIZE(tmp);
4905 values = asdl_seq_new(len, arena);
4906 if (values == NULL) goto failed;
4907 for (i = 0; i < len; i++) {
4908 expr_ty value;
4909 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
4910 if (res != 0) goto failed;
4911 asdl_seq_SET(values, i, value);
4912 }
4913 Py_XDECREF(tmp);
4914 tmp = NULL;
4915 } else {
4916 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
4917 return 1;
4918 }
4919 *out = BoolOp(op, values, lineno, col_offset, arena);
4920 if (*out == NULL) goto failed;
4921 return 0;
4922 }
4923 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type);
4924 if (isinstance == -1) {
4925 return 1;
4926 }
4927 if (isinstance) {
4928 expr_ty left;
4929 operator_ty op;
4930 expr_ty right;
4931
4932 if (_PyObject_HasAttrId(obj, &PyId_left)) {
4933 int res;
4934 tmp = _PyObject_GetAttrId(obj, &PyId_left);
4935 if (tmp == NULL) goto failed;
4936 res = obj2ast_expr(tmp, &left, arena);
4937 if (res != 0) goto failed;
4938 Py_XDECREF(tmp);
4939 tmp = NULL;
4940 } else {
4941 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
4942 return 1;
4943 }
4944 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4945 int res;
4946 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4947 if (tmp == NULL) goto failed;
4948 res = obj2ast_operator(tmp, &op, arena);
4949 if (res != 0) goto failed;
4950 Py_XDECREF(tmp);
4951 tmp = NULL;
4952 } else {
4953 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
4954 return 1;
4955 }
4956 if (_PyObject_HasAttrId(obj, &PyId_right)) {
4957 int res;
4958 tmp = _PyObject_GetAttrId(obj, &PyId_right);
4959 if (tmp == NULL) goto failed;
4960 res = obj2ast_expr(tmp, &right, arena);
4961 if (res != 0) goto failed;
4962 Py_XDECREF(tmp);
4963 tmp = NULL;
4964 } else {
4965 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
4966 return 1;
4967 }
4968 *out = BinOp(left, op, right, lineno, col_offset, arena);
4969 if (*out == NULL) goto failed;
4970 return 0;
4971 }
4972 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type);
4973 if (isinstance == -1) {
4974 return 1;
4975 }
4976 if (isinstance) {
4977 unaryop_ty op;
4978 expr_ty operand;
4979
4980 if (_PyObject_HasAttrId(obj, &PyId_op)) {
4981 int res;
4982 tmp = _PyObject_GetAttrId(obj, &PyId_op);
4983 if (tmp == NULL) goto failed;
4984 res = obj2ast_unaryop(tmp, &op, arena);
4985 if (res != 0) goto failed;
4986 Py_XDECREF(tmp);
4987 tmp = NULL;
4988 } else {
4989 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
4990 return 1;
4991 }
4992 if (_PyObject_HasAttrId(obj, &PyId_operand)) {
4993 int res;
4994 tmp = _PyObject_GetAttrId(obj, &PyId_operand);
4995 if (tmp == NULL) goto failed;
4996 res = obj2ast_expr(tmp, &operand, arena);
4997 if (res != 0) goto failed;
4998 Py_XDECREF(tmp);
4999 tmp = NULL;
5000 } else {
5001 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
5002 return 1;
5003 }
5004 *out = UnaryOp(op, operand, lineno, col_offset, arena);
5005 if (*out == NULL) goto failed;
5006 return 0;
5007 }
5008 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type);
5009 if (isinstance == -1) {
5010 return 1;
5011 }
5012 if (isinstance) {
5013 arguments_ty args;
5014 expr_ty body;
5015
5016 if (_PyObject_HasAttrId(obj, &PyId_args)) {
5017 int res;
5018 tmp = _PyObject_GetAttrId(obj, &PyId_args);
5019 if (tmp == NULL) goto failed;
5020 res = obj2ast_arguments(tmp, &args, arena);
5021 if (res != 0) goto failed;
5022 Py_XDECREF(tmp);
5023 tmp = NULL;
5024 } else {
5025 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
5026 return 1;
5027 }
5028 if (_PyObject_HasAttrId(obj, &PyId_body)) {
5029 int res;
5030 tmp = _PyObject_GetAttrId(obj, &PyId_body);
5031 if (tmp == NULL) goto failed;
5032 res = obj2ast_expr(tmp, &body, arena);
5033 if (res != 0) goto failed;
5034 Py_XDECREF(tmp);
5035 tmp = NULL;
5036 } else {
5037 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
5038 return 1;
5039 }
5040 *out = Lambda(args, body, lineno, col_offset, arena);
5041 if (*out == NULL) goto failed;
5042 return 0;
5043 }
5044 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type);
5045 if (isinstance == -1) {
5046 return 1;
5047 }
5048 if (isinstance) {
5049 expr_ty test;
5050 expr_ty body;
5051 expr_ty orelse;
5052
5053 if (_PyObject_HasAttrId(obj, &PyId_test)) {
5054 int res;
5055 tmp = _PyObject_GetAttrId(obj, &PyId_test);
5056 if (tmp == NULL) goto failed;
5057 res = obj2ast_expr(tmp, &test, arena);
5058 if (res != 0) goto failed;
5059 Py_XDECREF(tmp);
5060 tmp = NULL;
5061 } else {
5062 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
5063 return 1;
5064 }
5065 if (_PyObject_HasAttrId(obj, &PyId_body)) {
5066 int res;
5067 tmp = _PyObject_GetAttrId(obj, &PyId_body);
5068 if (tmp == NULL) goto failed;
5069 res = obj2ast_expr(tmp, &body, arena);
5070 if (res != 0) goto failed;
5071 Py_XDECREF(tmp);
5072 tmp = NULL;
5073 } else {
5074 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
5075 return 1;
5076 }
5077 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
5078 int res;
5079 tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
5080 if (tmp == NULL) goto failed;
5081 res = obj2ast_expr(tmp, &orelse, arena);
5082 if (res != 0) goto failed;
5083 Py_XDECREF(tmp);
5084 tmp = NULL;
5085 } else {
5086 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
5087 return 1;
5088 }
5089 *out = IfExp(test, body, orelse, lineno, col_offset, arena);
5090 if (*out == NULL) goto failed;
5091 return 0;
5092 }
5093 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type);
5094 if (isinstance == -1) {
5095 return 1;
5096 }
5097 if (isinstance) {
5098 asdl_seq* keys;
5099 asdl_seq* values;
5100
5101 if (_PyObject_HasAttrId(obj, &PyId_keys)) {
5102 int res;
5103 Py_ssize_t len;
5104 Py_ssize_t i;
5105 tmp = _PyObject_GetAttrId(obj, &PyId_keys);
5106 if (tmp == NULL) goto failed;
5107 if (!PyList_Check(tmp)) {
5108 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5109 goto failed;
5110 }
5111 len = PyList_GET_SIZE(tmp);
5112 keys = asdl_seq_new(len, arena);
5113 if (keys == NULL) goto failed;
5114 for (i = 0; i < len; i++) {
5115 expr_ty value;
5116 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5117 if (res != 0) goto failed;
5118 asdl_seq_SET(keys, i, value);
5119 }
5120 Py_XDECREF(tmp);
5121 tmp = NULL;
5122 } else {
5123 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
5124 return 1;
5125 }
5126 if (_PyObject_HasAttrId(obj, &PyId_values)) {
5127 int res;
5128 Py_ssize_t len;
5129 Py_ssize_t i;
5130 tmp = _PyObject_GetAttrId(obj, &PyId_values);
5131 if (tmp == NULL) goto failed;
5132 if (!PyList_Check(tmp)) {
5133 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5134 goto failed;
5135 }
5136 len = PyList_GET_SIZE(tmp);
5137 values = asdl_seq_new(len, arena);
5138 if (values == NULL) goto failed;
5139 for (i = 0; i < len; i++) {
5140 expr_ty value;
5141 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5142 if (res != 0) goto failed;
5143 asdl_seq_SET(values, i, value);
5144 }
5145 Py_XDECREF(tmp);
5146 tmp = NULL;
5147 } else {
5148 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
5149 return 1;
5150 }
5151 *out = Dict(keys, values, lineno, col_offset, arena);
5152 if (*out == NULL) goto failed;
5153 return 0;
5154 }
5155 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type);
5156 if (isinstance == -1) {
5157 return 1;
5158 }
5159 if (isinstance) {
5160 asdl_seq* elts;
5161
5162 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
5163 int res;
5164 Py_ssize_t len;
5165 Py_ssize_t i;
5166 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
5167 if (tmp == NULL) goto failed;
5168 if (!PyList_Check(tmp)) {
5169 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5170 goto failed;
5171 }
5172 len = PyList_GET_SIZE(tmp);
5173 elts = asdl_seq_new(len, arena);
5174 if (elts == NULL) goto failed;
5175 for (i = 0; i < len; i++) {
5176 expr_ty value;
5177 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5178 if (res != 0) goto failed;
5179 asdl_seq_SET(elts, i, value);
5180 }
5181 Py_XDECREF(tmp);
5182 tmp = NULL;
5183 } else {
5184 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
5185 return 1;
5186 }
5187 *out = Set(elts, lineno, col_offset, arena);
5188 if (*out == NULL) goto failed;
5189 return 0;
5190 }
5191 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type);
5192 if (isinstance == -1) {
5193 return 1;
5194 }
5195 if (isinstance) {
5196 expr_ty elt;
5197 asdl_seq* generators;
5198
5199 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
5200 int res;
5201 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
5202 if (tmp == NULL) goto failed;
5203 res = obj2ast_expr(tmp, &elt, arena);
5204 if (res != 0) goto failed;
5205 Py_XDECREF(tmp);
5206 tmp = NULL;
5207 } else {
5208 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
5209 return 1;
5210 }
5211 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5212 int res;
5213 Py_ssize_t len;
5214 Py_ssize_t i;
5215 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5216 if (tmp == NULL) goto failed;
5217 if (!PyList_Check(tmp)) {
5218 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5219 goto failed;
5220 }
5221 len = PyList_GET_SIZE(tmp);
5222 generators = asdl_seq_new(len, arena);
5223 if (generators == NULL) goto failed;
5224 for (i = 0; i < len; i++) {
5225 comprehension_ty value;
5226 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5227 if (res != 0) goto failed;
5228 asdl_seq_SET(generators, i, value);
5229 }
5230 Py_XDECREF(tmp);
5231 tmp = NULL;
5232 } else {
5233 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
5234 return 1;
5235 }
5236 *out = ListComp(elt, generators, lineno, col_offset, arena);
5237 if (*out == NULL) goto failed;
5238 return 0;
5239 }
5240 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type);
5241 if (isinstance == -1) {
5242 return 1;
5243 }
5244 if (isinstance) {
5245 expr_ty elt;
5246 asdl_seq* generators;
5247
5248 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
5249 int res;
5250 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
5251 if (tmp == NULL) goto failed;
5252 res = obj2ast_expr(tmp, &elt, arena);
5253 if (res != 0) goto failed;
5254 Py_XDECREF(tmp);
5255 tmp = NULL;
5256 } else {
5257 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
5258 return 1;
5259 }
5260 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5261 int res;
5262 Py_ssize_t len;
5263 Py_ssize_t i;
5264 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5265 if (tmp == NULL) goto failed;
5266 if (!PyList_Check(tmp)) {
5267 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5268 goto failed;
5269 }
5270 len = PyList_GET_SIZE(tmp);
5271 generators = asdl_seq_new(len, arena);
5272 if (generators == NULL) goto failed;
5273 for (i = 0; i < len; i++) {
5274 comprehension_ty value;
5275 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5276 if (res != 0) goto failed;
5277 asdl_seq_SET(generators, i, value);
5278 }
5279 Py_XDECREF(tmp);
5280 tmp = NULL;
5281 } else {
5282 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
5283 return 1;
5284 }
5285 *out = SetComp(elt, generators, lineno, col_offset, arena);
5286 if (*out == NULL) goto failed;
5287 return 0;
5288 }
5289 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type);
5290 if (isinstance == -1) {
5291 return 1;
5292 }
5293 if (isinstance) {
5294 expr_ty key;
5295 expr_ty value; 5129 expr_ty value;
5296 asdl_seq* generators; 5130 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5297 5131 if (res != 0) goto failed;
5298 if (_PyObject_HasAttrId(obj, &PyId_key)) { 5132 asdl_seq_SET(values, i, value);
5299 int res; 5133 }
5300 tmp = _PyObject_GetAttrId(obj, &PyId_key); 5134 Py_XDECREF(tmp);
5301 if (tmp == NULL) goto failed; 5135 tmp = NULL;
5302 res = obj2ast_expr(tmp, &key, arena); 5136 } else {
5303 if (res != 0) goto failed; 5137 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
5304 Py_XDECREF(tmp); 5138 return 1;
5305 tmp = NULL; 5139 }
5306 } else { 5140 *out = Dict(keys, values, lineno, col_offset, arena);
5307 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp"); 5141 if (*out == NULL) goto failed;
5308 return 1; 5142 return 0;
5309 } 5143 }
5310 if (_PyObject_HasAttrId(obj, &PyId_value)) { 5144 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type);
5311 int res; 5145 if (isinstance == -1) {
5312 tmp = _PyObject_GetAttrId(obj, &PyId_value); 5146 return 1;
5313 if (tmp == NULL) goto failed; 5147 }
5314 res = obj2ast_expr(tmp, &value, arena); 5148 if (isinstance) {
5315 if (res != 0) goto failed; 5149 asdl_seq* elts;
5316 Py_XDECREF(tmp); 5150
5317 tmp = NULL; 5151 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
5318 } else { 5152 int res;
5319 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp"); 5153 Py_ssize_t len;
5320 return 1; 5154 Py_ssize_t i;
5321 } 5155 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
5322 if (_PyObject_HasAttrId(obj, &PyId_generators)) { 5156 if (tmp == NULL) goto failed;
5323 int res; 5157 if (!PyList_Check(tmp)) {
5324 Py_ssize_t len; 5158 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5325 Py_ssize_t i; 5159 goto failed;
5326 tmp = _PyObject_GetAttrId(obj, &PyId_generators); 5160 }
5327 if (tmp == NULL) goto failed; 5161 len = PyList_GET_SIZE(tmp);
5328 if (!PyList_Check(tmp)) { 5162 elts = asdl_seq_new(len, arena);
5329 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); 5163 if (elts == NULL) goto failed;
5330 goto failed; 5164 for (i = 0; i < len; i++) {
5331 }
5332 len = PyList_GET_SIZE(tmp);
5333 generators = asdl_seq_new(len, arena);
5334 if (generators == NULL) goto failed;
5335 for (i = 0; i < len; i++) {
5336 comprehension_ty value;
5337 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5338 if (res != 0) goto failed;
5339 asdl_seq_SET(generators, i, value);
5340 }
5341 Py_XDECREF(tmp);
5342 tmp = NULL;
5343 } else {
5344 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
5345 return 1;
5346 }
5347 *out = DictComp(key, value, generators, lineno, col_offset,
5348 arena);
5349 if (*out == NULL) goto failed;
5350 return 0;
5351 }
5352 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type);
5353 if (isinstance == -1) {
5354 return 1;
5355 }
5356 if (isinstance) {
5357 expr_ty elt;
5358 asdl_seq* generators;
5359
5360 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
5361 int res;
5362 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
5363 if (tmp == NULL) goto failed;
5364 res = obj2ast_expr(tmp, &elt, arena);
5365 if (res != 0) goto failed;
5366 Py_XDECREF(tmp);
5367 tmp = NULL;
5368 } else {
5369 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
5370 return 1;
5371 }
5372 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5373 int res;
5374 Py_ssize_t len;
5375 Py_ssize_t i;
5376 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5377 if (tmp == NULL) goto failed;
5378 if (!PyList_Check(tmp)) {
5379 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5380 goto failed;
5381 }
5382 len = PyList_GET_SIZE(tmp);
5383 generators = asdl_seq_new(len, arena);
5384 if (generators == NULL) goto failed;
5385 for (i = 0; i < len; i++) {
5386 comprehension_ty value;
5387 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5388 if (res != 0) goto failed;
5389 asdl_seq_SET(generators, i, value);
5390 }
5391 Py_XDECREF(tmp);
5392 tmp = NULL;
5393 } else {
5394 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
5395 return 1;
5396 }
5397 *out = GeneratorExp(elt, generators, lineno, col_offset, arena);
5398 if (*out == NULL) goto failed;
5399 return 0;
5400 }
5401 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type);
5402 if (isinstance == -1) {
5403 return 1;
5404 }
5405 if (isinstance) {
5406 expr_ty value; 5165 expr_ty value;
5407 5166 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5408 if (_PyObject_HasAttrId(obj, &PyId_value)) { 5167 if (res != 0) goto failed;
5409 int res; 5168 asdl_seq_SET(elts, i, value);
5410 tmp = _PyObject_GetAttrId(obj, &PyId_value); 5169 }
5411 if (tmp == NULL) goto failed; 5170 Py_XDECREF(tmp);
5412 res = obj2ast_expr(tmp, &value, arena); 5171 tmp = NULL;
5413 if (res != 0) goto failed; 5172 } else {
5414 Py_XDECREF(tmp); 5173 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
5415 tmp = NULL; 5174 return 1;
5416 } else { 5175 }
5417 value = NULL; 5176 *out = Set(elts, lineno, col_offset, arena);
5418 } 5177 if (*out == NULL) goto failed;
5419 *out = Yield(value, lineno, col_offset, arena); 5178 return 0;
5420 if (*out == NULL) goto failed; 5179 }
5421 return 0; 5180 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type);
5422 } 5181 if (isinstance == -1) {
5423 isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type); 5182 return 1;
5424 if (isinstance == -1) { 5183 }
5425 return 1; 5184 if (isinstance) {
5426 } 5185 expr_ty elt;
5427 if (isinstance) { 5186 asdl_seq* generators;
5187
5188 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
5189 int res;
5190 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
5191 if (tmp == NULL) goto failed;
5192 res = obj2ast_expr(tmp, &elt, arena);
5193 if (res != 0) goto failed;
5194 Py_XDECREF(tmp);
5195 tmp = NULL;
5196 } else {
5197 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
5198 return 1;
5199 }
5200 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5201 int res;
5202 Py_ssize_t len;
5203 Py_ssize_t i;
5204 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5205 if (tmp == NULL) goto failed;
5206 if (!PyList_Check(tmp)) {
5207 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5208 goto failed;
5209 }
5210 len = PyList_GET_SIZE(tmp);
5211 generators = asdl_seq_new(len, arena);
5212 if (generators == NULL) goto failed;
5213 for (i = 0; i < len; i++) {
5214 comprehension_ty value;
5215 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5216 if (res != 0) goto failed;
5217 asdl_seq_SET(generators, i, value);
5218 }
5219 Py_XDECREF(tmp);
5220 tmp = NULL;
5221 } else {
5222 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
5223 return 1;
5224 }
5225 *out = ListComp(elt, generators, lineno, col_offset, arena);
5226 if (*out == NULL) goto failed;
5227 return 0;
5228 }
5229 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type);
5230 if (isinstance == -1) {
5231 return 1;
5232 }
5233 if (isinstance) {
5234 expr_ty elt;
5235 asdl_seq* generators;
5236
5237 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
5238 int res;
5239 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
5240 if (tmp == NULL) goto failed;
5241 res = obj2ast_expr(tmp, &elt, arena);
5242 if (res != 0) goto failed;
5243 Py_XDECREF(tmp);
5244 tmp = NULL;
5245 } else {
5246 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
5247 return 1;
5248 }
5249 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5250 int res;
5251 Py_ssize_t len;
5252 Py_ssize_t i;
5253 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5254 if (tmp == NULL) goto failed;
5255 if (!PyList_Check(tmp)) {
5256 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5257 goto failed;
5258 }
5259 len = PyList_GET_SIZE(tmp);
5260 generators = asdl_seq_new(len, arena);
5261 if (generators == NULL) goto failed;
5262 for (i = 0; i < len; i++) {
5263 comprehension_ty value;
5264 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5265 if (res != 0) goto failed;
5266 asdl_seq_SET(generators, i, value);
5267 }
5268 Py_XDECREF(tmp);
5269 tmp = NULL;
5270 } else {
5271 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
5272 return 1;
5273 }
5274 *out = SetComp(elt, generators, lineno, col_offset, arena);
5275 if (*out == NULL) goto failed;
5276 return 0;
5277 }
5278 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type);
5279 if (isinstance == -1) {
5280 return 1;
5281 }
5282 if (isinstance) {
5283 expr_ty key;
5284 expr_ty value;
5285 asdl_seq* generators;
5286
5287 if (_PyObject_HasAttrId(obj, &PyId_key)) {
5288 int res;
5289 tmp = _PyObject_GetAttrId(obj, &PyId_key);
5290 if (tmp == NULL) goto failed;
5291 res = obj2ast_expr(tmp, &key, arena);
5292 if (res != 0) goto failed;
5293 Py_XDECREF(tmp);
5294 tmp = NULL;
5295 } else {
5296 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
5297 return 1;
5298 }
5299 if (_PyObject_HasAttrId(obj, &PyId_value)) {
5300 int res;
5301 tmp = _PyObject_GetAttrId(obj, &PyId_value);
5302 if (tmp == NULL) goto failed;
5303 res = obj2ast_expr(tmp, &value, arena);
5304 if (res != 0) goto failed;
5305 Py_XDECREF(tmp);
5306 tmp = NULL;
5307 } else {
5308 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
5309 return 1;
5310 }
5311 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5312 int res;
5313 Py_ssize_t len;
5314 Py_ssize_t i;
5315 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5316 if (tmp == NULL) goto failed;
5317 if (!PyList_Check(tmp)) {
5318 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5319 goto failed;
5320 }
5321 len = PyList_GET_SIZE(tmp);
5322 generators = asdl_seq_new(len, arena);
5323 if (generators == NULL) goto failed;
5324 for (i = 0; i < len; i++) {
5325 comprehension_ty value;
5326 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5327 if (res != 0) goto failed;
5328 asdl_seq_SET(generators, i, value);
5329 }
5330 Py_XDECREF(tmp);
5331 tmp = NULL;
5332 } else {
5333 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
5334 return 1;
5335 }
5336 *out = DictComp(key, value, generators, lineno, col_offset, arena);
5337 if (*out == NULL) goto failed;
5338 return 0;
5339 }
5340 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type);
5341 if (isinstance == -1) {
5342 return 1;
5343 }
5344 if (isinstance) {
5345 expr_ty elt;
5346 asdl_seq* generators;
5347
5348 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
5349 int res;
5350 tmp = _PyObject_GetAttrId(obj, &PyId_elt);
5351 if (tmp == NULL) goto failed;
5352 res = obj2ast_expr(tmp, &elt, arena);
5353 if (res != 0) goto failed;
5354 Py_XDECREF(tmp);
5355 tmp = NULL;
5356 } else {
5357 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
5358 return 1;
5359 }
5360 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
5361 int res;
5362 Py_ssize_t len;
5363 Py_ssize_t i;
5364 tmp = _PyObject_GetAttrId(obj, &PyId_generators);
5365 if (tmp == NULL) goto failed;
5366 if (!PyList_Check(tmp)) {
5367 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5368 goto failed;
5369 }
5370 len = PyList_GET_SIZE(tmp);
5371 generators = asdl_seq_new(len, arena);
5372 if (generators == NULL) goto failed;
5373 for (i = 0; i < len; i++) {
5374 comprehension_ty value;
5375 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
5376 if (res != 0) goto failed;
5377 asdl_seq_SET(generators, i, value);
5378 }
5379 Py_XDECREF(tmp);
5380 tmp = NULL;
5381 } else {
5382 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
5383 return 1;
5384 }
5385 *out = GeneratorExp(elt, generators, lineno, col_offset, arena);
5386 if (*out == NULL) goto failed;
5387 return 0;
5388 }
5389 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type);
5390 if (isinstance == -1) {
5391 return 1;
5392 }
5393 if (isinstance) {
5394 expr_ty value;
5395
5396 if (_PyObject_HasAttrId(obj, &PyId_value)) {
5397 int res;
5398 tmp = _PyObject_GetAttrId(obj, &PyId_value);
5399 if (tmp == NULL) goto failed;
5400 res = obj2ast_expr(tmp, &value, arena);
5401 if (res != 0) goto failed;
5402 Py_XDECREF(tmp);
5403 tmp = NULL;
5404 } else {
5405 value = NULL;
5406 }
5407 *out = Yield(value, lineno, col_offset, arena);
5408 if (*out == NULL) goto failed;
5409 return 0;
5410 }
5411 isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type);
5412 if (isinstance == -1) {
5413 return 1;
5414 }
5415 if (isinstance) {
5416 expr_ty value;
5417
5418 if (_PyObject_HasAttrId(obj, &PyId_value)) {
5419 int res;
5420 tmp = _PyObject_GetAttrId(obj, &PyId_value);
5421 if (tmp == NULL) goto failed;
5422 res = obj2ast_expr(tmp, &value, arena);
5423 if (res != 0) goto failed;
5424 Py_XDECREF(tmp);
5425 tmp = NULL;
5426 } else {
5427 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
5428 return 1;
5429 }
5430 *out = YieldFrom(value, lineno, col_offset, arena);
5431 if (*out == NULL) goto failed;
5432 return 0;
5433 }
5434 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type);
5435 if (isinstance == -1) {
5436 return 1;
5437 }
5438 if (isinstance) {
5439 expr_ty left;
5440 asdl_int_seq* ops;
5441 asdl_seq* comparators;
5442
5443 if (_PyObject_HasAttrId(obj, &PyId_left)) {
5444 int res;
5445 tmp = _PyObject_GetAttrId(obj, &PyId_left);
5446 if (tmp == NULL) goto failed;
5447 res = obj2ast_expr(tmp, &left, arena);
5448 if (res != 0) goto failed;
5449 Py_XDECREF(tmp);
5450 tmp = NULL;
5451 } else {
5452 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
5453 return 1;
5454 }
5455 if (_PyObject_HasAttrId(obj, &PyId_ops)) {
5456 int res;
5457 Py_ssize_t len;
5458 Py_ssize_t i;
5459 tmp = _PyObject_GetAttrId(obj, &PyId_ops);
5460 if (tmp == NULL) goto failed;
5461 if (!PyList_Check(tmp)) {
5462 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5463 goto failed;
5464 }
5465 len = PyList_GET_SIZE(tmp);
5466 ops = asdl_int_seq_new(len, arena);
5467 if (ops == NULL) goto failed;
5468 for (i = 0; i < len; i++) {
5469 cmpop_ty value;
5470 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena);
5471 if (res != 0) goto failed;
5472 asdl_seq_SET(ops, i, value);
5473 }
5474 Py_XDECREF(tmp);
5475 tmp = NULL;
5476 } else {
5477 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
5478 return 1;
5479 }
5480 if (_PyObject_HasAttrId(obj, &PyId_comparators)) {
5481 int res;
5482 Py_ssize_t len;
5483 Py_ssize_t i;
5484 tmp = _PyObject_GetAttrId(obj, &PyId_comparators);
5485 if (tmp == NULL) goto failed;
5486 if (!PyList_Check(tmp)) {
5487 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5488 goto failed;
5489 }
5490 len = PyList_GET_SIZE(tmp);
5491 comparators = asdl_seq_new(len, arena);
5492 if (comparators == NULL) goto failed;
5493 for (i = 0; i < len; i++) {
5428 expr_ty value; 5494 expr_ty value;
5429 5495 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5430 if (_PyObject_HasAttrId(obj, &PyId_value)) { 5496 if (res != 0) goto failed;
5431 int res; 5497 asdl_seq_SET(comparators, i, value);
5432 tmp = _PyObject_GetAttrId(obj, &PyId_value); 5498 }
5433 if (tmp == NULL) goto failed; 5499 Py_XDECREF(tmp);
5434 res = obj2ast_expr(tmp, &value, arena); 5500 tmp = NULL;
5435 if (res != 0) goto failed; 5501 } else {
5436 Py_XDECREF(tmp); 5502 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
5437 tmp = NULL; 5503 return 1;
5438 } else { 5504 }
5439 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom"); 5505 *out = Compare(left, ops, comparators, lineno, col_offset, arena);
5440 return 1; 5506 if (*out == NULL) goto failed;
5441 } 5507 return 0;
5442 *out = YieldFrom(value, lineno, col_offset, arena); 5508 }
5443 if (*out == NULL) goto failed; 5509 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type);
5444 return 0; 5510 if (isinstance == -1) {
5445 } 5511 return 1;
5446 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); 5512 }
5447 if (isinstance == -1) { 5513 if (isinstance) {
5448 return 1; 5514 expr_ty func;
5449 } 5515 asdl_seq* args;
5450 if (isinstance) { 5516 asdl_seq* keywords;
5451 expr_ty left; 5517 expr_ty starargs;
5452 asdl_int_seq* ops; 5518 expr_ty kwargs;
5453 asdl_seq* comparators; 5519
5454 5520 if (_PyObject_HasAttrId(obj, &PyId_func)) {
5455 if (_PyObject_HasAttrId(obj, &PyId_left)) { 5521 int res;
5456 int res; 5522 tmp = _PyObject_GetAttrId(obj, &PyId_func);
5457 tmp = _PyObject_GetAttrId(obj, &PyId_left); 5523 if (tmp == NULL) goto failed;
5458 if (tmp == NULL) goto failed; 5524 res = obj2ast_expr(tmp, &func, arena);
5459 res = obj2ast_expr(tmp, &left, arena); 5525 if (res != 0) goto failed;
5460 if (res != 0) goto failed; 5526 Py_XDECREF(tmp);
5461 Py_XDECREF(tmp); 5527 tmp = NULL;
5462 tmp = NULL; 5528 } else {
5463 } else { 5529 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
5464 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare"); 5530 return 1;
5465 return 1; 5531 }
5466 } 5532 if (_PyObject_HasAttrId(obj, &PyId_args)) {
5467 if (_PyObject_HasAttrId(obj, &PyId_ops)) { 5533 int res;
5468 int res; 5534 Py_ssize_t len;
5469 Py_ssize_t len; 5535 Py_ssize_t i;
5470 Py_ssize_t i; 5536 tmp = _PyObject_GetAttrId(obj, &PyId_args);
5471 tmp = _PyObject_GetAttrId(obj, &PyId_ops); 5537 if (tmp == NULL) goto failed;
5472 if (tmp == NULL) goto failed; 5538 if (!PyList_Check(tmp)) {
5473 if (!PyList_Check(tmp)) { 5539 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5474 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name); 5540 goto failed;
5475 goto failed; 5541 }
5476 } 5542 len = PyList_GET_SIZE(tmp);
5477 len = PyList_GET_SIZE(tmp); 5543 args = asdl_seq_new(len, arena);
5478 ops = asdl_int_seq_new(len, arena); 5544 if (args == NULL) goto failed;
5479 if (ops == NULL) goto failed; 5545 for (i = 0; i < len; i++) {
5480 for (i = 0; i < len; i++) {
5481 cmpop_ty value;
5482 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena);
5483 if (res != 0) goto failed;
5484 asdl_seq_SET(ops, i, value);
5485 }
5486 Py_XDECREF(tmp);
5487 tmp = NULL;
5488 } else {
5489 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
5490 return 1;
5491 }
5492 if (_PyObject_HasAttrId(obj, &PyId_comparators)) {
5493 int res;
5494 Py_ssize_t len;
5495 Py_ssize_t i;
5496 tmp = _PyObject_GetAttrId(obj, &PyId_comparators);
5497 if (tmp == NULL) goto failed;
5498 if (!PyList_Check(tmp)) {
5499 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5500 goto failed;
5501 }
5502 len = PyList_GET_SIZE(tmp);
5503 comparators = asdl_seq_new(len, arena);
5504 if (comparators == NULL) goto failed;
5505 for (i = 0; i < len; i++) {
5506 expr_ty value;
5507 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5508 if (res != 0) goto failed;
5509 asdl_seq_SET(comparators, i, value);
5510 }
5511 Py_XDECREF(tmp);
5512 tmp = NULL;
5513 } else {
5514 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
5515 return 1;
5516 }
5517 *out = Compare(left, ops, comparators, lineno, col_offset,
5518 arena);
5519 if (*out == NULL) goto failed;
5520 return 0;
5521 }
5522 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type);
5523 if (isinstance == -1) {
5524 return 1;
5525 }
5526 if (isinstance) {
5527 expr_ty func;
5528 asdl_seq* args;
5529 asdl_seq* keywords;
5530 expr_ty starargs;
5531 expr_ty kwargs;
5532
5533 if (_PyObject_HasAttrId(obj, &PyId_func)) {
5534 int res;
5535 tmp = _PyObject_GetAttrId(obj, &PyId_func);
5536 if (tmp == NULL) goto failed;
5537 res = obj2ast_expr(tmp, &func, arena);
5538 if (res != 0) goto failed;
5539 Py_XDECREF(tmp);
5540 tmp = NULL;
5541 } else {
5542 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
5543 return 1;
5544 }
5545 if (_PyObject_HasAttrId(obj, &PyId_args)) {
5546 int res;
5547 Py_ssize_t len;
5548 Py_ssize_t i;
5549 tmp = _PyObject_GetAttrId(obj, &PyId_args);
5550 if (tmp == NULL) goto failed;
5551 if (!PyList_Check(tmp)) {
5552 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5553 goto failed;
5554 }
5555 len = PyList_GET_SIZE(tmp);
5556 args = asdl_seq_new(len, arena);
5557 if (args == NULL) goto failed;
5558 for (i = 0; i < len; i++) {
5559 expr_ty value;
5560 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5561 if (res != 0) goto failed;
5562 asdl_seq_SET(args, i, value);
5563 }
5564 Py_XDECREF(tmp);
5565 tmp = NULL;
5566 } else {
5567 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
5568 return 1;
5569 }
5570 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
5571 int res;
5572 Py_ssize_t len;
5573 Py_ssize_t i;
5574 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
5575 if (tmp == NULL) goto failed;
5576 if (!PyList_Check(tmp)) {
5577 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5578 goto failed;
5579 }
5580 len = PyList_GET_SIZE(tmp);
5581 keywords = asdl_seq_new(len, arena);
5582 if (keywords == NULL) goto failed;
5583 for (i = 0; i < len; i++) {
5584 keyword_ty value;
5585 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
5586 if (res != 0) goto failed;
5587 asdl_seq_SET(keywords, i, value);
5588 }
5589 Py_XDECREF(tmp);
5590 tmp = NULL;
5591 } else {
5592 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
5593 return 1;
5594 }
5595 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
5596 int res;
5597 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
5598 if (tmp == NULL) goto failed;
5599 res = obj2ast_expr(tmp, &starargs, arena);
5600 if (res != 0) goto failed;
5601 Py_XDECREF(tmp);
5602 tmp = NULL;
5603 } else {
5604 starargs = NULL;
5605 }
5606 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
5607 int res;
5608 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
5609 if (tmp == NULL) goto failed;
5610 res = obj2ast_expr(tmp, &kwargs, arena);
5611 if (res != 0) goto failed;
5612 Py_XDECREF(tmp);
5613 tmp = NULL;
5614 } else {
5615 kwargs = NULL;
5616 }
5617 *out = Call(func, args, keywords, starargs, kwargs, lineno,
5618 col_offset, arena);
5619 if (*out == NULL) goto failed;
5620 return 0;
5621 }
5622 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type);
5623 if (isinstance == -1) {
5624 return 1;
5625 }
5626 if (isinstance) {
5627 object n;
5628
5629 if (_PyObject_HasAttrId(obj, &PyId_n)) {
5630 int res;
5631 tmp = _PyObject_GetAttrId(obj, &PyId_n);
5632 if (tmp == NULL) goto failed;
5633 res = obj2ast_object(tmp, &n, arena);
5634 if (res != 0) goto failed;
5635 Py_XDECREF(tmp);
5636 tmp = NULL;
5637 } else {
5638 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
5639 return 1;
5640 }
5641 *out = Num(n, lineno, col_offset, arena);
5642 if (*out == NULL) goto failed;
5643 return 0;
5644 }
5645 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type);
5646 if (isinstance == -1) {
5647 return 1;
5648 }
5649 if (isinstance) {
5650 string s;
5651
5652 if (_PyObject_HasAttrId(obj, &PyId_s)) {
5653 int res;
5654 tmp = _PyObject_GetAttrId(obj, &PyId_s);
5655 if (tmp == NULL) goto failed;
5656 res = obj2ast_string(tmp, &s, arena);
5657 if (res != 0) goto failed;
5658 Py_XDECREF(tmp);
5659 tmp = NULL;
5660 } else {
5661 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
5662 return 1;
5663 }
5664 *out = Str(s, lineno, col_offset, arena);
5665 if (*out == NULL) goto failed;
5666 return 0;
5667 }
5668 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
5669 if (isinstance == -1) {
5670 return 1;
5671 }
5672 if (isinstance) {
5673 bytes s;
5674
5675 if (_PyObject_HasAttrId(obj, &PyId_s)) {
5676 int res;
5677 tmp = _PyObject_GetAttrId(obj, &PyId_s);
5678 if (tmp == NULL) goto failed;
5679 res = obj2ast_bytes(tmp, &s, arena);
5680 if (res != 0) goto failed;
5681 Py_XDECREF(tmp);
5682 tmp = NULL;
5683 } else {
5684 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
5685 return 1;
5686 }
5687 *out = Bytes(s, lineno, col_offset, arena);
5688 if (*out == NULL) goto failed;
5689 return 0;
5690 }
5691 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type);
5692 if (isinstance == -1) {
5693 return 1;
5694 }
5695 if (isinstance) {
5696
5697 *out = Ellipsis(lineno, col_offset, arena);
5698 if (*out == NULL) goto failed;
5699 return 0;
5700 }
5701 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type);
5702 if (isinstance == -1) {
5703 return 1;
5704 }
5705 if (isinstance) {
5706 expr_ty value; 5546 expr_ty value;
5707 identifier attr; 5547 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5708 expr_context_ty ctx; 5548 if (res != 0) goto failed;
5709 5549 asdl_seq_SET(args, i, value);
5710 if (_PyObject_HasAttrId(obj, &PyId_value)) { 5550 }
5711 int res; 5551 Py_XDECREF(tmp);
5712 tmp = _PyObject_GetAttrId(obj, &PyId_value); 5552 tmp = NULL;
5713 if (tmp == NULL) goto failed; 5553 } else {
5714 res = obj2ast_expr(tmp, &value, arena); 5554 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
5715 if (res != 0) goto failed; 5555 return 1;
5716 Py_XDECREF(tmp); 5556 }
5717 tmp = NULL; 5557 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
5718 } else { 5558 int res;
5719 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute"); 5559 Py_ssize_t len;
5720 return 1; 5560 Py_ssize_t i;
5721 } 5561 tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
5722 if (_PyObject_HasAttrId(obj, &PyId_attr)) { 5562 if (tmp == NULL) goto failed;
5723 int res; 5563 if (!PyList_Check(tmp)) {
5724 tmp = _PyObject_GetAttrId(obj, &PyId_attr); 5564 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5725 if (tmp == NULL) goto failed; 5565 goto failed;
5726 res = obj2ast_identifier(tmp, &attr, arena); 5566 }
5727 if (res != 0) goto failed; 5567 len = PyList_GET_SIZE(tmp);
5728 Py_XDECREF(tmp); 5568 keywords = asdl_seq_new(len, arena);
5729 tmp = NULL; 5569 if (keywords == NULL) goto failed;
5730 } else { 5570 for (i = 0; i < len; i++) {
5731 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute"); 5571 keyword_ty value;
5732 return 1; 5572 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
5733 } 5573 if (res != 0) goto failed;
5734 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { 5574 asdl_seq_SET(keywords, i, value);
5735 int res; 5575 }
5736 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); 5576 Py_XDECREF(tmp);
5737 if (tmp == NULL) goto failed; 5577 tmp = NULL;
5738 res = obj2ast_expr_context(tmp, &ctx, arena); 5578 } else {
5739 if (res != 0) goto failed; 5579 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
5740 Py_XDECREF(tmp); 5580 return 1;
5741 tmp = NULL; 5581 }
5742 } else { 5582 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
5743 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute"); 5583 int res;
5744 return 1; 5584 tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
5745 } 5585 if (tmp == NULL) goto failed;
5746 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); 5586 res = obj2ast_expr(tmp, &starargs, arena);
5747 if (*out == NULL) goto failed; 5587 if (res != 0) goto failed;
5748 return 0; 5588 Py_XDECREF(tmp);
5749 } 5589 tmp = NULL;
5750 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); 5590 } else {
5751 if (isinstance == -1) { 5591 starargs = NULL;
5752 return 1; 5592 }
5753 } 5593 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
5754 if (isinstance) { 5594 int res;
5595 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
5596 if (tmp == NULL) goto failed;
5597 res = obj2ast_expr(tmp, &kwargs, arena);
5598 if (res != 0) goto failed;
5599 Py_XDECREF(tmp);
5600 tmp = NULL;
5601 } else {
5602 kwargs = NULL;
5603 }
5604 *out = Call(func, args, keywords, starargs, kwargs, lineno, col_offset,
5605 arena);
5606 if (*out == NULL) goto failed;
5607 return 0;
5608 }
5609 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type);
5610 if (isinstance == -1) {
5611 return 1;
5612 }
5613 if (isinstance) {
5614 object n;
5615
5616 if (_PyObject_HasAttrId(obj, &PyId_n)) {
5617 int res;
5618 tmp = _PyObject_GetAttrId(obj, &PyId_n);
5619 if (tmp == NULL) goto failed;
5620 res = obj2ast_object(tmp, &n, arena);
5621 if (res != 0) goto failed;
5622 Py_XDECREF(tmp);
5623 tmp = NULL;
5624 } else {
5625 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
5626 return 1;
5627 }
5628 *out = Num(n, lineno, col_offset, arena);
5629 if (*out == NULL) goto failed;
5630 return 0;
5631 }
5632 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type);
5633 if (isinstance == -1) {
5634 return 1;
5635 }
5636 if (isinstance) {
5637 string s;
5638
5639 if (_PyObject_HasAttrId(obj, &PyId_s)) {
5640 int res;
5641 tmp = _PyObject_GetAttrId(obj, &PyId_s);
5642 if (tmp == NULL) goto failed;
5643 res = obj2ast_string(tmp, &s, arena);
5644 if (res != 0) goto failed;
5645 Py_XDECREF(tmp);
5646 tmp = NULL;
5647 } else {
5648 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
5649 return 1;
5650 }
5651 *out = Str(s, lineno, col_offset, arena);
5652 if (*out == NULL) goto failed;
5653 return 0;
5654 }
5655 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
5656 if (isinstance == -1) {
5657 return 1;
5658 }
5659 if (isinstance) {
5660 bytes s;
5661
5662 if (_PyObject_HasAttrId(obj, &PyId_s)) {
5663 int res;
5664 tmp = _PyObject_GetAttrId(obj, &PyId_s);
5665 if (tmp == NULL) goto failed;
5666 res = obj2ast_bytes(tmp, &s, arena);
5667 if (res != 0) goto failed;
5668 Py_XDECREF(tmp);
5669 tmp = NULL;
5670 } else {
5671 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
5672 return 1;
5673 }
5674 *out = Bytes(s, lineno, col_offset, arena);
5675 if (*out == NULL) goto failed;
5676 return 0;
5677 }
5678 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type);
5679 if (isinstance == -1) {
5680 return 1;
5681 }
5682 if (isinstance) {
5683
5684 *out = Ellipsis(lineno, col_offset, arena);
5685 if (*out == NULL) goto failed;
5686 return 0;
5687 }
5688 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type);
5689 if (isinstance == -1) {
5690 return 1;
5691 }
5692 if (isinstance) {
5693 expr_ty value;
5694 identifier attr;
5695 expr_context_ty ctx;
5696
5697 if (_PyObject_HasAttrId(obj, &PyId_value)) {
5698 int res;
5699 tmp = _PyObject_GetAttrId(obj, &PyId_value);
5700 if (tmp == NULL) goto failed;
5701 res = obj2ast_expr(tmp, &value, arena);
5702 if (res != 0) goto failed;
5703 Py_XDECREF(tmp);
5704 tmp = NULL;
5705 } else {
5706 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
5707 return 1;
5708 }
5709 if (_PyObject_HasAttrId(obj, &PyId_attr)) {
5710 int res;
5711 tmp = _PyObject_GetAttrId(obj, &PyId_attr);
5712 if (tmp == NULL) goto failed;
5713 res = obj2ast_identifier(tmp, &attr, arena);
5714 if (res != 0) goto failed;
5715 Py_XDECREF(tmp);
5716 tmp = NULL;
5717 } else {
5718 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
5719 return 1;
5720 }
5721 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5722 int res;
5723 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5724 if (tmp == NULL) goto failed;
5725 res = obj2ast_expr_context(tmp, &ctx, arena);
5726 if (res != 0) goto failed;
5727 Py_XDECREF(tmp);
5728 tmp = NULL;
5729 } else {
5730 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
5731 return 1;
5732 }
5733 *out = Attribute(value, attr, ctx, lineno, col_offset, arena);
5734 if (*out == NULL) goto failed;
5735 return 0;
5736 }
5737 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type);
5738 if (isinstance == -1) {
5739 return 1;
5740 }
5741 if (isinstance) {
5742 expr_ty value;
5743 slice_ty slice;
5744 expr_context_ty ctx;
5745
5746 if (_PyObject_HasAttrId(obj, &PyId_value)) {
5747 int res;
5748 tmp = _PyObject_GetAttrId(obj, &PyId_value);
5749 if (tmp == NULL) goto failed;
5750 res = obj2ast_expr(tmp, &value, arena);
5751 if (res != 0) goto failed;
5752 Py_XDECREF(tmp);
5753 tmp = NULL;
5754 } else {
5755 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
5756 return 1;
5757 }
5758 if (_PyObject_HasAttrId(obj, &PyId_slice)) {
5759 int res;
5760 tmp = _PyObject_GetAttrId(obj, &PyId_slice);
5761 if (tmp == NULL) goto failed;
5762 res = obj2ast_slice(tmp, &slice, arena);
5763 if (res != 0) goto failed;
5764 Py_XDECREF(tmp);
5765 tmp = NULL;
5766 } else {
5767 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
5768 return 1;
5769 }
5770 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5771 int res;
5772 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5773 if (tmp == NULL) goto failed;
5774 res = obj2ast_expr_context(tmp, &ctx, arena);
5775 if (res != 0) goto failed;
5776 Py_XDECREF(tmp);
5777 tmp = NULL;
5778 } else {
5779 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
5780 return 1;
5781 }
5782 *out = Subscript(value, slice, ctx, lineno, col_offset, arena);
5783 if (*out == NULL) goto failed;
5784 return 0;
5785 }
5786 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type);
5787 if (isinstance == -1) {
5788 return 1;
5789 }
5790 if (isinstance) {
5791 expr_ty value;
5792 expr_context_ty ctx;
5793
5794 if (_PyObject_HasAttrId(obj, &PyId_value)) {
5795 int res;
5796 tmp = _PyObject_GetAttrId(obj, &PyId_value);
5797 if (tmp == NULL) goto failed;
5798 res = obj2ast_expr(tmp, &value, arena);
5799 if (res != 0) goto failed;
5800 Py_XDECREF(tmp);
5801 tmp = NULL;
5802 } else {
5803 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
5804 return 1;
5805 }
5806 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5807 int res;
5808 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5809 if (tmp == NULL) goto failed;
5810 res = obj2ast_expr_context(tmp, &ctx, arena);
5811 if (res != 0) goto failed;
5812 Py_XDECREF(tmp);
5813 tmp = NULL;
5814 } else {
5815 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
5816 return 1;
5817 }
5818 *out = Starred(value, ctx, lineno, col_offset, arena);
5819 if (*out == NULL) goto failed;
5820 return 0;
5821 }
5822 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type);
5823 if (isinstance == -1) {
5824 return 1;
5825 }
5826 if (isinstance) {
5827 identifier id;
5828 expr_context_ty ctx;
5829
5830 if (_PyObject_HasAttrId(obj, &PyId_id)) {
5831 int res;
5832 tmp = _PyObject_GetAttrId(obj, &PyId_id);
5833 if (tmp == NULL) goto failed;
5834 res = obj2ast_identifier(tmp, &id, arena);
5835 if (res != 0) goto failed;
5836 Py_XDECREF(tmp);
5837 tmp = NULL;
5838 } else {
5839 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
5840 return 1;
5841 }
5842 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5843 int res;
5844 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5845 if (tmp == NULL) goto failed;
5846 res = obj2ast_expr_context(tmp, &ctx, arena);
5847 if (res != 0) goto failed;
5848 Py_XDECREF(tmp);
5849 tmp = NULL;
5850 } else {
5851 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
5852 return 1;
5853 }
5854 *out = Name(id, ctx, lineno, col_offset, arena);
5855 if (*out == NULL) goto failed;
5856 return 0;
5857 }
5858 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type);
5859 if (isinstance == -1) {
5860 return 1;
5861 }
5862 if (isinstance) {
5863 asdl_seq* elts;
5864 expr_context_ty ctx;
5865
5866 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
5867 int res;
5868 Py_ssize_t len;
5869 Py_ssize_t i;
5870 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
5871 if (tmp == NULL) goto failed;
5872 if (!PyList_Check(tmp)) {
5873 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5874 goto failed;
5875 }
5876 len = PyList_GET_SIZE(tmp);
5877 elts = asdl_seq_new(len, arena);
5878 if (elts == NULL) goto failed;
5879 for (i = 0; i < len; i++) {
5755 expr_ty value; 5880 expr_ty value;
5756 slice_ty slice; 5881 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5757 expr_context_ty ctx; 5882 if (res != 0) goto failed;
5758 5883 asdl_seq_SET(elts, i, value);
5759 if (_PyObject_HasAttrId(obj, &PyId_value)) { 5884 }
5760 int res; 5885 Py_XDECREF(tmp);
5761 tmp = _PyObject_GetAttrId(obj, &PyId_value); 5886 tmp = NULL;
5762 if (tmp == NULL) goto failed; 5887 } else {
5763 res = obj2ast_expr(tmp, &value, arena); 5888 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
5764 if (res != 0) goto failed; 5889 return 1;
5765 Py_XDECREF(tmp); 5890 }
5766 tmp = NULL; 5891 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5767 } else { 5892 int res;
5768 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript"); 5893 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5769 return 1; 5894 if (tmp == NULL) goto failed;
5770 } 5895 res = obj2ast_expr_context(tmp, &ctx, arena);
5771 if (_PyObject_HasAttrId(obj, &PyId_slice)) { 5896 if (res != 0) goto failed;
5772 int res; 5897 Py_XDECREF(tmp);
5773 tmp = _PyObject_GetAttrId(obj, &PyId_slice); 5898 tmp = NULL;
5774 if (tmp == NULL) goto failed; 5899 } else {
5775 res = obj2ast_slice(tmp, &slice, arena); 5900 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
5776 if (res != 0) goto failed; 5901 return 1;
5777 Py_XDECREF(tmp); 5902 }
5778 tmp = NULL; 5903 *out = List(elts, ctx, lineno, col_offset, arena);
5779 } else { 5904 if (*out == NULL) goto failed;
5780 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript"); 5905 return 0;
5781 return 1; 5906 }
5782 } 5907 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type);
5783 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { 5908 if (isinstance == -1) {
5784 int res; 5909 return 1;
5785 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); 5910 }
5786 if (tmp == NULL) goto failed; 5911 if (isinstance) {
5787 res = obj2ast_expr_context(tmp, &ctx, arena); 5912 asdl_seq* elts;
5788 if (res != 0) goto failed; 5913 expr_context_ty ctx;
5789 Py_XDECREF(tmp); 5914
5790 tmp = NULL; 5915 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
5791 } else { 5916 int res;
5792 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript"); 5917 Py_ssize_t len;
5793 return 1; 5918 Py_ssize_t i;
5794 } 5919 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
5795 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); 5920 if (tmp == NULL) goto failed;
5796 if (*out == NULL) goto failed; 5921 if (!PyList_Check(tmp)) {
5797 return 0; 5922 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5798 } 5923 goto failed;
5799 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type); 5924 }
5800 if (isinstance == -1) { 5925 len = PyList_GET_SIZE(tmp);
5801 return 1; 5926 elts = asdl_seq_new(len, arena);
5802 } 5927 if (elts == NULL) goto failed;
5803 if (isinstance) { 5928 for (i = 0; i < len; i++) {
5804 expr_ty value; 5929 expr_ty value;
5805 expr_context_ty ctx; 5930 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5806 5931 if (res != 0) goto failed;
5807 if (_PyObject_HasAttrId(obj, &PyId_value)) { 5932 asdl_seq_SET(elts, i, value);
5808 int res; 5933 }
5809 tmp = _PyObject_GetAttrId(obj, &PyId_value); 5934 Py_XDECREF(tmp);
5810 if (tmp == NULL) goto failed; 5935 tmp = NULL;
5811 res = obj2ast_expr(tmp, &value, arena); 5936 } else {
5812 if (res != 0) goto failed; 5937 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
5813 Py_XDECREF(tmp); 5938 return 1;
5814 tmp = NULL; 5939 }
5815 } else { 5940 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5816 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred"); 5941 int res;
5817 return 1; 5942 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5818 } 5943 if (tmp == NULL) goto failed;
5819 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { 5944 res = obj2ast_expr_context(tmp, &ctx, arena);
5820 int res; 5945 if (res != 0) goto failed;
5821 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); 5946 Py_XDECREF(tmp);
5822 if (tmp == NULL) goto failed; 5947 tmp = NULL;
5823 res = obj2ast_expr_context(tmp, &ctx, arena); 5948 } else {
5824 if (res != 0) goto failed; 5949 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
5825 Py_XDECREF(tmp); 5950 return 1;
5826 tmp = NULL; 5951 }
5827 } else { 5952 *out = Tuple(elts, ctx, lineno, col_offset, arena);
5828 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred"); 5953 if (*out == NULL) goto failed;
5829 return 1; 5954 return 0;
5830 } 5955 }
5831 *out = Starred(value, ctx, lineno, col_offset, arena); 5956
5832 if (*out == NULL) goto failed; 5957 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
5833 return 0; 5958 failed:
5834 } 5959 Py_XDECREF(tmp);
5835 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); 5960 return 1;
5836 if (isinstance == -1) {
5837 return 1;
5838 }
5839 if (isinstance) {
5840 identifier id;
5841 expr_context_ty ctx;
5842
5843 if (_PyObject_HasAttrId(obj, &PyId_id)) {
5844 int res;
5845 tmp = _PyObject_GetAttrId(obj, &PyId_id);
5846 if (tmp == NULL) goto failed;
5847 res = obj2ast_identifier(tmp, &id, arena);
5848 if (res != 0) goto failed;
5849 Py_XDECREF(tmp);
5850 tmp = NULL;
5851 } else {
5852 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
5853 return 1;
5854 }
5855 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5856 int res;
5857 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5858 if (tmp == NULL) goto failed;
5859 res = obj2ast_expr_context(tmp, &ctx, arena);
5860 if (res != 0) goto failed;
5861 Py_XDECREF(tmp);
5862 tmp = NULL;
5863 } else {
5864 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
5865 return 1;
5866 }
5867 *out = Name(id, ctx, lineno, col_offset, arena);
5868 if (*out == NULL) goto failed;
5869 return 0;
5870 }
5871 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type);
5872 if (isinstance == -1) {
5873 return 1;
5874 }
5875 if (isinstance) {
5876 asdl_seq* elts;
5877 expr_context_ty ctx;
5878
5879 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
5880 int res;
5881 Py_ssize_t len;
5882 Py_ssize_t i;
5883 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
5884 if (tmp == NULL) goto failed;
5885 if (!PyList_Check(tmp)) {
5886 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5887 goto failed;
5888 }
5889 len = PyList_GET_SIZE(tmp);
5890 elts = asdl_seq_new(len, arena);
5891 if (elts == NULL) goto failed;
5892 for (i = 0; i < len; i++) {
5893 expr_ty value;
5894 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5895 if (res != 0) goto failed;
5896 asdl_seq_SET(elts, i, value);
5897 }
5898 Py_XDECREF(tmp);
5899 tmp = NULL;
5900 } else {
5901 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
5902 return 1;
5903 }
5904 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5905 int res;
5906 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5907 if (tmp == NULL) goto failed;
5908 res = obj2ast_expr_context(tmp, &ctx, arena);
5909 if (res != 0) goto failed;
5910 Py_XDECREF(tmp);
5911 tmp = NULL;
5912 } else {
5913 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
5914 return 1;
5915 }
5916 *out = List(elts, ctx, lineno, col_offset, arena);
5917 if (*out == NULL) goto failed;
5918 return 0;
5919 }
5920 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type);
5921 if (isinstance == -1) {
5922 return 1;
5923 }
5924 if (isinstance) {
5925 asdl_seq* elts;
5926 expr_context_ty ctx;
5927
5928 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
5929 int res;
5930 Py_ssize_t len;
5931 Py_ssize_t i;
5932 tmp = _PyObject_GetAttrId(obj, &PyId_elts);
5933 if (tmp == NULL) goto failed;
5934 if (!PyList_Check(tmp)) {
5935 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
5936 goto failed;
5937 }
5938 len = PyList_GET_SIZE(tmp);
5939 elts = asdl_seq_new(len, arena);
5940 if (elts == NULL) goto failed;
5941 for (i = 0; i < len; i++) {
5942 expr_ty value;
5943 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
5944 if (res != 0) goto failed;
5945 asdl_seq_SET(elts, i, value);
5946 }
5947 Py_XDECREF(tmp);
5948 tmp = NULL;
5949 } else {
5950 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
5951 return 1;
5952 }
5953 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
5954 int res;
5955 tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
5956 if (tmp == NULL) goto failed;
5957 res = obj2ast_expr_context(tmp, &ctx, arena);
5958 if (res != 0) goto failed;
5959 Py_XDECREF(tmp);
5960 tmp = NULL;
5961 } else {
5962 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
5963 return 1;
5964 }
5965 *out = Tuple(elts, ctx, lineno, col_offset, arena);
5966 if (*out == NULL) goto failed;
5967 return 0;
5968 }
5969
5970 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
5971 failed:
5972 Py_XDECREF(tmp);
5973 return 1;
5974 } 5961 }
5975 5962
5976 int 5963 int
5977 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) 5964 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
5978 { 5965 {
5979 int isinstance; 5966 int isinstance;
5980 5967
5981 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); 5968 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type);
5982 if (isinstance == -1) { 5969 if (isinstance == -1) {
5983 return 1; 5970 return 1;
5984 } 5971 }
5985 if (isinstance) { 5972 if (isinstance) {
5986 *out = Load; 5973 *out = Load;
5987 return 0; 5974 return 0;
5988 } 5975 }
5989 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); 5976 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type);
5990 if (isinstance == -1) { 5977 if (isinstance == -1) {
5991 return 1; 5978 return 1;
5992 } 5979 }
5993 if (isinstance) { 5980 if (isinstance) {
5994 *out = Store; 5981 *out = Store;
5995 return 0; 5982 return 0;
5996 } 5983 }
5997 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); 5984 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type);
5998 if (isinstance == -1) { 5985 if (isinstance == -1) {
5999 return 1; 5986 return 1;
6000 } 5987 }
6001 if (isinstance) { 5988 if (isinstance) {
6002 *out = Del; 5989 *out = Del;
6003 return 0; 5990 return 0;
6004 } 5991 }
6005 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); 5992 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type);
6006 if (isinstance == -1) { 5993 if (isinstance == -1) {
6007 return 1; 5994 return 1;
6008 } 5995 }
6009 if (isinstance) { 5996 if (isinstance) {
6010 *out = AugLoad; 5997 *out = AugLoad;
6011 return 0; 5998 return 0;
6012 } 5999 }
6013 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); 6000 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type);
6014 if (isinstance == -1) { 6001 if (isinstance == -1) {
6015 return 1; 6002 return 1;
6016 } 6003 }
6017 if (isinstance) { 6004 if (isinstance) {
6018 *out = AugStore; 6005 *out = AugStore;
6019 return 0; 6006 return 0;
6020 } 6007 }
6021 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); 6008 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type);
6022 if (isinstance == -1) { 6009 if (isinstance == -1) {
6023 return 1; 6010 return 1;
6024 } 6011 }
6025 if (isinstance) { 6012 if (isinstance) {
6026 *out = Param; 6013 *out = Param;
6027 return 0; 6014 return 0;
6028 } 6015 }
6029 6016
6030 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj); 6017 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
6031 return 1; 6018 return 1;
6032 } 6019 }
6033 6020
6034 int 6021 int
6035 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) 6022 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
6036 { 6023 {
6037 int isinstance; 6024 int isinstance;
6038 6025
6039 PyObject *tmp = NULL; 6026 PyObject *tmp = NULL;
6040 6027
6041 if (obj == Py_None) { 6028 if (obj == Py_None) {
6042 *out = NULL; 6029 *out = NULL;
6043 return 0; 6030 return 0;
6044 } 6031 }
6045 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); 6032 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type);
6046 if (isinstance == -1) { 6033 if (isinstance == -1) {
6047 return 1; 6034 return 1;
6048 } 6035 }
6049 if (isinstance) { 6036 if (isinstance) {
6050 expr_ty lower; 6037 expr_ty lower;
6051 expr_ty upper; 6038 expr_ty upper;
6052 expr_ty step; 6039 expr_ty step;
6053 6040
6054 if (_PyObject_HasAttrId(obj, &PyId_lower)) { 6041 if (_PyObject_HasAttrId(obj, &PyId_lower)) {
6055 int res; 6042 int res;
6056 tmp = _PyObject_GetAttrId(obj, &PyId_lower); 6043 tmp = _PyObject_GetAttrId(obj, &PyId_lower);
6057 if (tmp == NULL) goto failed; 6044 if (tmp == NULL) goto failed;
6058 res = obj2ast_expr(tmp, &lower, arena); 6045 res = obj2ast_expr(tmp, &lower, arena);
6059 if (res != 0) goto failed; 6046 if (res != 0) goto failed;
6060 Py_XDECREF(tmp); 6047 Py_XDECREF(tmp);
6061 tmp = NULL; 6048 tmp = NULL;
6062 } else { 6049 } else {
6063 lower = NULL; 6050 lower = NULL;
6064 } 6051 }
6065 if (_PyObject_HasAttrId(obj, &PyId_upper)) { 6052 if (_PyObject_HasAttrId(obj, &PyId_upper)) {
6066 int res; 6053 int res;
6067 tmp = _PyObject_GetAttrId(obj, &PyId_upper); 6054 tmp = _PyObject_GetAttrId(obj, &PyId_upper);
6068 if (tmp == NULL) goto failed; 6055 if (tmp == NULL) goto failed;
6069 res = obj2ast_expr(tmp, &upper, arena); 6056 res = obj2ast_expr(tmp, &upper, arena);
6070 if (res != 0) goto failed; 6057 if (res != 0) goto failed;
6071 Py_XDECREF(tmp); 6058 Py_XDECREF(tmp);
6072 tmp = NULL; 6059 tmp = NULL;
6073 } else { 6060 } else {
6074 upper = NULL; 6061 upper = NULL;
6075 } 6062 }
6076 if (_PyObject_HasAttrId(obj, &PyId_step)) { 6063 if (_PyObject_HasAttrId(obj, &PyId_step)) {
6077 int res; 6064 int res;
6078 tmp = _PyObject_GetAttrId(obj, &PyId_step); 6065 tmp = _PyObject_GetAttrId(obj, &PyId_step);
6079 if (tmp == NULL) goto failed; 6066 if (tmp == NULL) goto failed;
6080 res = obj2ast_expr(tmp, &step, arena); 6067 res = obj2ast_expr(tmp, &step, arena);
6081 if (res != 0) goto failed; 6068 if (res != 0) goto failed;
6082 Py_XDECREF(tmp); 6069 Py_XDECREF(tmp);
6083 tmp = NULL; 6070 tmp = NULL;
6084 } else { 6071 } else {
6085 step = NULL; 6072 step = NULL;
6086 } 6073 }
6087 *out = Slice(lower, upper, step, arena); 6074 *out = Slice(lower, upper, step, arena);
6088 if (*out == NULL) goto failed; 6075 if (*out == NULL) goto failed;
6089 return 0; 6076 return 0;
6090 } 6077 }
6091 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); 6078 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type);
6092 if (isinstance == -1) { 6079 if (isinstance == -1) {
6093 return 1; 6080 return 1;
6094 } 6081 }
6095 if (isinstance) { 6082 if (isinstance) {
6096 asdl_seq* dims; 6083 asdl_seq* dims;
6097 6084
6098 if (_PyObject_HasAttrId(obj, &PyId_dims)) { 6085 if (_PyObject_HasAttrId(obj, &PyId_dims)) {
6099 int res; 6086 int res;
6100 Py_ssize_t len; 6087 Py_ssize_t len;
6101 Py_ssize_t i; 6088 Py_ssize_t i;
6102 tmp = _PyObject_GetAttrId(obj, &PyId_dims); 6089 tmp = _PyObject_GetAttrId(obj, &PyId_dims);
6103 if (tmp == NULL) goto failed; 6090 if (tmp == NULL) goto failed;
6104 if (!PyList_Check(tmp)) { 6091 if (!PyList_Check(tmp)) {
6105 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name); 6092 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6106 goto failed; 6093 goto failed;
6107 } 6094 }
6108 len = PyList_GET_SIZE(tmp); 6095 len = PyList_GET_SIZE(tmp);
6109 dims = asdl_seq_new(len, arena); 6096 dims = asdl_seq_new(len, arena);
6110 if (dims == NULL) goto failed; 6097 if (dims == NULL) goto failed;
6111 for (i = 0; i < len; i++) { 6098 for (i = 0; i < len; i++) {
6112 slice_ty value; 6099 slice_ty value;
6113 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena); 6100 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena);
6114 if (res != 0) goto failed; 6101 if (res != 0) goto failed;
6115 asdl_seq_SET(dims, i, value); 6102 asdl_seq_SET(dims, i, value);
6116 } 6103 }
6117 Py_XDECREF(tmp); 6104 Py_XDECREF(tmp);
6118 tmp = NULL; 6105 tmp = NULL;
6119 } else { 6106 } else {
6120 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice"); 6107 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice");
6121 return 1; 6108 return 1;
6122 } 6109 }
6123 *out = ExtSlice(dims, arena); 6110 *out = ExtSlice(dims, arena);
6124 if (*out == NULL) goto failed; 6111 if (*out == NULL) goto failed;
6125 return 0; 6112 return 0;
6126 } 6113 }
6127 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); 6114 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type);
6128 if (isinstance == -1) { 6115 if (isinstance == -1) {
6129 return 1; 6116 return 1;
6130 } 6117 }
6131 if (isinstance) { 6118 if (isinstance) {
6132 expr_ty value; 6119 expr_ty value;
6133 6120
6134 if (_PyObject_HasAttrId(obj, &PyId_value)) { 6121 if (_PyObject_HasAttrId(obj, &PyId_value)) {
6135 int res; 6122 int res;
6136 tmp = _PyObject_GetAttrId(obj, &PyId_value); 6123 tmp = _PyObject_GetAttrId(obj, &PyId_value);
6137 if (tmp == NULL) goto failed; 6124 if (tmp == NULL) goto failed;
6138 res = obj2ast_expr(tmp, &value, arena); 6125 res = obj2ast_expr(tmp, &value, arena);
6139 if (res != 0) goto failed; 6126 if (res != 0) goto failed;
6140 Py_XDECREF(tmp); 6127 Py_XDECREF(tmp);
6141 tmp = NULL; 6128 tmp = NULL;
6142 } else { 6129 } else {
6143 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index"); 6130 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index");
6144 return 1; 6131 return 1;
6145 } 6132 }
6146 *out = Index(value, arena); 6133 *out = Index(value, arena);
6147 if (*out == NULL) goto failed; 6134 if (*out == NULL) goto failed;
6148 return 0; 6135 return 0;
6149 } 6136 }
6150 6137
6151 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj); 6138 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj);
6152 failed: 6139 failed:
6153 Py_XDECREF(tmp); 6140 Py_XDECREF(tmp);
6154 return 1; 6141 return 1;
6155 } 6142 }
6156 6143
6157 int 6144 int
6158 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) 6145 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
6159 { 6146 {
6160 int isinstance; 6147 int isinstance;
6161 6148
6162 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); 6149 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type);
6163 if (isinstance == -1) { 6150 if (isinstance == -1) {
6164 return 1; 6151 return 1;
6165 } 6152 }
6166 if (isinstance) { 6153 if (isinstance) {
6167 *out = And; 6154 *out = And;
6168 return 0; 6155 return 0;
6169 } 6156 }
6170 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); 6157 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type);
6171 if (isinstance == -1) { 6158 if (isinstance == -1) {
6172 return 1; 6159 return 1;
6173 } 6160 }
6174 if (isinstance) { 6161 if (isinstance) {
6175 *out = Or; 6162 *out = Or;
6176 return 0; 6163 return 0;
6177 } 6164 }
6178 6165
6179 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj); 6166 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
6180 return 1; 6167 return 1;
6181 } 6168 }
6182 6169
6183 int 6170 int
6184 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) 6171 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
6185 { 6172 {
6186 int isinstance; 6173 int isinstance;
6187 6174
6188 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); 6175 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type);
6189 if (isinstance == -1) { 6176 if (isinstance == -1) {
6190 return 1; 6177 return 1;
6191 } 6178 }
6192 if (isinstance) { 6179 if (isinstance) {
6193 *out = Add; 6180 *out = Add;
6194 return 0; 6181 return 0;
6195 } 6182 }
6196 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); 6183 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type);
6197 if (isinstance == -1) { 6184 if (isinstance == -1) {
6198 return 1; 6185 return 1;
6199 } 6186 }
6200 if (isinstance) { 6187 if (isinstance) {
6201 *out = Sub; 6188 *out = Sub;
6202 return 0; 6189 return 0;
6203 } 6190 }
6204 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); 6191 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type);
6205 if (isinstance == -1) { 6192 if (isinstance == -1) {
6206 return 1; 6193 return 1;
6207 } 6194 }
6208 if (isinstance) { 6195 if (isinstance) {
6209 *out = Mult; 6196 *out = Mult;
6210 return 0; 6197 return 0;
6211 } 6198 }
6212 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); 6199 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type);
6213 if (isinstance == -1) { 6200 if (isinstance == -1) {
6214 return 1; 6201 return 1;
6215 } 6202 }
6216 if (isinstance) { 6203 if (isinstance) {
6217 *out = Div; 6204 *out = Div;
6218 return 0; 6205 return 0;
6219 } 6206 }
6220 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); 6207 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type);
6221 if (isinstance == -1) { 6208 if (isinstance == -1) {
6222 return 1; 6209 return 1;
6223 } 6210 }
6224 if (isinstance) { 6211 if (isinstance) {
6225 *out = Mod; 6212 *out = Mod;
6226 return 0; 6213 return 0;
6227 } 6214 }
6228 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); 6215 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type);
6229 if (isinstance == -1) { 6216 if (isinstance == -1) {
6230 return 1; 6217 return 1;
6231 } 6218 }
6232 if (isinstance) { 6219 if (isinstance) {
6233 *out = Pow; 6220 *out = Pow;
6234 return 0; 6221 return 0;
6235 } 6222 }
6236 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); 6223 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type);
6237 if (isinstance == -1) { 6224 if (isinstance == -1) {
6238 return 1; 6225 return 1;
6239 } 6226 }
6240 if (isinstance) { 6227 if (isinstance) {
6241 *out = LShift; 6228 *out = LShift;
6242 return 0; 6229 return 0;
6243 } 6230 }
6244 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); 6231 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type);
6245 if (isinstance == -1) { 6232 if (isinstance == -1) {
6246 return 1; 6233 return 1;
6247 } 6234 }
6248 if (isinstance) { 6235 if (isinstance) {
6249 *out = RShift; 6236 *out = RShift;
6250 return 0; 6237 return 0;
6251 } 6238 }
6252 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); 6239 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type);
6253 if (isinstance == -1) { 6240 if (isinstance == -1) {
6254 return 1; 6241 return 1;
6255 } 6242 }
6256 if (isinstance) { 6243 if (isinstance) {
6257 *out = BitOr; 6244 *out = BitOr;
6258 return 0; 6245 return 0;
6259 } 6246 }
6260 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); 6247 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type);
6261 if (isinstance == -1) { 6248 if (isinstance == -1) {
6262 return 1; 6249 return 1;
6263 } 6250 }
6264 if (isinstance) { 6251 if (isinstance) {
6265 *out = BitXor; 6252 *out = BitXor;
6266 return 0; 6253 return 0;
6267 } 6254 }
6268 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); 6255 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type);
6269 if (isinstance == -1) { 6256 if (isinstance == -1) {
6270 return 1; 6257 return 1;
6271 } 6258 }
6272 if (isinstance) { 6259 if (isinstance) {
6273 *out = BitAnd; 6260 *out = BitAnd;
6274 return 0; 6261 return 0;
6275 } 6262 }
6276 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); 6263 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type);
6277 if (isinstance == -1) { 6264 if (isinstance == -1) {
6278 return 1; 6265 return 1;
6279 } 6266 }
6280 if (isinstance) { 6267 if (isinstance) {
6281 *out = FloorDiv; 6268 *out = FloorDiv;
6282 return 0; 6269 return 0;
6283 } 6270 }
6284 6271
6285 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj); 6272 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
6286 return 1; 6273 return 1;
6287 } 6274 }
6288 6275
6289 int 6276 int
6290 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) 6277 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
6291 { 6278 {
6292 int isinstance; 6279 int isinstance;
6293 6280
6294 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); 6281 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type);
6295 if (isinstance == -1) { 6282 if (isinstance == -1) {
6296 return 1; 6283 return 1;
6297 } 6284 }
6298 if (isinstance) { 6285 if (isinstance) {
6299 *out = Invert; 6286 *out = Invert;
6300 return 0; 6287 return 0;
6301 } 6288 }
6302 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); 6289 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type);
6303 if (isinstance == -1) { 6290 if (isinstance == -1) {
6304 return 1; 6291 return 1;
6305 } 6292 }
6306 if (isinstance) { 6293 if (isinstance) {
6307 *out = Not; 6294 *out = Not;
6308 return 0; 6295 return 0;
6309 } 6296 }
6310 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); 6297 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type);
6311 if (isinstance == -1) { 6298 if (isinstance == -1) {
6312 return 1; 6299 return 1;
6313 } 6300 }
6314 if (isinstance) { 6301 if (isinstance) {
6315 *out = UAdd; 6302 *out = UAdd;
6316 return 0; 6303 return 0;
6317 } 6304 }
6318 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); 6305 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type);
6319 if (isinstance == -1) { 6306 if (isinstance == -1) {
6320 return 1; 6307 return 1;
6321 } 6308 }
6322 if (isinstance) { 6309 if (isinstance) {
6323 *out = USub; 6310 *out = USub;
6324 return 0; 6311 return 0;
6325 } 6312 }
6326 6313
6327 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj); 6314 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
6328 return 1; 6315 return 1;
6329 } 6316 }
6330 6317
6331 int 6318 int
6332 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) 6319 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
6333 { 6320 {
6334 int isinstance; 6321 int isinstance;
6335 6322
6336 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); 6323 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type);
6337 if (isinstance == -1) { 6324 if (isinstance == -1) {
6338 return 1; 6325 return 1;
6339 } 6326 }
6340 if (isinstance) { 6327 if (isinstance) {
6341 *out = Eq; 6328 *out = Eq;
6342 return 0; 6329 return 0;
6343 } 6330 }
6344 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); 6331 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type);
6345 if (isinstance == -1) { 6332 if (isinstance == -1) {
6346 return 1; 6333 return 1;
6347 } 6334 }
6348 if (isinstance) { 6335 if (isinstance) {
6349 *out = NotEq; 6336 *out = NotEq;
6350 return 0; 6337 return 0;
6351 } 6338 }
6352 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); 6339 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type);
6353 if (isinstance == -1) { 6340 if (isinstance == -1) {
6354 return 1; 6341 return 1;
6355 } 6342 }
6356 if (isinstance) { 6343 if (isinstance) {
6357 *out = Lt; 6344 *out = Lt;
6358 return 0; 6345 return 0;
6359 } 6346 }
6360 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); 6347 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type);
6361 if (isinstance == -1) { 6348 if (isinstance == -1) {
6362 return 1; 6349 return 1;
6363 } 6350 }
6364 if (isinstance) { 6351 if (isinstance) {
6365 *out = LtE; 6352 *out = LtE;
6366 return 0; 6353 return 0;
6367 } 6354 }
6368 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); 6355 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type);
6369 if (isinstance == -1) { 6356 if (isinstance == -1) {
6370 return 1; 6357 return 1;
6371 } 6358 }
6372 if (isinstance) { 6359 if (isinstance) {
6373 *out = Gt; 6360 *out = Gt;
6374 return 0; 6361 return 0;
6375 } 6362 }
6376 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); 6363 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type);
6377 if (isinstance == -1) { 6364 if (isinstance == -1) {
6378 return 1; 6365 return 1;
6379 } 6366 }
6380 if (isinstance) { 6367 if (isinstance) {
6381 *out = GtE; 6368 *out = GtE;
6382 return 0; 6369 return 0;
6383 } 6370 }
6384 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); 6371 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type);
6385 if (isinstance == -1) { 6372 if (isinstance == -1) {
6386 return 1; 6373 return 1;
6387 } 6374 }
6388 if (isinstance) { 6375 if (isinstance) {
6389 *out = Is; 6376 *out = Is;
6390 return 0; 6377 return 0;
6391 } 6378 }
6392 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); 6379 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type);
6393 if (isinstance == -1) { 6380 if (isinstance == -1) {
6394 return 1; 6381 return 1;
6395 } 6382 }
6396 if (isinstance) { 6383 if (isinstance) {
6397 *out = IsNot; 6384 *out = IsNot;
6398 return 0; 6385 return 0;
6399 } 6386 }
6400 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); 6387 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type);
6401 if (isinstance == -1) { 6388 if (isinstance == -1) {
6402 return 1; 6389 return 1;
6403 } 6390 }
6404 if (isinstance) { 6391 if (isinstance) {
6405 *out = In; 6392 *out = In;
6406 return 0; 6393 return 0;
6407 } 6394 }
6408 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); 6395 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type);
6409 if (isinstance == -1) { 6396 if (isinstance == -1) {
6410 return 1; 6397 return 1;
6411 } 6398 }
6412 if (isinstance) { 6399 if (isinstance) {
6413 *out = NotIn; 6400 *out = NotIn;
6414 return 0; 6401 return 0;
6415 } 6402 }
6416 6403
6417 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj); 6404 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
6418 return 1; 6405 return 1;
6419 } 6406 }
6420 6407
6421 int 6408 int
6422 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena) 6409 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
6423 { 6410 {
6424 PyObject* tmp = NULL; 6411 PyObject* tmp = NULL;
6425 expr_ty target; 6412 expr_ty target;
6426 expr_ty iter; 6413 expr_ty iter;
6427 asdl_seq* ifs; 6414 asdl_seq* ifs;
6428 6415
6429 if (_PyObject_HasAttrId(obj, &PyId_target)) { 6416 if (_PyObject_HasAttrId(obj, &PyId_target)) {
6430 int res; 6417 int res;
6431 tmp = _PyObject_GetAttrId(obj, &PyId_target); 6418 tmp = _PyObject_GetAttrId(obj, &PyId_target);
6432 if (tmp == NULL) goto failed; 6419 if (tmp == NULL) goto failed;
6433 res = obj2ast_expr(tmp, &target, arena); 6420 res = obj2ast_expr(tmp, &target, arena);
6434 if (res != 0) goto failed; 6421 if (res != 0) goto failed;
6435 Py_XDECREF(tmp); 6422 Py_XDECREF(tmp);
6436 tmp = NULL; 6423 tmp = NULL;
6437 } else { 6424 } else {
6438 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension"); 6425 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
6439 return 1; 6426 return 1;
6440 } 6427 }
6441 if (_PyObject_HasAttrId(obj, &PyId_iter)) { 6428 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
6442 int res; 6429 int res;
6443 tmp = _PyObject_GetAttrId(obj, &PyId_iter); 6430 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
6444 if (tmp == NULL) goto failed; 6431 if (tmp == NULL) goto failed;
6445 res = obj2ast_expr(tmp, &iter, arena); 6432 res = obj2ast_expr(tmp, &iter, arena);
6446 if (res != 0) goto failed; 6433 if (res != 0) goto failed;
6447 Py_XDECREF(tmp); 6434 Py_XDECREF(tmp);
6448 tmp = NULL; 6435 tmp = NULL;
6449 } else { 6436 } else {
6450 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension"); 6437 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
6451 return 1; 6438 return 1;
6452 } 6439 }
6453 if (_PyObject_HasAttrId(obj, &PyId_ifs)) { 6440 if (_PyObject_HasAttrId(obj, &PyId_ifs)) {
6454 int res; 6441 int res;
6455 Py_ssize_t len; 6442 Py_ssize_t len;
6456 Py_ssize_t i; 6443 Py_ssize_t i;
6457 tmp = _PyObject_GetAttrId(obj, &PyId_ifs); 6444 tmp = _PyObject_GetAttrId(obj, &PyId_ifs);
6458 if (tmp == NULL) goto failed; 6445 if (tmp == NULL) goto failed;
6459 if (!PyList_Check(tmp)) { 6446 if (!PyList_Check(tmp)) {
6460 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name); 6447 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6461 goto failed; 6448 goto failed;
6462 } 6449 }
6463 len = PyList_GET_SIZE(tmp); 6450 len = PyList_GET_SIZE(tmp);
6464 ifs = asdl_seq_new(len, arena); 6451 ifs = asdl_seq_new(len, arena);
6465 if (ifs == NULL) goto failed; 6452 if (ifs == NULL) goto failed;
6466 for (i = 0; i < len; i++) { 6453 for (i = 0; i < len; i++) {
6467 expr_ty value; 6454 expr_ty value;
6468 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); 6455 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
6469 if (res != 0) goto failed; 6456 if (res != 0) goto failed;
6470 asdl_seq_SET(ifs, i, value); 6457 asdl_seq_SET(ifs, i, value);
6471 } 6458 }
6472 Py_XDECREF(tmp); 6459 Py_XDECREF(tmp);
6473 tmp = NULL; 6460 tmp = NULL;
6474 } else { 6461 } else {
6475 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension"); 6462 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
6476 return 1; 6463 return 1;
6477 } 6464 }
6478 *out = comprehension(target, iter, ifs, arena); 6465 *out = comprehension(target, iter, ifs, arena);
6479 return 0; 6466 return 0;
6480 failed: 6467 failed:
6481 Py_XDECREF(tmp); 6468 Py_XDECREF(tmp);
6482 return 1; 6469 return 1;
6483 } 6470 }
6484 6471
6485 int 6472 int
6486 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) 6473 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
6487 { 6474 {
6488 int isinstance; 6475 int isinstance;
6489 6476
6490 PyObject *tmp = NULL; 6477 PyObject *tmp = NULL;
6491 int lineno; 6478 int lineno;
6492 int col_offset; 6479 int col_offset;
6493 6480
6494 if (obj == Py_None) { 6481 if (obj == Py_None) {
6495 *out = NULL; 6482 *out = NULL;
6496 return 0; 6483 return 0;
6497 } 6484 }
6498 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { 6485 if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
6499 int res; 6486 int res;
6500 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); 6487 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
6501 if (tmp == NULL) goto failed; 6488 if (tmp == NULL) goto failed;
6502 res = obj2ast_int(tmp, &lineno, arena); 6489 res = obj2ast_int(tmp, &lineno, arena);
6490 if (res != 0) goto failed;
6491 Py_XDECREF(tmp);
6492 tmp = NULL;
6493 } else {
6494 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
6495 return 1;
6496 }
6497 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
6498 int res;
6499 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
6500 if (tmp == NULL) goto failed;
6501 res = obj2ast_int(tmp, &col_offset, arena);
6502 if (res != 0) goto failed;
6503 Py_XDECREF(tmp);
6504 tmp = NULL;
6505 } else {
6506 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
6507 return 1;
6508 }
6509 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);
6510 if (isinstance == -1) {
6511 return 1;
6512 }
6513 if (isinstance) {
6514 expr_ty type;
6515 identifier name;
6516 asdl_seq* body;
6517
6518 if (_PyObject_HasAttrId(obj, &PyId_type)) {
6519 int res;
6520 tmp = _PyObject_GetAttrId(obj, &PyId_type);
6521 if (tmp == NULL) goto failed;
6522 res = obj2ast_expr(tmp, &type, arena);
6523 if (res != 0) goto failed;
6524 Py_XDECREF(tmp);
6525 tmp = NULL;
6526 } else {
6527 type = NULL;
6528 }
6529 if (_PyObject_HasAttrId(obj, &PyId_name)) {
6530 int res;
6531 tmp = _PyObject_GetAttrId(obj, &PyId_name);
6532 if (tmp == NULL) goto failed;
6533 res = obj2ast_identifier(tmp, &name, arena);
6534 if (res != 0) goto failed;
6535 Py_XDECREF(tmp);
6536 tmp = NULL;
6537 } else {
6538 name = NULL;
6539 }
6540 if (_PyObject_HasAttrId(obj, &PyId_body)) {
6541 int res;
6542 Py_ssize_t len;
6543 Py_ssize_t i;
6544 tmp = _PyObject_GetAttrId(obj, &PyId_body);
6545 if (tmp == NULL) goto failed;
6546 if (!PyList_Check(tmp)) {
6547 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6548 goto failed;
6549 }
6550 len = PyList_GET_SIZE(tmp);
6551 body = asdl_seq_new(len, arena);
6552 if (body == NULL) goto failed;
6553 for (i = 0; i < len; i++) {
6554 stmt_ty value;
6555 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
6503 if (res != 0) goto failed; 6556 if (res != 0) goto failed;
6504 Py_XDECREF(tmp); 6557 asdl_seq_SET(body, i, value);
6505 tmp = NULL; 6558 }
6506 } else { 6559 Py_XDECREF(tmp);
6507 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler"); 6560 tmp = NULL;
6508 return 1; 6561 } else {
6509 } 6562 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
6510 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { 6563 return 1;
6511 int res; 6564 }
6512 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); 6565 *out = ExceptHandler(type, name, body, lineno, col_offset, arena);
6513 if (tmp == NULL) goto failed; 6566 if (*out == NULL) goto failed;
6514 res = obj2ast_int(tmp, &col_offset, arena); 6567 return 0;
6515 if (res != 0) goto failed; 6568 }
6516 Py_XDECREF(tmp); 6569
6517 tmp = NULL; 6570 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
6518 } else { 6571 failed:
6519 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); 6572 Py_XDECREF(tmp);
6520 return 1; 6573 return 1;
6521 }
6522 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);
6523 if (isinstance == -1) {
6524 return 1;
6525 }
6526 if (isinstance) {
6527 expr_ty type;
6528 identifier name;
6529 asdl_seq* body;
6530
6531 if (_PyObject_HasAttrId(obj, &PyId_type)) {
6532 int res;
6533 tmp = _PyObject_GetAttrId(obj, &PyId_type);
6534 if (tmp == NULL) goto failed;
6535 res = obj2ast_expr(tmp, &type, arena);
6536 if (res != 0) goto failed;
6537 Py_XDECREF(tmp);
6538 tmp = NULL;
6539 } else {
6540 type = NULL;
6541 }
6542 if (_PyObject_HasAttrId(obj, &PyId_name)) {
6543 int res;
6544 tmp = _PyObject_GetAttrId(obj, &PyId_name);
6545 if (tmp == NULL) goto failed;
6546 res = obj2ast_identifier(tmp, &name, arena);
6547 if (res != 0) goto failed;
6548 Py_XDECREF(tmp);
6549 tmp = NULL;
6550 } else {
6551 name = NULL;
6552 }
6553 if (_PyObject_HasAttrId(obj, &PyId_body)) {
6554 int res;
6555 Py_ssize_t len;
6556 Py_ssize_t i;
6557 tmp = _PyObject_GetAttrId(obj, &PyId_body);
6558 if (tmp == NULL) goto failed;
6559 if (!PyList_Check(tmp)) {
6560 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6561 goto failed;
6562 }
6563 len = PyList_GET_SIZE(tmp);
6564 body = asdl_seq_new(len, arena);
6565 if (body == NULL) goto failed;
6566 for (i = 0; i < len; i++) {
6567 stmt_ty value;
6568 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
6569 if (res != 0) goto failed;
6570 asdl_seq_SET(body, i, value);
6571 }
6572 Py_XDECREF(tmp);
6573 tmp = NULL;
6574 } else {
6575 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
6576 return 1;
6577 }
6578 *out = ExceptHandler(type, name, body, lineno, col_offset,
6579 arena);
6580 if (*out == NULL) goto failed;
6581 return 0;
6582 }
6583
6584 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
6585 failed:
6586 Py_XDECREF(tmp);
6587 return 1;
6588 } 6574 }
6589 6575
6590 int 6576 int
6591 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena) 6577 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
6592 { 6578 {
6593 PyObject* tmp = NULL; 6579 PyObject* tmp = NULL;
6594 asdl_seq* args; 6580 asdl_seq* args;
6595 identifier vararg; 6581 identifier vararg;
6596 expr_ty varargannotation; 6582 expr_ty varargannotation;
6597 asdl_seq* kwonlyargs; 6583 asdl_seq* kwonlyargs;
6598 identifier kwarg; 6584 identifier kwarg;
6599 expr_ty kwargannotation; 6585 expr_ty kwargannotation;
6600 asdl_seq* defaults; 6586 asdl_seq* defaults;
6601 asdl_seq* kw_defaults; 6587 asdl_seq* kw_defaults;
6602 6588
6603 if (_PyObject_HasAttrId(obj, &PyId_args)) { 6589 if (_PyObject_HasAttrId(obj, &PyId_args)) {
6604 int res; 6590 int res;
6605 Py_ssize_t len; 6591 Py_ssize_t len;
6606 Py_ssize_t i; 6592 Py_ssize_t i;
6607 tmp = _PyObject_GetAttrId(obj, &PyId_args); 6593 tmp = _PyObject_GetAttrId(obj, &PyId_args);
6608 if (tmp == NULL) goto failed; 6594 if (tmp == NULL) goto failed;
6609 if (!PyList_Check(tmp)) { 6595 if (!PyList_Check(tmp)) {
6610 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); 6596 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6611 goto failed; 6597 goto failed;
6612 } 6598 }
6613 len = PyList_GET_SIZE(tmp); 6599 len = PyList_GET_SIZE(tmp);
6614 args = asdl_seq_new(len, arena); 6600 args = asdl_seq_new(len, arena);
6615 if (args == NULL) goto failed; 6601 if (args == NULL) goto failed;
6616 for (i = 0; i < len; i++) { 6602 for (i = 0; i < len; i++) {
6617 arg_ty value; 6603 arg_ty value;
6618 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); 6604 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
6619 if (res != 0) goto failed; 6605 if (res != 0) goto failed;
6620 asdl_seq_SET(args, i, value); 6606 asdl_seq_SET(args, i, value);
6621 } 6607 }
6622 Py_XDECREF(tmp); 6608 Py_XDECREF(tmp);
6623 tmp = NULL; 6609 tmp = NULL;
6624 } else { 6610 } else {
6625 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments"); 6611 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
6626 return 1; 6612 return 1;
6627 } 6613 }
6628 if (_PyObject_HasAttrId(obj, &PyId_vararg)) { 6614 if (_PyObject_HasAttrId(obj, &PyId_vararg)) {
6629 int res; 6615 int res;
6630 tmp = _PyObject_GetAttrId(obj, &PyId_vararg); 6616 tmp = _PyObject_GetAttrId(obj, &PyId_vararg);
6631 if (tmp == NULL) goto failed; 6617 if (tmp == NULL) goto failed;
6632 res = obj2ast_identifier(tmp, &vararg, arena); 6618 res = obj2ast_identifier(tmp, &vararg, arena);
6633 if (res != 0) goto failed; 6619 if (res != 0) goto failed;
6634 Py_XDECREF(tmp); 6620 Py_XDECREF(tmp);
6635 tmp = NULL; 6621 tmp = NULL;
6636 } else { 6622 } else {
6637 vararg = NULL; 6623 vararg = NULL;
6638 } 6624 }
6639 if (_PyObject_HasAttrId(obj, &PyId_varargannotation)) { 6625 if (_PyObject_HasAttrId(obj, &PyId_varargannotation)) {
6640 int res; 6626 int res;
6641 tmp = _PyObject_GetAttrId(obj, &PyId_varargannotation); 6627 tmp = _PyObject_GetAttrId(obj, &PyId_varargannotation);
6642 if (tmp == NULL) goto failed; 6628 if (tmp == NULL) goto failed;
6643 res = obj2ast_expr(tmp, &varargannotation, arena); 6629 res = obj2ast_expr(tmp, &varargannotation, arena);
6644 if (res != 0) goto failed; 6630 if (res != 0) goto failed;
6645 Py_XDECREF(tmp); 6631 Py_XDECREF(tmp);
6646 tmp = NULL; 6632 tmp = NULL;
6647 } else { 6633 } else {
6648 varargannotation = NULL; 6634 varargannotation = NULL;
6649 } 6635 }
6650 if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) { 6636 if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) {
6651 int res; 6637 int res;
6652 Py_ssize_t len; 6638 Py_ssize_t len;
6653 Py_ssize_t i; 6639 Py_ssize_t i;
6654 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs); 6640 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs);
6655 if (tmp == NULL) goto failed; 6641 if (tmp == NULL) goto failed;
6656 if (!PyList_Check(tmp)) { 6642 if (!PyList_Check(tmp)) {
6657 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name); 6643 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6658 goto failed; 6644 goto failed;
6659 } 6645 }
6660 len = PyList_GET_SIZE(tmp); 6646 len = PyList_GET_SIZE(tmp);
6661 kwonlyargs = asdl_seq_new(len, arena); 6647 kwonlyargs = asdl_seq_new(len, arena);
6662 if (kwonlyargs == NULL) goto failed; 6648 if (kwonlyargs == NULL) goto failed;
6663 for (i = 0; i < len; i++) { 6649 for (i = 0; i < len; i++) {
6664 arg_ty value; 6650 arg_ty value;
6665 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); 6651 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
6666 if (res != 0) goto failed; 6652 if (res != 0) goto failed;
6667 asdl_seq_SET(kwonlyargs, i, value); 6653 asdl_seq_SET(kwonlyargs, i, value);
6668 } 6654 }
6669 Py_XDECREF(tmp); 6655 Py_XDECREF(tmp);
6670 tmp = NULL; 6656 tmp = NULL;
6671 } else { 6657 } else {
6672 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments"); 6658 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
6673 return 1; 6659 return 1;
6674 } 6660 }
6675 if (_PyObject_HasAttrId(obj, &PyId_kwarg)) { 6661 if (_PyObject_HasAttrId(obj, &PyId_kwarg)) {
6676 int res; 6662 int res;
6677 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg); 6663 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg);
6678 if (tmp == NULL) goto failed; 6664 if (tmp == NULL) goto failed;
6679 res = obj2ast_identifier(tmp, &kwarg, arena); 6665 res = obj2ast_identifier(tmp, &kwarg, arena);
6680 if (res != 0) goto failed; 6666 if (res != 0) goto failed;
6681 Py_XDECREF(tmp); 6667 Py_XDECREF(tmp);
6682 tmp = NULL; 6668 tmp = NULL;
6683 } else { 6669 } else {
6684 kwarg = NULL; 6670 kwarg = NULL;
6685 } 6671 }
6686 if (_PyObject_HasAttrId(obj, &PyId_kwargannotation)) { 6672 if (_PyObject_HasAttrId(obj, &PyId_kwargannotation)) {
6687 int res; 6673 int res;
6688 tmp = _PyObject_GetAttrId(obj, &PyId_kwargannotation); 6674 tmp = _PyObject_GetAttrId(obj, &PyId_kwargannotation);
6689 if (tmp == NULL) goto failed; 6675 if (tmp == NULL) goto failed;
6690 res = obj2ast_expr(tmp, &kwargannotation, arena); 6676 res = obj2ast_expr(tmp, &kwargannotation, arena);
6691 if (res != 0) goto failed; 6677 if (res != 0) goto failed;
6692 Py_XDECREF(tmp); 6678 Py_XDECREF(tmp);
6693 tmp = NULL; 6679 tmp = NULL;
6694 } else { 6680 } else {
6695 kwargannotation = NULL; 6681 kwargannotation = NULL;
6696 } 6682 }
6697 if (_PyObject_HasAttrId(obj, &PyId_defaults)) { 6683 if (_PyObject_HasAttrId(obj, &PyId_defaults)) {
6698 int res; 6684 int res;
6699 Py_ssize_t len; 6685 Py_ssize_t len;
6700 Py_ssize_t i; 6686 Py_ssize_t i;
6701 tmp = _PyObject_GetAttrId(obj, &PyId_defaults); 6687 tmp = _PyObject_GetAttrId(obj, &PyId_defaults);
6702 if (tmp == NULL) goto failed; 6688 if (tmp == NULL) goto failed;
6703 if (!PyList_Check(tmp)) { 6689 if (!PyList_Check(tmp)) {
6704 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); 6690 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6705 goto failed; 6691 goto failed;
6706 } 6692 }
6707 len = PyList_GET_SIZE(tmp); 6693 len = PyList_GET_SIZE(tmp);
6708 defaults = asdl_seq_new(len, arena); 6694 defaults = asdl_seq_new(len, arena);
6709 if (defaults == NULL) goto failed; 6695 if (defaults == NULL) goto failed;
6710 for (i = 0; i < len; i++) { 6696 for (i = 0; i < len; i++) {
6711 expr_ty value; 6697 expr_ty value;
6712 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); 6698 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
6713 if (res != 0) goto failed; 6699 if (res != 0) goto failed;
6714 asdl_seq_SET(defaults, i, value); 6700 asdl_seq_SET(defaults, i, value);
6715 } 6701 }
6716 Py_XDECREF(tmp); 6702 Py_XDECREF(tmp);
6717 tmp = NULL; 6703 tmp = NULL;
6718 } else { 6704 } else {
6719 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); 6705 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
6720 return 1; 6706 return 1;
6721 } 6707 }
6722 if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) { 6708 if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) {
6723 int res; 6709 int res;
6724 Py_ssize_t len; 6710 Py_ssize_t len;
6725 Py_ssize_t i; 6711 Py_ssize_t i;
6726 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults); 6712 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults);
6727 if (tmp == NULL) goto failed; 6713 if (tmp == NULL) goto failed;
6728 if (!PyList_Check(tmp)) { 6714 if (!PyList_Check(tmp)) {
6729 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); 6715 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
6730 goto failed; 6716 goto failed;
6731 } 6717 }
6732 len = PyList_GET_SIZE(tmp); 6718 len = PyList_GET_SIZE(tmp);
6733 kw_defaults = asdl_seq_new(len, arena); 6719 kw_defaults = asdl_seq_new(len, arena);
6734 if (kw_defaults == NULL) goto failed; 6720 if (kw_defaults == NULL) goto failed;
6735 for (i = 0; i < len; i++) { 6721 for (i = 0; i < len; i++) {
6736 expr_ty value; 6722 expr_ty value;
6737 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); 6723 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
6738 if (res != 0) goto failed; 6724 if (res != 0) goto failed;
6739 asdl_seq_SET(kw_defaults, i, value); 6725 asdl_seq_SET(kw_defaults, i, value);
6740 } 6726 }
6741 Py_XDECREF(tmp); 6727 Py_XDECREF(tmp);
6742 tmp = NULL; 6728 tmp = NULL;
6743 } else { 6729 } else {
6744 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments"); 6730 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
6745 return 1; 6731 return 1;
6746 } 6732 }
6747 *out = arguments(args, vararg, varargannotation, kwonlyargs, kwarg, 6733 *out = arguments(args, vararg, varargannotation, kwonlyargs, kwarg,
6748 kwargannotation, defaults, kw_defaults, arena); 6734 kwargannotation, defaults, kw_defaults, arena);
6749 return 0; 6735 return 0;
6750 failed: 6736 failed:
6751 Py_XDECREF(tmp); 6737 Py_XDECREF(tmp);
6752 return 1; 6738 return 1;
6753 } 6739 }
6754 6740
6755 int 6741 int
6756 obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena) 6742 obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
6757 { 6743 {
6758 PyObject* tmp = NULL; 6744 PyObject* tmp = NULL;
6759 identifier arg; 6745 identifier arg;
6760 expr_ty annotation; 6746 expr_ty annotation;
6761 6747
6762 if (_PyObject_HasAttrId(obj, &PyId_arg)) { 6748 if (_PyObject_HasAttrId(obj, &PyId_arg)) {
6763 int res; 6749 int res;
6764 tmp = _PyObject_GetAttrId(obj, &PyId_arg); 6750 tmp = _PyObject_GetAttrId(obj, &PyId_arg);
6765 if (tmp == NULL) goto failed; 6751 if (tmp == NULL) goto failed;
6766 res = obj2ast_identifier(tmp, &arg, arena); 6752 res = obj2ast_identifier(tmp, &arg, arena);
6767 if (res != 0) goto failed; 6753 if (res != 0) goto failed;
6768 Py_XDECREF(tmp); 6754 Py_XDECREF(tmp);
6769 tmp = NULL; 6755 tmp = NULL;
6770 } else { 6756 } else {
6771 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg"); 6757 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
6772 return 1; 6758 return 1;
6773 } 6759 }
6774 if (_PyObject_HasAttrId(obj, &PyId_annotation)) { 6760 if (_PyObject_HasAttrId(obj, &PyId_annotation)) {
6775 int res; 6761 int res;
6776 tmp = _PyObject_GetAttrId(obj, &PyId_annotation); 6762 tmp = _PyObject_GetAttrId(obj, &PyId_annotation);
6777 if (tmp == NULL) goto failed; 6763 if (tmp == NULL) goto failed;
6778 res = obj2ast_expr(tmp, &annotation, arena); 6764 res = obj2ast_expr(tmp, &annotation, arena);
6779 if (res != 0) goto failed; 6765 if (res != 0) goto failed;
6780 Py_XDECREF(tmp); 6766 Py_XDECREF(tmp);
6781 tmp = NULL; 6767 tmp = NULL;
6782 } else { 6768 } else {
6783 annotation = NULL; 6769 annotation = NULL;
6784 } 6770 }
6785 *out = arg(arg, annotation, arena); 6771 *out = arg(arg, annotation, arena);
6786 return 0; 6772 return 0;
6787 failed: 6773 failed:
6788 Py_XDECREF(tmp); 6774 Py_XDECREF(tmp);
6789 return 1; 6775 return 1;
6790 } 6776 }
6791 6777
6792 int 6778 int
6793 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena) 6779 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)
6794 { 6780 {
6795 PyObject* tmp = NULL; 6781 PyObject* tmp = NULL;
6796 identifier arg; 6782 identifier arg;
6797 expr_ty value; 6783 expr_ty value;
6798 6784
6799 if (_PyObject_HasAttrId(obj, &PyId_arg)) { 6785 if (_PyObject_HasAttrId(obj, &PyId_arg)) {
6800 int res; 6786 int res;
6801 tmp = _PyObject_GetAttrId(obj, &PyId_arg); 6787 tmp = _PyObject_GetAttrId(obj, &PyId_arg);
6802 if (tmp == NULL) goto failed; 6788 if (tmp == NULL) goto failed;
6803 res = obj2ast_identifier(tmp, &arg, arena); 6789 res = obj2ast_identifier(tmp, &arg, arena);
6804 if (res != 0) goto failed; 6790 if (res != 0) goto failed;
6805 Py_XDECREF(tmp); 6791 Py_XDECREF(tmp);
6806 tmp = NULL; 6792 tmp = NULL;
6807 } else { 6793 } else {
6808 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword"); 6794 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword");
6809 return 1; 6795 return 1;
6810 } 6796 }
6811 if (_PyObject_HasAttrId(obj, &PyId_value)) { 6797 if (_PyObject_HasAttrId(obj, &PyId_value)) {
6812 int res; 6798 int res;
6813 tmp = _PyObject_GetAttrId(obj, &PyId_value); 6799 tmp = _PyObject_GetAttrId(obj, &PyId_value);
6814 if (tmp == NULL) goto failed; 6800 if (tmp == NULL) goto failed;
6815 res = obj2ast_expr(tmp, &value, arena); 6801 res = obj2ast_expr(tmp, &value, arena);
6816 if (res != 0) goto failed; 6802 if (res != 0) goto failed;
6817 Py_XDECREF(tmp); 6803 Py_XDECREF(tmp);
6818 tmp = NULL; 6804 tmp = NULL;
6819 } else { 6805 } else {
6820 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword"); 6806 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
6821 return 1; 6807 return 1;
6822 } 6808 }
6823 *out = keyword(arg, value, arena); 6809 *out = keyword(arg, value, arena);
6824 return 0; 6810 return 0;
6825 failed: 6811 failed:
6826 Py_XDECREF(tmp); 6812 Py_XDECREF(tmp);
6827 return 1; 6813 return 1;
6828 } 6814 }
6829 6815
6830 int 6816 int
6831 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena) 6817 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
6832 { 6818 {
6833 PyObject* tmp = NULL; 6819 PyObject* tmp = NULL;
6834 identifier name; 6820 identifier name;
6835 identifier asname; 6821 identifier asname;
6836 6822
6837 if (_PyObject_HasAttrId(obj, &PyId_name)) { 6823 if (_PyObject_HasAttrId(obj, &PyId_name)) {
6838 int res; 6824 int res;
6839 tmp = _PyObject_GetAttrId(obj, &PyId_name); 6825 tmp = _PyObject_GetAttrId(obj, &PyId_name);
6840 if (tmp == NULL) goto failed; 6826 if (tmp == NULL) goto failed;
6841 res = obj2ast_identifier(tmp, &name, arena); 6827 res = obj2ast_identifier(tmp, &name, arena);
6842 if (res != 0) goto failed; 6828 if (res != 0) goto failed;
6843 Py_XDECREF(tmp); 6829 Py_XDECREF(tmp);
6844 tmp = NULL; 6830 tmp = NULL;
6845 } else { 6831 } else {
6846 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias"); 6832 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
6847 return 1; 6833 return 1;
6848 } 6834 }
6849 if (_PyObject_HasAttrId(obj, &PyId_asname)) { 6835 if (_PyObject_HasAttrId(obj, &PyId_asname)) {
6850 int res; 6836 int res;
6851 tmp = _PyObject_GetAttrId(obj, &PyId_asname); 6837 tmp = _PyObject_GetAttrId(obj, &PyId_asname);
6852 if (tmp == NULL) goto failed; 6838 if (tmp == NULL) goto failed;
6853 res = obj2ast_identifier(tmp, &asname, arena); 6839 res = obj2ast_identifier(tmp, &asname, arena);
6854 if (res != 0) goto failed; 6840 if (res != 0) goto failed;
6855 Py_XDECREF(tmp); 6841 Py_XDECREF(tmp);
6856 tmp = NULL; 6842 tmp = NULL;
6857 } else { 6843 } else {
6858 asname = NULL; 6844 asname = NULL;
6859 } 6845 }
6860 *out = alias(name, asname, arena); 6846 *out = alias(name, asname, arena);
6861 return 0; 6847 return 0;
6862 failed: 6848 failed:
6863 Py_XDECREF(tmp); 6849 Py_XDECREF(tmp);
6864 return 1; 6850 return 1;
6865 } 6851 }
6866 6852
6867 int 6853 int
6868 obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena) 6854 obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
6869 { 6855 {
6870 PyObject* tmp = NULL; 6856 PyObject* tmp = NULL;
6871 expr_ty context_expr; 6857 expr_ty context_expr;
6872 expr_ty optional_vars; 6858 expr_ty optional_vars;
6873 6859
6874 if (_PyObject_HasAttrId(obj, &PyId_context_expr)) { 6860 if (_PyObject_HasAttrId(obj, &PyId_context_expr)) {
6875 int res; 6861 int res;
6876 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr); 6862 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr);
6877 if (tmp == NULL) goto failed; 6863 if (tmp == NULL) goto failed;
6878 res = obj2ast_expr(tmp, &context_expr, arena); 6864 res = obj2ast_expr(tmp, &context_expr, arena);
6879 if (res != 0) goto failed; 6865 if (res != 0) goto failed;
6880 Py_XDECREF(tmp); 6866 Py_XDECREF(tmp);
6881 tmp = NULL; 6867 tmp = NULL;
6882 } else { 6868 } else {
6883 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem"); 6869 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
6884 return 1; 6870 return 1;
6885 } 6871 }
6886 if (_PyObject_HasAttrId(obj, &PyId_optional_vars)) { 6872 if (_PyObject_HasAttrId(obj, &PyId_optional_vars)) {
6887 int res; 6873 int res;
6888 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars); 6874 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars);
6889 if (tmp == NULL) goto failed; 6875 if (tmp == NULL) goto failed;
6890 res = obj2ast_expr(tmp, &optional_vars, arena); 6876 res = obj2ast_expr(tmp, &optional_vars, arena);
6891 if (res != 0) goto failed; 6877 if (res != 0) goto failed;
6892 Py_XDECREF(tmp); 6878 Py_XDECREF(tmp);
6893 tmp = NULL; 6879 tmp = NULL;
6894 } else { 6880 } else {
6895 optional_vars = NULL; 6881 optional_vars = NULL;
6896 } 6882 }
6897 *out = withitem(context_expr, optional_vars, arena); 6883 *out = withitem(context_expr, optional_vars, arena);
6898 return 0; 6884 return 0;
6899 failed: 6885 failed:
6900 Py_XDECREF(tmp); 6886 Py_XDECREF(tmp);
6901 return 1; 6887 return 1;
6902 } 6888 }
6903 6889
6904 6890
6905 static struct PyModuleDef _astmodule = { 6891 static struct PyModuleDef _astmodule = {
6906 PyModuleDef_HEAD_INIT, "_ast" 6892 PyModuleDef_HEAD_INIT, "_ast"
6907 }; 6893 };
6908 PyMODINIT_FUNC 6894 PyMODINIT_FUNC
6909 PyInit__ast(void) 6895 PyInit__ast(void)
6910 { 6896 {
6911 PyObject *m, *d; 6897 PyObject *m, *d;
6912 if (!init_types()) return NULL; 6898 if (!init_types()) return NULL;
6913 m = PyModule_Create(&_astmodule); 6899 m = PyModule_Create(&_astmodule);
6914 if (!m) return NULL; 6900 if (!m) return NULL;
6915 d = PyModule_GetDict(m); 6901 d = PyModule_GetDict(m);
6916 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return 6902 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL;
6917 NULL; 6903 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
6918 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) 6904 return NULL;
6919 return NULL; 6905 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return NULL;
6920 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return 6906 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) return
6921 NULL; 6907 NULL;
6922 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) 6908 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) <
6923 return NULL; 6909 0) return NULL;
6924 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) 6910 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < 0)
6925 < 0) return NULL; 6911 return NULL;
6926 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < 6912 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return
6927 0) return NULL; 6913 NULL;
6928 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return 6914 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return NULL;
6929 NULL; 6915 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) <
6930 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return 6916 0) return NULL;
6931 NULL; 6917 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0)
6932 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) 6918 return NULL;
6933 < 0) return NULL; 6919 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) return
6934 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0) 6920 NULL;
6935 return NULL; 6921 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) return
6936 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) 6922 NULL;
6937 return NULL; 6923 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) return
6938 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) 6924 NULL;
6939 return NULL; 6925 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 0)
6940 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) 6926 return NULL;
6941 return NULL; 6927 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return NULL;
6942 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 6928 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return
6943 0) return NULL; 6929 NULL;
6944 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return 6930 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL;
6945 NULL; 6931 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return NULL;
6946 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return 6932 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return
6947 NULL; 6933 NULL;
6948 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL; 6934 if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return NULL;
6949 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return 6935 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) return
6950 NULL; 6936 NULL;
6951 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return 6937 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) return
6952 NULL; 6938 NULL;
6953 if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return 6939 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < 0)
6954 NULL; 6940 return NULL;
6955 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) 6941 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) return
6956 return NULL; 6942 NULL;
6957 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) 6943 if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0)
6958 return NULL; 6944 return NULL;
6959 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < 6945 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return NULL;
6960 0) return NULL; 6946 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return NULL;
6961 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) 6947 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return
6962 return NULL; 6948 NULL;
6963 if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0) 6949 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0)
6964 return NULL; 6950 return NULL;
6965 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return 6951 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return NULL;
6966 NULL; 6952 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) return
6967 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return 6953 NULL;
6968 NULL; 6954 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return
6969 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return 6955 NULL;
6970 NULL; 6956 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) return
6971 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0) 6957 NULL;
6972 return NULL; 6958 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) return
6973 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return 6959 NULL;
6974 NULL; 6960 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return
6975 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) 6961 NULL;
6976 return NULL; 6962 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return NULL;
6977 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return 6963 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return NULL;
6978 NULL; 6964 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0)
6979 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) 6965 return NULL;
6980 return NULL; 6966 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) return
6981 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) 6967 NULL;
6982 return NULL; 6968 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0)
6983 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return 6969 return NULL;
6984 NULL; 6970 if (PyDict_SetItemString(d, "GeneratorExp", (PyObject*)GeneratorExp_type) <
6985 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return 6971 0) return NULL;
6986 NULL; 6972 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return
6987 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return 6973 NULL;
6988 NULL; 6974 if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) < 0)
6989 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) 6975 return NULL;
6990 return NULL; 6976 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) return
6991 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) 6977 NULL;
6992 return NULL; 6978 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return NULL;
6993 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0) 6979 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return NULL;
6994 return NULL; 6980 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return NULL;
6995 if (PyDict_SetItemString(d, "GeneratorExp", 6981 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return
6996 (PyObject*)GeneratorExp_type) < 0) return NULL; 6982 NULL;
6997 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return 6983 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0)
6998 NULL; 6984 return NULL;
6999 if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) < 6985 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0)
7000 0) return NULL; 6986 return NULL;
7001 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) 6987 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0)
7002 return NULL; 6988 return NULL;
7003 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return 6989 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0) return
7004 NULL; 6990 NULL;
7005 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return 6991 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return NULL;
7006 NULL; 6992 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return NULL;
7007 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return 6993 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return
7008 NULL; 6994 NULL;
7009 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return 6995 if (PyDict_SetItemString(d, "expr_context", (PyObject*)expr_context_type) <
7010 NULL; 6996 0) return NULL;
7011 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) 6997 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return NULL;
7012 return NULL; 6998 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return
7013 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 6999 NULL;
7014 0) return NULL; 7000 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return NULL;
7015 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 7001 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) return
7016 0) return NULL; 7002 NULL;
7017 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0) 7003 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0)
7018 return NULL; 7004 return NULL;
7019 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return 7005 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return
7020 NULL; 7006 NULL;
7021 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return 7007 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return
7022 NULL; 7008 NULL;
7023 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return 7009 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return
7024 NULL; 7010 NULL;
7025 if (PyDict_SetItemString(d, "expr_context", 7011 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0)
7026 (PyObject*)expr_context_type) < 0) return NULL; 7012 return NULL;
7027 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return 7013 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return
7028 NULL; 7014 NULL;
7029 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return 7015 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) return
7030 NULL; 7016 NULL;
7031 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return 7017 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return NULL;
7032 NULL; 7018 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL;
7033 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) 7019 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0)
7034 return NULL; 7020 return NULL;
7035 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0) 7021 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return NULL;
7036 return NULL; 7022 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return NULL;
7037 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return 7023 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return NULL;
7038 NULL; 7024 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return NULL;
7039 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return 7025 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return NULL;
7040 NULL; 7026 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return NULL;
7041 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return 7027 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) return
7042 NULL; 7028 NULL;
7043 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) 7029 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) return
7044 return NULL; 7030 NULL;
7045 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return 7031 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return
7046 NULL; 7032 NULL;
7047 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) 7033 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) return
7048 return NULL; 7034 NULL;
7049 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return 7035 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) return
7050 NULL; 7036 NULL;
7051 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL; 7037 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0)
7052 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0) 7038 return NULL;
7053 return NULL; 7039 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) return
7054 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return 7040 NULL;
7055 NULL; 7041 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) return
7056 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return 7042 NULL;
7057 NULL; 7043 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return NULL;
7058 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return 7044 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return NULL;
7059 NULL; 7045 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return NULL;
7060 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return 7046 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return
7061 NULL; 7047 NULL;
7062 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return 7048 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL;
7063 NULL; 7049 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return
7064 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return 7050 NULL;
7065 NULL; 7051 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL;
7066 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) 7052 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return NULL;
7067 return NULL; 7053 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL;
7068 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) 7054 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return NULL;
7069 return NULL; 7055 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL;
7070 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return 7056 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return
7071 NULL; 7057 NULL;
7072 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) 7058 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL;
7073 return NULL; 7059 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return
7074 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) 7060 NULL;
7075 return NULL; 7061 if (PyDict_SetItemString(d, "comprehension", (PyObject*)comprehension_type)
7076 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0) 7062 < 0) return NULL;
7077 return NULL; 7063 if (PyDict_SetItemString(d, "excepthandler", (PyObject*)excepthandler_type)
7078 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) 7064 < 0) return NULL;
7079 return NULL; 7065 if (PyDict_SetItemString(d, "ExceptHandler", (PyObject*)ExceptHandler_type)
7080 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) 7066 < 0) return NULL;
7081 return NULL; 7067 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 0)
7082 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return 7068 return NULL;
7083 NULL; 7069 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return NULL;
7084 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return 7070 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) return
7085 NULL; 7071 NULL;
7086 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return 7072 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return
7087 NULL; 7073 NULL;
7088 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return 7074 if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0)
7089 NULL; 7075 return NULL;
7090 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL; 7076 return m;
7091 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return
7092 NULL;
7093 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL;
7094 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return
7095 NULL;
7096 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL;
7097 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return
7098 NULL;
7099 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL;
7100 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return
7101 NULL;
7102 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL;
7103 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return
7104 NULL;
7105 if (PyDict_SetItemString(d, "comprehension",
7106 (PyObject*)comprehension_type) < 0) return NULL;
7107 if (PyDict_SetItemString(d, "excepthandler",
7108 (PyObject*)excepthandler_type) < 0) return NULL;
7109 if (PyDict_SetItemString(d, "ExceptHandler",
7110 (PyObject*)ExceptHandler_type) < 0) return NULL;
7111 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) <
7112 0) return NULL;
7113 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return
7114 NULL;
7115 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0)
7116 return NULL;
7117 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return
7118 NULL;
7119 if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0)
7120 return NULL;
7121 return m;
7122 } 7077 }
7123 7078
7124 7079
7125 PyObject* PyAST_mod2obj(mod_ty t) 7080 PyObject* PyAST_mod2obj(mod_ty t)
7126 { 7081 {