Lines Matching refs:state

13 static int init_types(struct ast_state *state);
19 struct ast_state *state = &interp->ast;
20 if (!init_types(state)) {
23 return state;
28 struct ast_state *state = &interp->ast;
30 Py_CLEAR(state->AST_type);
31 Py_CLEAR(state->Add_singleton);
32 Py_CLEAR(state->Add_type);
33 Py_CLEAR(state->And_singleton);
34 Py_CLEAR(state->And_type);
35 Py_CLEAR(state->AnnAssign_type);
36 Py_CLEAR(state->Assert_type);
37 Py_CLEAR(state->Assign_type);
38 Py_CLEAR(state->AsyncFor_type);
39 Py_CLEAR(state->AsyncFunctionDef_type);
40 Py_CLEAR(state->AsyncWith_type);
41 Py_CLEAR(state->Attribute_type);
42 Py_CLEAR(state->AugAssign_type);
43 Py_CLEAR(state->Await_type);
44 Py_CLEAR(state->BinOp_type);
45 Py_CLEAR(state->BitAnd_singleton);
46 Py_CLEAR(state->BitAnd_type);
47 Py_CLEAR(state->BitOr_singleton);
48 Py_CLEAR(state->BitOr_type);
49 Py_CLEAR(state->BitXor_singleton);
50 Py_CLEAR(state->BitXor_type);
51 Py_CLEAR(state->BoolOp_type);
52 Py_CLEAR(state->Break_type);
53 Py_CLEAR(state->Call_type);
54 Py_CLEAR(state->ClassDef_type);
55 Py_CLEAR(state->Compare_type);
56 Py_CLEAR(state->Constant_type);
57 Py_CLEAR(state->Continue_type);
58 Py_CLEAR(state->Del_singleton);
59 Py_CLEAR(state->Del_type);
60 Py_CLEAR(state->Delete_type);
61 Py_CLEAR(state->DictComp_type);
62 Py_CLEAR(state->Dict_type);
63 Py_CLEAR(state->Div_singleton);
64 Py_CLEAR(state->Div_type);
65 Py_CLEAR(state->Eq_singleton);
66 Py_CLEAR(state->Eq_type);
67 Py_CLEAR(state->ExceptHandler_type);
68 Py_CLEAR(state->Expr_type);
69 Py_CLEAR(state->Expression_type);
70 Py_CLEAR(state->FloorDiv_singleton);
71 Py_CLEAR(state->FloorDiv_type);
72 Py_CLEAR(state->For_type);
73 Py_CLEAR(state->FormattedValue_type);
74 Py_CLEAR(state->FunctionDef_type);
75 Py_CLEAR(state->FunctionType_type);
76 Py_CLEAR(state->GeneratorExp_type);
77 Py_CLEAR(state->Global_type);
78 Py_CLEAR(state->GtE_singleton);
79 Py_CLEAR(state->GtE_type);
80 Py_CLEAR(state->Gt_singleton);
81 Py_CLEAR(state->Gt_type);
82 Py_CLEAR(state->IfExp_type);
83 Py_CLEAR(state->If_type);
84 Py_CLEAR(state->ImportFrom_type);
85 Py_CLEAR(state->Import_type);
86 Py_CLEAR(state->In_singleton);
87 Py_CLEAR(state->In_type);
88 Py_CLEAR(state->Interactive_type);
89 Py_CLEAR(state->Invert_singleton);
90 Py_CLEAR(state->Invert_type);
91 Py_CLEAR(state->IsNot_singleton);
92 Py_CLEAR(state->IsNot_type);
93 Py_CLEAR(state->Is_singleton);
94 Py_CLEAR(state->Is_type);
95 Py_CLEAR(state->JoinedStr_type);
96 Py_CLEAR(state->LShift_singleton);
97 Py_CLEAR(state->LShift_type);
98 Py_CLEAR(state->Lambda_type);
99 Py_CLEAR(state->ListComp_type);
100 Py_CLEAR(state->List_type);
101 Py_CLEAR(state->Load_singleton);
102 Py_CLEAR(state->Load_type);
103 Py_CLEAR(state->LtE_singleton);
104 Py_CLEAR(state->LtE_type);
105 Py_CLEAR(state->Lt_singleton);
106 Py_CLEAR(state->Lt_type);
107 Py_CLEAR(state->MatMult_singleton);
108 Py_CLEAR(state->MatMult_type);
109 Py_CLEAR(state->MatchAs_type);
110 Py_CLEAR(state->MatchClass_type);
111 Py_CLEAR(state->MatchMapping_type);
112 Py_CLEAR(state->MatchOr_type);
113 Py_CLEAR(state->MatchSequence_type);
114 Py_CLEAR(state->MatchSingleton_type);
115 Py_CLEAR(state->MatchStar_type);
116 Py_CLEAR(state->MatchValue_type);
117 Py_CLEAR(state->Match_type);
118 Py_CLEAR(state->Mod_singleton);
119 Py_CLEAR(state->Mod_type);
120 Py_CLEAR(state->Module_type);
121 Py_CLEAR(state->Mult_singleton);
122 Py_CLEAR(state->Mult_type);
123 Py_CLEAR(state->Name_type);
124 Py_CLEAR(state->NamedExpr_type);
125 Py_CLEAR(state->Nonlocal_type);
126 Py_CLEAR(state->NotEq_singleton);
127 Py_CLEAR(state->NotEq_type);
128 Py_CLEAR(state->NotIn_singleton);
129 Py_CLEAR(state->NotIn_type);
130 Py_CLEAR(state->Not_singleton);
131 Py_CLEAR(state->Not_type);
132 Py_CLEAR(state->Or_singleton);
133 Py_CLEAR(state->Or_type);
134 Py_CLEAR(state->Pass_type);
135 Py_CLEAR(state->Pow_singleton);
136 Py_CLEAR(state->Pow_type);
137 Py_CLEAR(state->RShift_singleton);
138 Py_CLEAR(state->RShift_type);
139 Py_CLEAR(state->Raise_type);
140 Py_CLEAR(state->Return_type);
141 Py_CLEAR(state->SetComp_type);
142 Py_CLEAR(state->Set_type);
143 Py_CLEAR(state->Slice_type);
144 Py_CLEAR(state->Starred_type);
145 Py_CLEAR(state->Store_singleton);
146 Py_CLEAR(state->Store_type);
147 Py_CLEAR(state->Sub_singleton);
148 Py_CLEAR(state->Sub_type);
149 Py_CLEAR(state->Subscript_type);
150 Py_CLEAR(state->TryStar_type);
151 Py_CLEAR(state->Try_type);
152 Py_CLEAR(state->Tuple_type);
153 Py_CLEAR(state->TypeIgnore_type);
154 Py_CLEAR(state->UAdd_singleton);
155 Py_CLEAR(state->UAdd_type);
156 Py_CLEAR(state->USub_singleton);
157 Py_CLEAR(state->USub_type);
158 Py_CLEAR(state->UnaryOp_type);
159 Py_CLEAR(state->While_type);
160 Py_CLEAR(state->With_type);
161 Py_CLEAR(state->YieldFrom_type);
162 Py_CLEAR(state->Yield_type);
163 Py_CLEAR(state->__dict__);
164 Py_CLEAR(state->__doc__);
165 Py_CLEAR(state->__match_args__);
166 Py_CLEAR(state->__module__);
167 Py_CLEAR(state->_attributes);
168 Py_CLEAR(state->_fields);
169 Py_CLEAR(state->alias_type);
170 Py_CLEAR(state->annotation);
171 Py_CLEAR(state->arg);
172 Py_CLEAR(state->arg_type);
173 Py_CLEAR(state->args);
174 Py_CLEAR(state->argtypes);
175 Py_CLEAR(state->arguments_type);
176 Py_CLEAR(state->asname);
177 Py_CLEAR(state->ast);
178 Py_CLEAR(state->attr);
179 Py_CLEAR(state->bases);
180 Py_CLEAR(state->body);
181 Py_CLEAR(state->boolop_type);
182 Py_CLEAR(state->cases);
183 Py_CLEAR(state->cause);
184 Py_CLEAR(state->cls);
185 Py_CLEAR(state->cmpop_type);
186 Py_CLEAR(state->col_offset);
187 Py_CLEAR(state->comparators);
188 Py_CLEAR(state->comprehension_type);
189 Py_CLEAR(state->context_expr);
190 Py_CLEAR(state->conversion);
191 Py_CLEAR(state->ctx);
192 Py_CLEAR(state->decorator_list);
193 Py_CLEAR(state->defaults);
194 Py_CLEAR(state->elt);
195 Py_CLEAR(state->elts);
196 Py_CLEAR(state->end_col_offset);
197 Py_CLEAR(state->end_lineno);
198 Py_CLEAR(state->exc);
199 Py_CLEAR(state->excepthandler_type);
200 Py_CLEAR(state->expr_context_type);
201 Py_CLEAR(state->expr_type);
202 Py_CLEAR(state->finalbody);
203 Py_CLEAR(state->format_spec);
204 Py_CLEAR(state->func);
205 Py_CLEAR(state->generators);
206 Py_CLEAR(state->guard);
207 Py_CLEAR(state->handlers);
208 Py_CLEAR(state->id);
209 Py_CLEAR(state->ifs);
210 Py_CLEAR(state->is_async);
211 Py_CLEAR(state->items);
212 Py_CLEAR(state->iter);
213 Py_CLEAR(state->key);
214 Py_CLEAR(state->keys);
215 Py_CLEAR(state->keyword_type);
216 Py_CLEAR(state->keywords);
217 Py_CLEAR(state->kind);
218 Py_CLEAR(state->kw_defaults);
219 Py_CLEAR(state->kwarg);
220 Py_CLEAR(state->kwd_attrs);
221 Py_CLEAR(state->kwd_patterns);
222 Py_CLEAR(state->kwonlyargs);
223 Py_CLEAR(state->left);
224 Py_CLEAR(state->level);
225 Py_CLEAR(state->lineno);
226 Py_CLEAR(state->lower);
227 Py_CLEAR(state->match_case_type);
228 Py_CLEAR(state->mod_type);
229 Py_CLEAR(state->module);
230 Py_CLEAR(state->msg);
231 Py_CLEAR(state->name);
232 Py_CLEAR(state->names);
233 Py_CLEAR(state->op);
234 Py_CLEAR(state->operand);
235 Py_CLEAR(state->operator_type);
236 Py_CLEAR(state->ops);
237 Py_CLEAR(state->optional_vars);
238 Py_CLEAR(state->orelse);
239 Py_CLEAR(state->pattern);
240 Py_CLEAR(state->pattern_type);
241 Py_CLEAR(state->patterns);
242 Py_CLEAR(state->posonlyargs);
243 Py_CLEAR(state->rest);
244 Py_CLEAR(state->returns);
245 Py_CLEAR(state->right);
246 Py_CLEAR(state->simple);
247 Py_CLEAR(state->slice);
248 Py_CLEAR(state->step);
249 Py_CLEAR(state->stmt_type);
250 Py_CLEAR(state->subject);
251 Py_CLEAR(state->tag);
252 Py_CLEAR(state->target);
253 Py_CLEAR(state->targets);
254 Py_CLEAR(state->test);
255 Py_CLEAR(state->type);
256 Py_CLEAR(state->type_comment);
257 Py_CLEAR(state->type_ignore_type);
258 Py_CLEAR(state->type_ignores);
259 Py_CLEAR(state->unaryop_type);
260 Py_CLEAR(state->upper);
261 Py_CLEAR(state->value);
262 Py_CLEAR(state->values);
263 Py_CLEAR(state->vararg);
264 Py_CLEAR(state->withitem_type);
267 state->initialized = -1;
269 state->initialized = 0;
273 static int init_identifiers(struct ast_state *state)
275 if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return 0;
276 if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return 0;
277 if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return 0;
278 if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return 0;
279 if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return 0;
280 if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return 0;
281 if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return 0;
282 if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return 0;
283 if ((state->args = PyUnicode_InternFromString("args")) == NULL) return 0;
284 if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return 0;
285 if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return 0;
286 if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return 0;
287 if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0;
288 if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0;
289 if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0;
290 if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0;
291 if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0;
292 if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return 0;
293 if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return 0;
294 if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return 0;
295 if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return 0;
296 if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return 0;
297 if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return 0;
298 if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return 0;
299 if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return 0;
300 if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return 0;
301 if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return 0;
302 if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return 0;
303 if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return 0;
304 if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return 0;
305 if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return 0;
306 if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return 0;
307 if ((state->func = PyUnicode_InternFromString("func")) == NULL) return 0;
308 if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return 0;
309 if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return 0;
310 if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return 0;
311 if ((state->id = PyUnicode_InternFromString("id")) == NULL) return 0;
312 if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return 0;
313 if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return 0;
314 if ((state->items = PyUnicode_InternFromString("items")) == NULL) return 0;
315 if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return 0;
316 if ((state->key = PyUnicode_InternFromString("key")) == NULL) return 0;
317 if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return 0;
318 if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return 0;
319 if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return 0;
320 if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return 0;
321 if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return 0;
322 if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return 0;
323 if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return 0;
324 if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return 0;
325 if ((state->left = PyUnicode_InternFromString("left")) == NULL) return 0;
326 if ((state->level = PyUnicode_InternFromString("level")) == NULL) return 0;
327 if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return 0;
328 if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return 0;
329 if ((state->module = PyUnicode_InternFromString("module")) == NULL) return 0;
330 if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return 0;
331 if ((state->name = PyUnicode_InternFromString("name")) == NULL) return 0;
332 if ((state->names = PyUnicode_InternFromString("names")) == NULL) return 0;
333 if ((state->op = PyUnicode_InternFromString("op")) == NULL) return 0;
334 if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return 0;
335 if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return 0;
336 if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0;
337 if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0;
338 if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0;
339 if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return 0;
340 if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0;
341 if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return 0;
342 if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0;
343 if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0;
344 if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return 0;
345 if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return 0;
346 if ((state->step = PyUnicode_InternFromString("step")) == NULL) return 0;
347 if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return 0;
348 if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return 0;
349 if ((state->target = PyUnicode_InternFromString("target")) == NULL) return 0;
350 if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return 0;
351 if ((state->test = PyUnicode_InternFromString("test")) == NULL) return 0;
352 if ((state->type = PyUnicode_InternFromString("type")) == NULL) return 0;
353 if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return 0;
354 if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return 0;
355 if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return 0;
356 if ((state->value = PyUnicode_InternFromString("value")) == NULL) return 0;
357 if ((state->values = PyUnicode_InternFromString("values")) == NULL) return 0;
358 if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return 0;
376 static PyObject* ast2obj_mod(struct ast_state *state, void*);
397 static PyObject* ast2obj_stmt(struct ast_state *state, void*);
524 static PyObject* ast2obj_expr(struct ast_state *state, void*);
637 static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
638 static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
639 static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
640 static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
641 static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
642 static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
655 static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
661 static PyObject* ast2obj_arguments(struct ast_state *state, void*);
671 static PyObject* ast2obj_arg(struct ast_state *state, void*);
683 static PyObject* ast2obj_keyword(struct ast_state *state, void*);
694 static PyObject* ast2obj_alias(struct ast_state *state, void*);
705 static PyObject* ast2obj_withitem(struct ast_state *state, void*);
710 static PyObject* ast2obj_match_case(struct ast_state *state, void*);
722 static PyObject* ast2obj_pattern(struct ast_state *state, void*);
753 static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
797 struct ast_state *state = get_ast_state();
798 if (state == NULL) {
805 if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
873 struct ast_state *state = get_ast_state();
874 if (state == NULL) {
879 if (_PyObject_LookupAttr(self, state->__dict__, &dict) < 0) {
928 make_type(struct ast_state *state, const char *type, PyObject* base,
945 state->_fields, fnames,
946 state->__match_args__, fnames,
947 state->__module__,
948 state->ast,
949 state->__doc__, doc);
955 add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
969 result = PyObject_SetAttr(type, state->_attributes, l) >= 0;
976 static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq, PyObject* (*func)(struct ast_state *state, void*))
984 value = func(state, asdl_seq_GET_UNTYPED(seq, i));
994 static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
1005 static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
1012 static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1027 static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
1038 static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1044 return obj2ast_object(state, obj, out, arena);
1047 static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
1053 return obj2ast_object(state, obj, out, arena);
1056 static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
1071 static int add_ast_fields(struct ast_state *state)
1076 PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
1077 PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
1078 PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
1089 init_types(struct ast_state *state)
1093 assert(state->initialized >= 0);
1095 if (state->initialized) {
1098 if (init_identifiers(state) < 0) {
1101 state->AST_type = PyType_FromSpec(&AST_type_spec);
1102 if (!state->AST_type) {
1105 if (add_ast_fields(state) < 0) {
1108 state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
1113 if (!state->mod_type) return 0;
1114 if (!add_attributes(state, state->mod_type, NULL, 0)) return 0;
1115 state->Module_type = make_type(state, "Module", state->mod_type,
1118 if (!state->Module_type) return 0;
1119 state->Interactive_type = make_type(state, "Interactive", state->mod_type,
1122 if (!state->Interactive_type) return 0;
1123 state->Expression_type = make_type(state, "Expression", state->mod_type,
1126 if (!state->Expression_type) return 0;
1127 state->FunctionType_type = make_type(state, "FunctionType",
1128 state->mod_type, FunctionType_fields,
1131 if (!state->FunctionType_type) return 0;
1132 state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
1160 if (!state->stmt_type) return 0;
1161 if (!add_attributes(state, state->stmt_type, stmt_attributes, 4)) return 0;
1162 if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
1164 if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
1167 state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
1170 if (!state->FunctionDef_type) return 0;
1171 if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
1174 if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
1177 state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
1178 state->stmt_type,
1181 if (!state->AsyncFunctionDef_type) return 0;
1182 if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
1185 if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
1188 state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
1191 if (!state->ClassDef_type) return 0;
1192 state->Return_type = make_type(state, "Return", state->stmt_type,
1195 if (!state->Return_type) return 0;
1196 if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
1198 state->Delete_type = make_type(state, "Delete", state->stmt_type,
1201 if (!state->Delete_type) return 0;
1202 state->Assign_type = make_type(state, "Assign", state->stmt_type,
1205 if (!state->Assign_type) return 0;
1206 if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
1209 state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
1212 if (!state->AugAssign_type) return 0;
1213 state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
1216 if (!state->AnnAssign_type) return 0;
1217 if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
1219 state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
1221 if (!state->For_type) return 0;
1222 if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
1224 state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
1227 if (!state->AsyncFor_type) return 0;
1228 if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
1231 state->While_type = make_type(state, "While", state->stmt_type,
1234 if (!state->While_type) return 0;
1235 state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
1237 if (!state->If_type) return 0;
1238 state->With_type = make_type(state, "With", state->stmt_type, With_fields,
1241 if (!state->With_type) return 0;
1242 if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
1244 state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
1247 if (!state->AsyncWith_type) return 0;
1248 if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
1251 state->Match_type = make_type(state, "Match", state->stmt_type,
1254 if (!state->Match_type) return 0;
1255 state->Raise_type = make_type(state, "Raise", state->stmt_type,
1258 if (!state->Raise_type) return 0;
1259 if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
1261 if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
1263 state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
1265 if (!state->Try_type) return 0;
1266 state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
1269 if (!state->TryStar_type) return 0;
1270 state->Assert_type = make_type(state, "Assert", state->stmt_type,
1273 if (!state->Assert_type) return 0;
1274 if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
1276 state->Import_type = make_type(state, "Import", state->stmt_type,
1279 if (!state->Import_type) return 0;
1280 state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
1283 if (!state->ImportFrom_type) return 0;
1284 if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
1286 if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
1288 state->Global_type = make_type(state, "Global", state->stmt_type,
1291 if (!state->Global_type) return 0;
1292 state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
1295 if (!state->Nonlocal_type) return 0;
1296 state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
1299 if (!state->Expr_type) return 0;
1300 state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
1302 if (!state->Pass_type) return 0;
1303 state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
1305 if (!state->Break_type) return 0;
1306 state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
1309 if (!state->Continue_type) return 0;
1310 state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
1338 if (!state->expr_type) return 0;
1339 if (!add_attributes(state, state->expr_type, expr_attributes, 4)) return 0;
1340 if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
1342 if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
1345 state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
1348 if (!state->BoolOp_type) return 0;
1349 state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
1352 if (!state->NamedExpr_type) return 0;
1353 state->BinOp_type = make_type(state, "BinOp", state->expr_type,
1356 if (!state->BinOp_type) return 0;
1357 state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
1360 if (!state->UnaryOp_type) return 0;
1361 state->Lambda_type = make_type(state, "Lambda", state->expr_type,
1364 if (!state->Lambda_type) return 0;
1365 state->IfExp_type = make_type(state, "IfExp", state->expr_type,
1368 if (!state->IfExp_type) return 0;
1369 state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
1372 if (!state->Dict_type) return 0;
1373 state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
1375 if (!state->Set_type) return 0;
1376 state->ListComp_type = make_type(state, "ListComp", state->expr_type,
1379 if (!state->ListComp_type) return 0;
1380 state->SetComp_type = make_type(state, "SetComp", state->expr_type,
1383 if (!state->SetComp_type) return 0;
1384 state->DictComp_type = make_type(state, "DictComp", state->expr_type,
1387 if (!state->DictComp_type) return 0;
1388 state->GeneratorExp_type = make_type(state, "GeneratorExp",
1389 state->expr_type, GeneratorExp_fields,
1392 if (!state->GeneratorExp_type) return 0;
1393 state->Await_type = make_type(state, "Await", state->expr_type,
1396 if (!state->Await_type) return 0;
1397 state->Yield_type = make_type(state, "Yield", state->expr_type,
1400 if (!state->Yield_type) return 0;
1401 if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
1403 state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
1406 if (!state->YieldFrom_type) return 0;
1407 state->Compare_type = make_type(state, "Compare", state->expr_type,
1410 if (!state->Compare_type) return 0;
1411 state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
1414 if (!state->Call_type) return 0;
1415 state->FormattedValue_type = make_type(state, "FormattedValue",
1416 state->expr_type,
1419 if (!state->FormattedValue_type) return 0;
1420 if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
1423 state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
1426 if (!state->JoinedStr_type) return 0;
1427 state->Constant_type = make_type(state, "Constant", state->expr_type,
1430 if (!state->Constant_type) return 0;
1431 if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
1433 state->Attribute_type = make_type(state, "Attribute", state->expr_type,
1436 if (!state->Attribute_type) return 0;
1437 state->Subscript_type = make_type(state, "Subscript", state->expr_type,
1440 if (!state->Subscript_type) return 0;
1441 state->Starred_type = make_type(state, "Starred", state->expr_type,
1444 if (!state->Starred_type) return 0;
1445 state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
1448 if (!state->Name_type) return 0;
1449 state->List_type = make_type(state, "List", state->expr_type, List_fields,
1452 if (!state->List_type) return 0;
1453 state->Tuple_type = make_type(state, "Tuple", state->expr_type,
1456 if (!state->Tuple_type) return 0;
1457 state->Slice_type = make_type(state, "Slice", state->expr_type,
1460 if (!state->Slice_type) return 0;
1461 if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
1463 if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
1465 if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
1467 state->expr_context_type = make_type(state, "expr_context",
1468 state->AST_type, NULL, 0,
1470 if (!state->expr_context_type) return 0;
1471 if (!add_attributes(state, state->expr_context_type, NULL, 0)) return 0;
1472 state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
1475 if (!state->Load_type) return 0;
1476 state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
1478 if (!state->Load_singleton) return 0;
1479 state->Store_type = make_type(state, "Store", state->expr_context_type,
1482 if (!state->Store_type) return 0;
1483 state->Store_singleton = PyType_GenericNew((PyTypeObject
1484 *)state->Store_type, NULL, NULL);
1485 if (!state->Store_singleton) return 0;
1486 state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
1488 if (!state->Del_type) return 0;
1489 state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
1491 if (!state->Del_singleton) return 0;
1492 state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
1494 if (!state->boolop_type) return 0;
1495 if (!add_attributes(state, state->boolop_type, NULL, 0)) return 0;
1496 state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
1498 if (!state->And_type) return 0;
1499 state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
1501 if (!state->And_singleton) return 0;
1502 state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
1504 if (!state->Or_type) return 0;
1505 state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
1507 if (!state->Or_singleton) return 0;
1508 state->operator_type = make_type(state, "operator", state->AST_type, NULL,
1511 if (!state->operator_type) return 0;
1512 if (!add_attributes(state, state->operator_type, NULL, 0)) return 0;
1513 state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
1515 if (!state->Add_type) return 0;
1516 state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
1518 if (!state->Add_singleton) return 0;
1519 state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
1521 if (!state->Sub_type) return 0;
1522 state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
1524 if (!state->Sub_singleton) return 0;
1525 state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
1527 if (!state->Mult_type) return 0;
1528 state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
1530 if (!state->Mult_singleton) return 0;
1531 state->MatMult_type = make_type(state, "MatMult", state->operator_type,
1534 if (!state->MatMult_type) return 0;
1535 state->MatMult_singleton = PyType_GenericNew((PyTypeObject
1536 *)state->MatMult_type, NULL,
1538 if (!state->MatMult_singleton) return 0;
1539 state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
1541 if (!state->Div_type) return 0;
1542 state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
1544 if (!state->Div_singleton) return 0;
1545 state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
1547 if (!state->Mod_type) return 0;
1548 state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
1550 if (!state->Mod_singleton) return 0;
1551 state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
1553 if (!state->Pow_type) return 0;
1554 state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
1556 if (!state->Pow_singleton) return 0;
1557 state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
1560 if (!state->LShift_type) return 0;
1561 state->LShift_singleton = PyType_GenericNew((PyTypeObject
1562 *)state->LShift_type, NULL,
1564 if (!state->LShift_singleton) return 0;
1565 state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
1568 if (!state->RShift_type) return 0;
1569 state->RShift_singleton = PyType_GenericNew((PyTypeObject
1570 *)state->RShift_type, NULL,
1572 if (!state->RShift_singleton) return 0;
1573 state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
1575 if (!state->BitOr_type) return 0;
1576 state->BitOr_singleton = PyType_GenericNew((PyTypeObject
1577 *)state->BitOr_type, NULL, NULL);
1578 if (!state->BitOr_singleton) return 0;
1579 state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
1582 if (!state->BitXor_type) return 0;
1583 state->BitXor_singleton = PyType_GenericNew((PyTypeObject
1584 *)state->BitXor_type, NULL,
1586 if (!state->BitXor_singleton) return 0;
1587 state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
1590 if (!state->BitAnd_type) return 0;
1591 state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
1592 *)state->BitAnd_type, NULL,
1594 if (!state->BitAnd_singleton) return 0;
1595 state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
1598 if (!state->FloorDiv_type) return 0;
1599 state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
1600 *)state->FloorDiv_type, NULL,
1602 if (!state->FloorDiv_singleton) return 0;
1603 state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
1605 if (!state->unaryop_type) return 0;
1606 if (!add_attributes(state, state->unaryop_type, NULL, 0)) return 0;
1607 state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
1610 if (!state->Invert_type) return 0;
1611 state->Invert_singleton = PyType_GenericNew((PyTypeObject
1612 *)state->Invert_type, NULL,
1614 if (!state->Invert_singleton) return 0;
1615 state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
1617 if (!state->Not_type) return 0;
1618 state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
1620 if (!state->Not_singleton) return 0;
1621 state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
1623 if (!state->UAdd_type) return 0;
1624 state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
1626 if (!state->UAdd_singleton) return 0;
1627 state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
1629 if (!state->USub_type) return 0;
1630 state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
1632 if (!state->USub_singleton) return 0;
1633 state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
1635 if (!state->cmpop_type) return 0;
1636 if (!add_attributes(state, state->cmpop_type, NULL, 0)) return 0;
1637 state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
1639 if (!state->Eq_type) return 0;
1640 state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
1642 if (!state->Eq_singleton) return 0;
1643 state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
1645 if (!state->NotEq_type) return 0;
1646 state->NotEq_singleton = PyType_GenericNew((PyTypeObject
1647 *)state->NotEq_type, NULL, NULL);
1648 if (!state->NotEq_singleton) return 0;
1649 state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
1651 if (!state->Lt_type) return 0;
1652 state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
1654 if (!state->Lt_singleton) return 0;
1655 state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
1657 if (!state->LtE_type) return 0;
1658 state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
1660 if (!state->LtE_singleton) return 0;
1661 state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
1663 if (!state->Gt_type) return 0;
1664 state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
1666 if (!state->Gt_singleton) return 0;
1667 state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
1669 if (!state->GtE_type) return 0;
1670 state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
1672 if (!state->GtE_singleton) return 0;
1673 state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
1675 if (!state->Is_type) return 0;
1676 state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
1678 if (!state->Is_singleton) return 0;
1679 state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
1681 if (!state->IsNot_type) return 0;
1682 state->IsNot_singleton = PyType_GenericNew((PyTypeObject
1683 *)state->IsNot_type, NULL, NULL);
1684 if (!state->IsNot_singleton) return 0;
1685 state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
1687 if (!state->In_type) return 0;
1688 state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
1690 if (!state->In_singleton) return 0;
1691 state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
1693 if (!state->NotIn_type) return 0;
1694 state->NotIn_singleton = PyType_GenericNew((PyTypeObject
1695 *)state->NotIn_type, NULL, NULL);
1696 if (!state->NotIn_singleton) return 0;
1697 state->comprehension_type = make_type(state, "comprehension",
1698 state->AST_type,
1701 if (!state->comprehension_type) return 0;
1702 if (!add_attributes(state, state->comprehension_type, NULL, 0)) return 0;
1703 state->excepthandler_type = make_type(state, "excepthandler",
1704 state->AST_type, NULL, 0,
1706 if (!state->excepthandler_type) return 0;
1707 if (!add_attributes(state, state->excepthandler_type,
1709 if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
1712 if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
1715 state->ExceptHandler_type = make_type(state, "ExceptHandler",
1716 state->excepthandler_type,
1719 if (!state->ExceptHandler_type) return 0;
1720 if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
1722 if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
1724 state->arguments_type = make_type(state, "arguments", state->AST_type,
1727 if (!state->arguments_type) return 0;
1728 if (!add_attributes(state, state->arguments_type, NULL, 0)) return 0;
1729 if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
1731 if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
1733 state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
1735 if (!state->arg_type) return 0;
1736 if (!add_attributes(state, state->arg_type, arg_attributes, 4)) return 0;
1737 if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
1739 if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
1741 if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
1743 if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
1745 state->keyword_type = make_type(state, "keyword", state->AST_type,
1748 if (!state->keyword_type) return 0;
1749 if (!add_attributes(state, state->keyword_type, keyword_attributes, 4))
1751 if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
1753 if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
1755 if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
1758 state->alias_type = make_type(state, "alias", state->AST_type,
1761 if (!state->alias_type) return 0;
1762 if (!add_attributes(state, state->alias_type, alias_attributes, 4)) return
1764 if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
1766 if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
1768 if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
1771 state->withitem_type = make_type(state, "withitem", state->AST_type,
1774 if (!state->withitem_type) return 0;
1775 if (!add_attributes(state, state->withitem_type, NULL, 0)) return 0;
1776 if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
1779 state->match_case_type = make_type(state, "match_case", state->AST_type,
1782 if (!state->match_case_type) return 0;
1783 if (!add_attributes(state, state->match_case_type, NULL, 0)) return 0;
1784 if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
1786 state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
1795 if (!state->pattern_type) return 0;
1796 if (!add_attributes(state, state->pattern_type, pattern_attributes, 4))
1798 state->MatchValue_type = make_type(state, "MatchValue",
1799 state->pattern_type, MatchValue_fields,
1802 if (!state->MatchValue_type) return 0;
1803 state->MatchSingleton_type = make_type(state, "MatchSingleton",
1804 state->pattern_type,
1807 if (!state->MatchSingleton_type) return 0;
1808 state->MatchSequence_type = make_type(state, "MatchSequence",
1809 state->pattern_type,
1812 if (!state->MatchSequence_type) return 0;
1813 state->MatchMapping_type = make_type(state, "MatchMapping",
1814 state->pattern_type,
1817 if (!state->MatchMapping_type) return 0;
1818 if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
1820 state->MatchClass_type = make_type(state, "MatchClass",
1821 state->pattern_type, MatchClass_fields,
1824 if (!state->MatchClass_type) return 0;
1825 state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
1828 if (!state->MatchStar_type) return 0;
1829 if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
1831 state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
1834 if (!state->MatchAs_type) return 0;
1835 if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
1837 if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
1839 state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
1842 if (!state->MatchOr_type) return 0;
1843 state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
1846 if (!state->type_ignore_type) return 0;
1847 if (!add_attributes(state, state->type_ignore_type, NULL, 0)) return 0;
1848 state->TypeIgnore_type = make_type(state, "TypeIgnore",
1849 state->type_ignore_type,
1852 if (!state->TypeIgnore_type) return 0;
1854 state->recursion_depth = 0;
1855 state->recursion_limit = 0;
1856 state->initialized = 1;
1860 static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
1862 static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
1864 static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
1866 static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
1868 static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
1870 static int obj2ast_operator(struct ast_state *state, PyObject* obj,
1872 static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
1874 static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
1876 static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
1878 static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
1880 static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
1882 static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
1884 static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
1886 static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
1888 static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
1890 static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
1892 static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
1894 static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
3607 ast2obj_mod(struct ast_state *state, void* _o)
3615 if (++state->recursion_depth > state->recursion_limit) {
3622 tp = (PyTypeObject *)state->Module_type;
3625 value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
3627 if (PyObject_SetAttr(result, state->body, value) == -1)
3630 value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
3633 if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
3638 tp = (PyTypeObject *)state->Interactive_type;
3641 value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
3644 if (PyObject_SetAttr(result, state->body, value) == -1)
3649 tp = (PyTypeObject *)state->Expression_type;
3652 value = ast2obj_expr(state, o->v.Expression.body);
3654 if (PyObject_SetAttr(result, state->body, value) == -1)
3659 tp = (PyTypeObject *)state->FunctionType_type;
3662 value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
3665 if (PyObject_SetAttr(result, state->argtypes, value) == -1)
3668 value = ast2obj_expr(state, o->v.FunctionType.returns);
3670 if (PyObject_SetAttr(result, state->returns, value) == -1)
3675 state->recursion_depth--;
3684 ast2obj_stmt(struct ast_state *state, void* _o)
3692 if (++state->recursion_depth > state->recursion_limit) {
3699 tp = (PyTypeObject *)state->FunctionDef_type;
3702 value = ast2obj_identifier(state, o->v.FunctionDef.name);
3704 if (PyObject_SetAttr(result, state->name, value) == -1)
3707 value = ast2obj_arguments(state, o->v.FunctionDef.args);
3709 if (PyObject_SetAttr(result, state->args, value) == -1)
3712 value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
3715 if (PyObject_SetAttr(result, state->body, value) == -1)
3718 value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
3721 if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3724 value = ast2obj_expr(state, o->v.FunctionDef.returns);
3726 if (PyObject_SetAttr(result, state->returns, value) == -1)
3729 value = ast2obj_string(state, o->v.FunctionDef.type_comment);
3731 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3736 tp = (PyTypeObject *)state->AsyncFunctionDef_type;
3739 value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
3741 if (PyObject_SetAttr(result, state->name, value) == -1)
3744 value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
3746 if (PyObject_SetAttr(result, state->args, value) == -1)
3749 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
3752 if (PyObject_SetAttr(result, state->body, value) == -1)
3755 value = ast2obj_list(state,
3759 if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3762 value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
3764 if (PyObject_SetAttr(result, state->returns, value) == -1)
3767 value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
3769 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3774 tp = (PyTypeObject *)state->ClassDef_type;
3777 value = ast2obj_identifier(state, o->v.ClassDef.name);
3779 if (PyObject_SetAttr(result, state->name, value) == -1)
3782 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
3785 if (PyObject_SetAttr(result, state->bases, value) == -1)
3788 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
3791 if (PyObject_SetAttr(result, state->keywords, value) == -1)
3794 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
3797 if (PyObject_SetAttr(result, state->body, value) == -1)
3800 value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
3803 if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
3808 tp = (PyTypeObject *)state->Return_type;
3811 value = ast2obj_expr(state, o->v.Return.value);
3813 if (PyObject_SetAttr(result, state->value, value) == -1)
3818 tp = (PyTypeObject *)state->Delete_type;
3821 value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
3824 if (PyObject_SetAttr(result, state->targets, value) == -1)
3829 tp = (PyTypeObject *)state->Assign_type;
3832 value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
3835 if (PyObject_SetAttr(result, state->targets, value) == -1)
3838 value = ast2obj_expr(state, o->v.Assign.value);
3840 if (PyObject_SetAttr(result, state->value, value) == -1)
3843 value = ast2obj_string(state, o->v.Assign.type_comment);
3845 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3850 tp = (PyTypeObject *)state->AugAssign_type;
3853 value = ast2obj_expr(state, o->v.AugAssign.target);
3855 if (PyObject_SetAttr(result, state->target, value) == -1)
3858 value = ast2obj_operator(state, o->v.AugAssign.op);
3860 if (PyObject_SetAttr(result, state->op, value) == -1)
3863 value = ast2obj_expr(state, o->v.AugAssign.value);
3865 if (PyObject_SetAttr(result, state->value, value) == -1)
3870 tp = (PyTypeObject *)state->AnnAssign_type;
3873 value = ast2obj_expr(state, o->v.AnnAssign.target);
3875 if (PyObject_SetAttr(result, state->target, value) == -1)
3878 value = ast2obj_expr(state, o->v.AnnAssign.annotation);
3880 if (PyObject_SetAttr(result, state->annotation, value) == -1)
3883 value = ast2obj_expr(state, o->v.AnnAssign.value);
3885 if (PyObject_SetAttr(result, state->value, value) == -1)
3888 value = ast2obj_int(state, o->v.AnnAssign.simple);
3890 if (PyObject_SetAttr(result, state->simple, value) == -1)
3895 tp = (PyTypeObject *)state->For_type;
3898 value = ast2obj_expr(state, o->v.For.target);
3900 if (PyObject_SetAttr(result, state->target, value) == -1)
3903 value = ast2obj_expr(state, o->v.For.iter);
3905 if (PyObject_SetAttr(result, state->iter, value) == -1)
3908 value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
3910 if (PyObject_SetAttr(result, state->body, value) == -1)
3913 value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
3915 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3918 value = ast2obj_string(state, o->v.For.type_comment);
3920 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3925 tp = (PyTypeObject *)state->AsyncFor_type;
3928 value = ast2obj_expr(state, o->v.AsyncFor.target);
3930 if (PyObject_SetAttr(result, state->target, value) == -1)
3933 value = ast2obj_expr(state, o->v.AsyncFor.iter);
3935 if (PyObject_SetAttr(result, state->iter, value) == -1)
3938 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
3941 if (PyObject_SetAttr(result, state->body, value) == -1)
3944 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
3947 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3950 value = ast2obj_string(state, o->v.AsyncFor.type_comment);
3952 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
3957 tp = (PyTypeObject *)state->While_type;
3960 value = ast2obj_expr(state, o->v.While.test);
3962 if (PyObject_SetAttr(result, state->test, value) == -1)
3965 value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
3967 if (PyObject_SetAttr(result, state->body, value) == -1)
3970 value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
3972 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3977 tp = (PyTypeObject *)state->If_type;
3980 value = ast2obj_expr(state, o->v.If.test);
3982 if (PyObject_SetAttr(result, state->test, value) == -1)
3985 value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
3987 if (PyObject_SetAttr(result, state->body, value) == -1)
3990 value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
3992 if (PyObject_SetAttr(result, state->orelse, value) == -1)
3997 tp = (PyTypeObject *)state->With_type;
4000 value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
4003 if (PyObject_SetAttr(result, state->items, value) == -1)
4006 value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
4008 if (PyObject_SetAttr(result, state->body, value) == -1)
4011 value = ast2obj_string(state, o->v.With.type_comment);
4013 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4018 tp = (PyTypeObject *)state->AsyncWith_type;
4021 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
4024 if (PyObject_SetAttr(result, state->items, value) == -1)
4027 value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
4030 if (PyObject_SetAttr(result, state->body, value) == -1)
4033 value = ast2obj_string(state, o->v.AsyncWith.type_comment);
4035 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
4040 tp = (PyTypeObject *)state->Match_type;
4043 value = ast2obj_expr(state, o->v.Match.subject);
4045 if (PyObject_SetAttr(result, state->subject, value) == -1)
4048 value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
4051 if (PyObject_SetAttr(result, state->cases, value) == -1)
4056 tp = (PyTypeObject *)state->Raise_type;
4059 value = ast2obj_expr(state, o->v.Raise.exc);
4061 if (PyObject_SetAttr(result, state->exc, value) == -1)
4064 value = ast2obj_expr(state, o->v.Raise.cause);
4066 if (PyObject_SetAttr(result, state->cause, value) == -1)
4071 tp = (PyTypeObject *)state->Try_type;
4074 value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
4076 if (PyObject_SetAttr(result, state->body, value) == -1)
4079 value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
4082 if (PyObject_SetAttr(result, state->handlers, value) == -1)
4085 value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
4087 if (PyObject_SetAttr(result, state->orelse, value) == -1)
4090 value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
4093 if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4098 tp = (PyTypeObject *)state->TryStar_type;
4101 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
4103 if (PyObject_SetAttr(result, state->body, value) == -1)
4106 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
4109 if (PyObject_SetAttr(result, state->handlers, value) == -1)
4112 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
4115 if (PyObject_SetAttr(result, state->orelse, value) == -1)
4118 value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
4121 if (PyObject_SetAttr(result, state->finalbody, value) == -1)
4126 tp = (PyTypeObject *)state->Assert_type;
4129 value = ast2obj_expr(state, o->v.Assert.test);
4131 if (PyObject_SetAttr(result, state->test, value) == -1)
4134 value = ast2obj_expr(state, o->v.Assert.msg);
4136 if (PyObject_SetAttr(result, state->msg, value) == -1)
4141 tp = (PyTypeObject *)state->Import_type;
4144 value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
4147 if (PyObject_SetAttr(result, state->names, value) == -1)
4152 tp = (PyTypeObject *)state->ImportFrom_type;
4155 value = ast2obj_identifier(state, o->v.ImportFrom.module);
4157 if (PyObject_SetAttr(result, state->module, value) == -1)
4160 value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
4163 if (PyObject_SetAttr(result, state->names, value) == -1)
4166 value = ast2obj_int(state, o->v.ImportFrom.level);
4168 if (PyObject_SetAttr(result, state->level, value) == -1)
4173 tp = (PyTypeObject *)state->Global_type;
4176 value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
4179 if (PyObject_SetAttr(result, state->names, value) == -1)
4184 tp = (PyTypeObject *)state->Nonlocal_type;
4187 value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
4190 if (PyObject_SetAttr(result, state->names, value) == -1)
4195 tp = (PyTypeObject *)state->Expr_type;
4198 value = ast2obj_expr(state, o->v.Expr.value);
4200 if (PyObject_SetAttr(result, state->value, value) == -1)
4205 tp = (PyTypeObject *)state->Pass_type;
4210 tp = (PyTypeObject *)state->Break_type;
4215 tp = (PyTypeObject *)state->Continue_type;
4220 value = ast2obj_int(state, o->lineno);
4222 if (PyObject_SetAttr(result, state->lineno, value) < 0)
4225 value = ast2obj_int(state, o->col_offset);
4227 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4230 value = ast2obj_int(state, o->end_lineno);
4232 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4235 value = ast2obj_int(state, o->end_col_offset);
4237 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4240 state->recursion_depth--;
4249 ast2obj_expr(struct ast_state *state, void* _o)
4257 if (++state->recursion_depth > state->recursion_limit) {
4264 tp = (PyTypeObject *)state->BoolOp_type;
4267 value = ast2obj_boolop(state, o->v.BoolOp.op);
4269 if (PyObject_SetAttr(result, state->op, value) == -1)
4272 value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
4275 if (PyObject_SetAttr(result, state->values, value) == -1)
4280 tp = (PyTypeObject *)state->NamedExpr_type;
4283 value = ast2obj_expr(state, o->v.NamedExpr.target);
4285 if (PyObject_SetAttr(result, state->target, value) == -1)
4288 value = ast2obj_expr(state, o->v.NamedExpr.value);
4290 if (PyObject_SetAttr(result, state->value, value) == -1)
4295 tp = (PyTypeObject *)state->BinOp_type;
4298 value = ast2obj_expr(state, o->v.BinOp.left);
4300 if (PyObject_SetAttr(result, state->left, value) == -1)
4303 value = ast2obj_operator(state, o->v.BinOp.op);
4305 if (PyObject_SetAttr(result, state->op, value) == -1)
4308 value = ast2obj_expr(state, o->v.BinOp.right);
4310 if (PyObject_SetAttr(result, state->right, value) == -1)
4315 tp = (PyTypeObject *)state->UnaryOp_type;
4318 value = ast2obj_unaryop(state, o->v.UnaryOp.op);
4320 if (PyObject_SetAttr(result, state->op, value) == -1)
4323 value = ast2obj_expr(state, o->v.UnaryOp.operand);
4325 if (PyObject_SetAttr(result, state->operand, value) == -1)
4330 tp = (PyTypeObject *)state->Lambda_type;
4333 value = ast2obj_arguments(state, o->v.Lambda.args);
4335 if (PyObject_SetAttr(result, state->args, value) == -1)
4338 value = ast2obj_expr(state, o->v.Lambda.body);
4340 if (PyObject_SetAttr(result, state->body, value) == -1)
4345 tp = (PyTypeObject *)state->IfExp_type;
4348 value = ast2obj_expr(state, o->v.IfExp.test);
4350 if (PyObject_SetAttr(result, state->test, value) == -1)
4353 value = ast2obj_expr(state, o->v.IfExp.body);
4355 if (PyObject_SetAttr(result, state->body, value) == -1)
4358 value = ast2obj_expr(state, o->v.IfExp.orelse);
4360 if (PyObject_SetAttr(result, state->orelse, value) == -1)
4365 tp = (PyTypeObject *)state->Dict_type;
4368 value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
4370 if (PyObject_SetAttr(result, state->keys, value) == -1)
4373 value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
4375 if (PyObject_SetAttr(result, state->values, value) == -1)
4380 tp = (PyTypeObject *)state->Set_type;
4383 value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
4385 if (PyObject_SetAttr(result, state->elts, value) == -1)
4390 tp = (PyTypeObject *)state->ListComp_type;
4393 value = ast2obj_expr(state, o->v.ListComp.elt);
4395 if (PyObject_SetAttr(result, state->elt, value) == -1)
4398 value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
4401 if (PyObject_SetAttr(result, state->generators, value) == -1)
4406 tp = (PyTypeObject *)state->SetComp_type;
4409 value = ast2obj_expr(state, o->v.SetComp.elt);
4411 if (PyObject_SetAttr(result, state->elt, value) == -1)
4414 value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
4417 if (PyObject_SetAttr(result, state->generators, value) == -1)
4422 tp = (PyTypeObject *)state->DictComp_type;
4425 value = ast2obj_expr(state, o->v.DictComp.key);
4427 if (PyObject_SetAttr(result, state->key, value) == -1)
4430 value = ast2obj_expr(state, o->v.DictComp.value);
4432 if (PyObject_SetAttr(result, state->value, value) == -1)
4435 value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
4438 if (PyObject_SetAttr(result, state->generators, value) == -1)
4443 tp = (PyTypeObject *)state->GeneratorExp_type;
4446 value = ast2obj_expr(state, o->v.GeneratorExp.elt);
4448 if (PyObject_SetAttr(result, state->elt, value) == -1)
4451 value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
4454 if (PyObject_SetAttr(result, state->generators, value) == -1)
4459 tp = (PyTypeObject *)state->Await_type;
4462 value = ast2obj_expr(state, o->v.Await.value);
4464 if (PyObject_SetAttr(result, state->value, value) == -1)
4469 tp = (PyTypeObject *)state->Yield_type;
4472 value = ast2obj_expr(state, o->v.Yield.value);
4474 if (PyObject_SetAttr(result, state->value, value) == -1)
4479 tp = (PyTypeObject *)state->YieldFrom_type;
4482 value = ast2obj_expr(state, o->v.YieldFrom.value);
4484 if (PyObject_SetAttr(result, state->value, value) == -1)
4489 tp = (PyTypeObject *)state->Compare_type;
4492 value = ast2obj_expr(state, o->v.Compare.left);
4494 if (PyObject_SetAttr(result, state->left, value) == -1)
4502 PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
4505 if (PyObject_SetAttr(result, state->ops, value) == -1)
4508 value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
4511 if (PyObject_SetAttr(result, state->comparators, value) == -1)
4516 tp = (PyTypeObject *)state->Call_type;
4519 value = ast2obj_expr(state, o->v.Call.func);
4521 if (PyObject_SetAttr(result, state->func, value) == -1)
4524 value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
4526 if (PyObject_SetAttr(result, state->args, value) == -1)
4529 value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
4532 if (PyObject_SetAttr(result, state->keywords, value) == -1)
4537 tp = (PyTypeObject *)state->FormattedValue_type;
4540 value = ast2obj_expr(state, o->v.FormattedValue.value);
4542 if (PyObject_SetAttr(result, state->value, value) == -1)
4545 value = ast2obj_int(state, o->v.FormattedValue.conversion);
4547 if (PyObject_SetAttr(result, state->conversion, value) == -1)
4550 value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
4552 if (PyObject_SetAttr(result, state->format_spec, value) == -1)
4557 tp = (PyTypeObject *)state->JoinedStr_type;
4560 value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
4563 if (PyObject_SetAttr(result, state->values, value) == -1)
4568 tp = (PyTypeObject *)state->Constant_type;
4571 value = ast2obj_constant(state, o->v.Constant.value);
4573 if (PyObject_SetAttr(result, state->value, value) == -1)
4576 value = ast2obj_string(state, o->v.Constant.kind);
4578 if (PyObject_SetAttr(result, state->kind, value) == -1)
4583 tp = (PyTypeObject *)state->Attribute_type;
4586 value = ast2obj_expr(state, o->v.Attribute.value);
4588 if (PyObject_SetAttr(result, state->value, value) == -1)
4591 value = ast2obj_identifier(state, o->v.Attribute.attr);
4593 if (PyObject_SetAttr(result, state->attr, value) == -1)
4596 value = ast2obj_expr_context(state, o->v.Attribute.ctx);
4598 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4603 tp = (PyTypeObject *)state->Subscript_type;
4606 value = ast2obj_expr(state, o->v.Subscript.value);
4608 if (PyObject_SetAttr(result, state->value, value) == -1)
4611 value = ast2obj_expr(state, o->v.Subscript.slice);
4613 if (PyObject_SetAttr(result, state->slice, value) == -1)
4616 value = ast2obj_expr_context(state, o->v.Subscript.ctx);
4618 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4623 tp = (PyTypeObject *)state->Starred_type;
4626 value = ast2obj_expr(state, o->v.Starred.value);
4628 if (PyObject_SetAttr(result, state->value, value) == -1)
4631 value = ast2obj_expr_context(state, o->v.Starred.ctx);
4633 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4638 tp = (PyTypeObject *)state->Name_type;
4641 value = ast2obj_identifier(state, o->v.Name.id);
4643 if (PyObject_SetAttr(result, state->id, value) == -1)
4646 value = ast2obj_expr_context(state, o->v.Name.ctx);
4648 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4653 tp = (PyTypeObject *)state->List_type;
4656 value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
4658 if (PyObject_SetAttr(result, state->elts, value) == -1)
4661 value = ast2obj_expr_context(state, o->v.List.ctx);
4663 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4668 tp = (PyTypeObject *)state->Tuple_type;
4671 value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
4673 if (PyObject_SetAttr(result, state->elts, value) == -1)
4676 value = ast2obj_expr_context(state, o->v.Tuple.ctx);
4678 if (PyObject_SetAttr(result, state->ctx, value) == -1)
4683 tp = (PyTypeObject *)state->Slice_type;
4686 value = ast2obj_expr(state, o->v.Slice.lower);
4688 if (PyObject_SetAttr(result, state->lower, value) == -1)
4691 value = ast2obj_expr(state, o->v.Slice.upper);
4693 if (PyObject_SetAttr(result, state->upper, value) == -1)
4696 value = ast2obj_expr(state, o->v.Slice.step);
4698 if (PyObject_SetAttr(result, state->step, value) == -1)
4703 value = ast2obj_int(state, o->lineno);
4705 if (PyObject_SetAttr(result, state->lineno, value) < 0)
4708 value = ast2obj_int(state, o->col_offset);
4710 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4713 value = ast2obj_int(state, o->end_lineno);
4715 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4718 value = ast2obj_int(state, o->end_col_offset);
4720 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4723 state->recursion_depth--;
4731 PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
4735 Py_INCREF(state->Load_singleton);
4736 return state->Load_singleton;
4738 Py_INCREF(state->Store_singleton);
4739 return state->Store_singleton;
4741 Py_INCREF(state->Del_singleton);
4742 return state->Del_singleton;
4746 PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
4750 Py_INCREF(state->And_singleton);
4751 return state->And_singleton;
4753 Py_INCREF(state->Or_singleton);
4754 return state->Or_singleton;
4758 PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
4762 Py_INCREF(state->Add_singleton);
4763 return state->Add_singleton;
4765 Py_INCREF(state->Sub_singleton);
4766 return state->Sub_singleton;
4768 Py_INCREF(state->Mult_singleton);
4769 return state->Mult_singleton;
4771 Py_INCREF(state->MatMult_singleton);
4772 return state->MatMult_singleton;
4774 Py_INCREF(state->Div_singleton);
4775 return state->Div_singleton;
4777 Py_INCREF(state->Mod_singleton);
4778 return state->Mod_singleton;
4780 Py_INCREF(state->Pow_singleton);
4781 return state->Pow_singleton;
4783 Py_INCREF(state->LShift_singleton);
4784 return state->LShift_singleton;
4786 Py_INCREF(state->RShift_singleton);
4787 return state->RShift_singleton;
4789 Py_INCREF(state->BitOr_singleton);
4790 return state->BitOr_singleton;
4792 Py_INCREF(state->BitXor_singleton);
4793 return state->BitXor_singleton;
4795 Py_INCREF(state->BitAnd_singleton);
4796 return state->BitAnd_singleton;
4798 Py_INCREF(state->FloorDiv_singleton);
4799 return state->FloorDiv_singleton;
4803 PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
4807 Py_INCREF(state->Invert_singleton);
4808 return state->Invert_singleton;
4810 Py_INCREF(state->Not_singleton);
4811 return state->Not_singleton;
4813 Py_INCREF(state->UAdd_singleton);
4814 return state->UAdd_singleton;
4816 Py_INCREF(state->USub_singleton);
4817 return state->USub_singleton;
4821 PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
4825 Py_INCREF(state->Eq_singleton);
4826 return state->Eq_singleton;
4828 Py_INCREF(state->NotEq_singleton);
4829 return state->NotEq_singleton;
4831 Py_INCREF(state->Lt_singleton);
4832 return state->Lt_singleton;
4834 Py_INCREF(state->LtE_singleton);
4835 return state->LtE_singleton;
4837 Py_INCREF(state->Gt_singleton);
4838 return state->Gt_singleton;
4840 Py_INCREF(state->GtE_singleton);
4841 return state->GtE_singleton;
4843 Py_INCREF(state->Is_singleton);
4844 return state->Is_singleton;
4846 Py_INCREF(state->IsNot_singleton);
4847 return state->IsNot_singleton;
4849 Py_INCREF(state->In_singleton);
4850 return state->In_singleton;
4852 Py_INCREF(state->NotIn_singleton);
4853 return state->NotIn_singleton;
4858 ast2obj_comprehension(struct ast_state *state, void* _o)
4866 if (++state->recursion_depth > state->recursion_limit) {
4871 tp = (PyTypeObject *)state->comprehension_type;
4874 value = ast2obj_expr(state, o->target);
4876 if (PyObject_SetAttr(result, state->target, value) == -1)
4879 value = ast2obj_expr(state, o->iter);
4881 if (PyObject_SetAttr(result, state->iter, value) == -1)
4884 value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
4886 if (PyObject_SetAttr(result, state->ifs, value) == -1)
4889 value = ast2obj_int(state, o->is_async);
4891 if (PyObject_SetAttr(result, state->is_async, value) == -1)
4894 state->recursion_depth--;
4903 ast2obj_excepthandler(struct ast_state *state, void* _o)
4911 if (++state->recursion_depth > state->recursion_limit) {
4918 tp = (PyTypeObject *)state->ExceptHandler_type;
4921 value = ast2obj_expr(state, o->v.ExceptHandler.type);
4923 if (PyObject_SetAttr(result, state->type, value) == -1)
4926 value = ast2obj_identifier(state, o->v.ExceptHandler.name);
4928 if (PyObject_SetAttr(result, state->name, value) == -1)
4931 value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
4934 if (PyObject_SetAttr(result, state->body, value) == -1)
4939 value = ast2obj_int(state, o->lineno);
4941 if (PyObject_SetAttr(result, state->lineno, value) < 0)
4944 value = ast2obj_int(state, o->col_offset);
4946 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
4949 value = ast2obj_int(state, o->end_lineno);
4951 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
4954 value = ast2obj_int(state, o->end_col_offset);
4956 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
4959 state->recursion_depth--;
4968 ast2obj_arguments(struct ast_state *state, void* _o)
4976 if (++state->recursion_depth > state->recursion_limit) {
4981 tp = (PyTypeObject *)state->arguments_type;
4984 value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
4986 if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
4989 value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
4991 if (PyObject_SetAttr(result, state->args, value) == -1)
4994 value = ast2obj_arg(state, o->vararg);
4996 if (PyObject_SetAttr(result, state->vararg, value) == -1)
4999 value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
5001 if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
5004 value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
5006 if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
5009 value = ast2obj_arg(state, o->kwarg);
5011 if (PyObject_SetAttr(result, state->kwarg, value) == -1)
5014 value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
5016 if (PyObject_SetAttr(result, state->defaults, value) == -1)
5019 state->recursion_depth--;
5028 ast2obj_arg(struct ast_state *state, void* _o)
5036 if (++state->recursion_depth > state->recursion_limit) {
5041 tp = (PyTypeObject *)state->arg_type;
5044 value = ast2obj_identifier(state, o->arg);
5046 if (PyObject_SetAttr(result, state->arg, value) == -1)
5049 value = ast2obj_expr(state, o->annotation);
5051 if (PyObject_SetAttr(result, state->annotation, value) == -1)
5054 value = ast2obj_string(state, o->type_comment);
5056 if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5059 value = ast2obj_int(state, o->lineno);
5061 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5064 value = ast2obj_int(state, o->col_offset);
5066 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5069 value = ast2obj_int(state, o->end_lineno);
5071 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5074 value = ast2obj_int(state, o->end_col_offset);
5076 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5079 state->recursion_depth--;
5088 ast2obj_keyword(struct ast_state *state, void* _o)
5096 if (++state->recursion_depth > state->recursion_limit) {
5101 tp = (PyTypeObject *)state->keyword_type;
5104 value = ast2obj_identifier(state, o->arg);
5106 if (PyObject_SetAttr(result, state->arg, value) == -1)
5109 value = ast2obj_expr(state, o->value);
5111 if (PyObject_SetAttr(result, state->value, value) == -1)
5114 value = ast2obj_int(state, o->lineno);
5116 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5119 value = ast2obj_int(state, o->col_offset);
5121 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5124 value = ast2obj_int(state, o->end_lineno);
5126 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5129 value = ast2obj_int(state, o->end_col_offset);
5131 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5134 state->recursion_depth--;
5143 ast2obj_alias(struct ast_state *state, void* _o)
5151 if (++state->recursion_depth > state->recursion_limit) {
5156 tp = (PyTypeObject *)state->alias_type;
5159 value = ast2obj_identifier(state, o->name);
5161 if (PyObject_SetAttr(result, state->name, value) == -1)
5164 value = ast2obj_identifier(state, o->asname);
5166 if (PyObject_SetAttr(result, state->asname, value) == -1)
5169 value = ast2obj_int(state, o->lineno);
5171 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5174 value = ast2obj_int(state, o->col_offset);
5176 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5179 value = ast2obj_int(state, o->end_lineno);
5181 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5184 value = ast2obj_int(state, o->end_col_offset);
5186 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5189 state->recursion_depth--;
5198 ast2obj_withitem(struct ast_state *state, void* _o)
5206 if (++state->recursion_depth > state->recursion_limit) {
5211 tp = (PyTypeObject *)state->withitem_type;
5214 value = ast2obj_expr(state, o->context_expr);
5216 if (PyObject_SetAttr(result, state->context_expr, value) == -1)
5219 value = ast2obj_expr(state, o->optional_vars);
5221 if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
5224 state->recursion_depth--;
5233 ast2obj_match_case(struct ast_state *state, void* _o)
5241 if (++state->recursion_depth > state->recursion_limit) {
5246 tp = (PyTypeObject *)state->match_case_type;
5249 value = ast2obj_pattern(state, o->pattern);
5251 if (PyObject_SetAttr(result, state->pattern, value) == -1)
5254 value = ast2obj_expr(state, o->guard);
5256 if (PyObject_SetAttr(result, state->guard, value) == -1)
5259 value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
5261 if (PyObject_SetAttr(result, state->body, value) == -1)
5264 state->recursion_depth--;
5273 ast2obj_pattern(struct ast_state *state, void* _o)
5281 if (++state->recursion_depth > state->recursion_limit) {
5288 tp = (PyTypeObject *)state->MatchValue_type;
5291 value = ast2obj_expr(state, o->v.MatchValue.value);
5293 if (PyObject_SetAttr(result, state->value, value) == -1)
5298 tp = (PyTypeObject *)state->MatchSingleton_type;
5301 value = ast2obj_constant(state, o->v.MatchSingleton.value);
5303 if (PyObject_SetAttr(result, state->value, value) == -1)
5308 tp = (PyTypeObject *)state->MatchSequence_type;
5311 value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
5314 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5319 tp = (PyTypeObject *)state->MatchMapping_type;
5322 value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
5325 if (PyObject_SetAttr(result, state->keys, value) == -1)
5328 value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
5331 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5334 value = ast2obj_identifier(state, o->v.MatchMapping.rest);
5336 if (PyObject_SetAttr(result, state->rest, value) == -1)
5341 tp = (PyTypeObject *)state->MatchClass_type;
5344 value = ast2obj_expr(state, o->v.MatchClass.cls);
5346 if (PyObject_SetAttr(result, state->cls, value) == -1)
5349 value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
5352 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5355 value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
5358 if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
5361 value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
5364 if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
5369 tp = (PyTypeObject *)state->MatchStar_type;
5372 value = ast2obj_identifier(state, o->v.MatchStar.name);
5374 if (PyObject_SetAttr(result, state->name, value) == -1)
5379 tp = (PyTypeObject *)state->MatchAs_type;
5382 value = ast2obj_pattern(state, o->v.MatchAs.pattern);
5384 if (PyObject_SetAttr(result, state->pattern, value) == -1)
5387 value = ast2obj_identifier(state, o->v.MatchAs.name);
5389 if (PyObject_SetAttr(result, state->name, value) == -1)
5394 tp = (PyTypeObject *)state->MatchOr_type;
5397 value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
5400 if (PyObject_SetAttr(result, state->patterns, value) == -1)
5405 value = ast2obj_int(state, o->lineno);
5407 if (PyObject_SetAttr(result, state->lineno, value) < 0)
5410 value = ast2obj_int(state, o->col_offset);
5412 if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5415 value = ast2obj_int(state, o->end_lineno);
5417 if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5420 value = ast2obj_int(state, o->end_col_offset);
5422 if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5425 state->recursion_depth--;
5434 ast2obj_type_ignore(struct ast_state *state, void* _o)
5442 if (++state->recursion_depth > state->recursion_limit) {
5449 tp = (PyTypeObject *)state->TypeIgnore_type;
5452 value = ast2obj_int(state, o->v.TypeIgnore.lineno);
5454 if (PyObject_SetAttr(result, state->lineno, value) == -1)
5457 value = ast2obj_string(state, o->v.TypeIgnore.tag);
5459 if (PyObject_SetAttr(result, state->tag, value) == -1)
5464 state->recursion_depth--;
5474 obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
5485 tp = state->Module_type;
5494 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5519 res = obj2ast_stmt(state, tmp2, &val, arena);
5531 if (_PyObject_LookupAttr(obj, state->type_ignores, &tmp) < 0) {
5556 res = obj2ast_type_ignore(state, tmp2, &val, arena);
5572 tp = state->Interactive_type;
5580 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5605 res = obj2ast_stmt(state, tmp2, &val, arena);
5621 tp = state->Expression_type;
5629 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5641 res = obj2ast_expr(state, tmp, &body, arena);
5650 tp = state->FunctionType_type;
5659 if (_PyObject_LookupAttr(obj, state->argtypes, &tmp) < 0) {
5684 res = obj2ast_expr(state, tmp2, &val, arena);
5696 if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5708 res = obj2ast_expr(state, tmp, &returns, arena);
5725 obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
5741 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
5753 res = obj2ast_int(state, tmp, &lineno, arena);
5758 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
5770 res = obj2ast_int(state, tmp, &col_offset, arena);
5775 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
5787 res = obj2ast_int(state, tmp, &end_lineno, arena);
5792 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
5804 res = obj2ast_int(state, tmp, &end_col_offset, arena);
5809 tp = state->FunctionDef_type;
5822 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5834 res = obj2ast_identifier(state, tmp, &name, arena);
5839 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
5851 res = obj2ast_arguments(state, tmp, &args, arena);
5856 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
5881 res = obj2ast_stmt(state, tmp2, &val, arena);
5893 if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
5918 res = obj2ast_expr(state, tmp2, &val, arena);
5930 if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
5942 res = obj2ast_expr(state, tmp, &returns, arena);
5947 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
5959 res = obj2ast_string(state, tmp, &type_comment, arena);
5970 tp = state->AsyncFunctionDef_type;
5983 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
5995 res = obj2ast_identifier(state, tmp, &name, arena);
6000 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
6012 res = obj2ast_arguments(state, tmp, &args, arena);
6017 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6042 res = obj2ast_stmt(state, tmp2, &val, arena);
6054 if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
6079 res = obj2ast_expr(state, tmp2, &val, arena);
6091 if (_PyObject_LookupAttr(obj, state->returns, &tmp) < 0) {
6103 res = obj2ast_expr(state, tmp, &returns, arena);
6108 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6120 res = obj2ast_string(state, tmp, &type_comment, arena);
6132 tp = state->ClassDef_type;
6144 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
6156 res = obj2ast_identifier(state, tmp, &name, arena);
6161 if (_PyObject_LookupAttr(obj, state->bases, &tmp) < 0) {
6186 res = obj2ast_expr(state, tmp2, &val, arena);
6198 if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
6223 res = obj2ast_keyword(state, tmp2, &val, arena);
6235 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6260 res = obj2ast_stmt(state, tmp2, &val, arena);
6272 if (_PyObject_LookupAttr(obj, state->decorator_list, &tmp) < 0) {
6297 res = obj2ast_expr(state, tmp2, &val, arena);
6315 tp = state->Return_type;
6323 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6335 res = obj2ast_expr(state, tmp, &value, arena);
6345 tp = state->Delete_type;
6353 if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6378 res = obj2ast_expr(state, tmp2, &val, arena);
6395 tp = state->Assign_type;
6405 if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
6430 res = obj2ast_expr(state, tmp2, &val, arena);
6442 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6454 res = obj2ast_expr(state, tmp, &value, arena);
6459 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6471 res = obj2ast_string(state, tmp, &type_comment, arena);
6481 tp = state->AugAssign_type;
6491 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6503 res = obj2ast_expr(state, tmp, &target, arena);
6508 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
6520 res = obj2ast_operator(state, tmp, &op, arena);
6525 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6537 res = obj2ast_expr(state, tmp, &value, arena);
6547 tp = state->AnnAssign_type;
6558 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6570 res = obj2ast_expr(state, tmp, &target, arena);
6575 if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
6587 res = obj2ast_expr(state, tmp, &annotation, arena);
6592 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
6604 res = obj2ast_expr(state, tmp, &value, arena);
6609 if (_PyObject_LookupAttr(obj, state->simple, &tmp) < 0) {
6621 res = obj2ast_int(state, tmp, &simple, arena);
6631 tp = state->For_type;
6643 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6655 res = obj2ast_expr(state, tmp, &target, arena);
6660 if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6672 res = obj2ast_expr(state, tmp, &iter, arena);
6677 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6702 res = obj2ast_stmt(state, tmp2, &val, arena);
6714 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6739 res = obj2ast_stmt(state, tmp2, &val, arena);
6751 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6763 res = obj2ast_string(state, tmp, &type_comment, arena);
6773 tp = state->AsyncFor_type;
6785 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
6797 res = obj2ast_expr(state, tmp, &target, arena);
6802 if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
6814 res = obj2ast_expr(state, tmp, &iter, arena);
6819 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6844 res = obj2ast_stmt(state, tmp2, &val, arena);
6856 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
6881 res = obj2ast_stmt(state, tmp2, &val, arena);
6893 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
6905 res = obj2ast_string(state, tmp, &type_comment, arena);
6916 tp = state->While_type;
6926 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
6938 res = obj2ast_expr(state, tmp, &test, arena);
6943 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
6968 res = obj2ast_stmt(state, tmp2, &val, arena);
6980 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7005 res = obj2ast_stmt(state, tmp2, &val, arena);
7022 tp = state->If_type;
7032 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
7044 res = obj2ast_expr(state, tmp, &test, arena);
7049 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7074 res = obj2ast_stmt(state, tmp2, &val, arena);
7086 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7111 res = obj2ast_stmt(state, tmp2, &val, arena);
7128 tp = state->With_type;
7138 if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7163 res = obj2ast_withitem(state, tmp2, &val, arena);
7175 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7200 res = obj2ast_stmt(state, tmp2, &val, arena);
7212 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7224 res = obj2ast_string(state, tmp, &type_comment, arena);
7234 tp = state->AsyncWith_type;
7244 if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
7269 res = obj2ast_withitem(state, tmp2, &val, arena);
7281 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7306 res = obj2ast_stmt(state, tmp2, &val, arena);
7318 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
7330 res = obj2ast_string(state, tmp, &type_comment, arena);
7340 tp = state->Match_type;
7349 if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) {
7361 res = obj2ast_expr(state, tmp, &subject, arena);
7366 if (_PyObject_LookupAttr(obj, state->cases, &tmp) < 0) {
7391 res = obj2ast_match_case(state, tmp2, &val, arena);
7408 tp = state->Raise_type;
7417 if (_PyObject_LookupAttr(obj, state->exc, &tmp) < 0) {
7429 res = obj2ast_expr(state, tmp, &exc, arena);
7434 if (_PyObject_LookupAttr(obj, state->cause, &tmp) < 0) {
7446 res = obj2ast_expr(state, tmp, &cause, arena);
7456 tp = state->Try_type;
7467 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7492 res = obj2ast_stmt(state, tmp2, &val, arena);
7504 if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7529 res = obj2ast_excepthandler(state, tmp2, &val, arena);
7541 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7566 res = obj2ast_stmt(state, tmp2, &val, arena);
7578 if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7603 res = obj2ast_stmt(state, tmp2, &val, arena);
7620 tp = state->TryStar_type;
7631 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
7656 res = obj2ast_stmt(state, tmp2, &val, arena);
7668 if (_PyObject_LookupAttr(obj, state->handlers, &tmp) < 0) {
7693 res = obj2ast_excepthandler(state, tmp2, &val, arena);
7705 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
7730 res = obj2ast_stmt(state, tmp2, &val, arena);
7742 if (_PyObject_LookupAttr(obj, state->finalbody, &tmp) < 0) {
7767 res = obj2ast_stmt(state, tmp2, &val, arena);
7784 tp = state->Assert_type;
7793 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
7805 res = obj2ast_expr(state, tmp, &test, arena);
7810 if (_PyObject_LookupAttr(obj, state->msg, &tmp) < 0) {
7822 res = obj2ast_expr(state, tmp, &msg, arena);
7832 tp = state->Import_type;
7840 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7865 res = obj2ast_alias(state, tmp2, &val, arena);
7882 tp = state->ImportFrom_type;
7892 if (_PyObject_LookupAttr(obj, state->module, &tmp) < 0) {
7904 res = obj2ast_identifier(state, tmp, &module, arena);
7909 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
7934 res = obj2ast_alias(state, tmp2, &val, arena);
7946 if (_PyObject_LookupAttr(obj, state->level, &tmp) < 0) {
7958 res = obj2ast_int(state, tmp, &level, arena);
7968 tp = state->Global_type;
7976 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
8001 res = obj2ast_identifier(state, tmp2, &val, arena);
8018 tp = state->Nonlocal_type;
8026 if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
8051 res = obj2ast_identifier(state, tmp2, &val, arena);
8068 tp = state->Expr_type;
8076 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8088 res = obj2ast_expr(state, tmp, &value, arena);
8098 tp = state->Pass_type;
8110 tp = state->Break_type;
8122 tp = state->Continue_type;
8142 obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
8158 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
8170 res = obj2ast_int(state, tmp, &lineno, arena);
8175 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
8187 res = obj2ast_int(state, tmp, &col_offset, arena);
8192 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
8204 res = obj2ast_int(state, tmp, &end_lineno, arena);
8209 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
8221 res = obj2ast_int(state, tmp, &end_col_offset, arena);
8226 tp = state->BoolOp_type;
8235 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8247 res = obj2ast_boolop(state, tmp, &op, arena);
8252 if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8277 res = obj2ast_expr(state, tmp2, &val, arena);
8294 tp = state->NamedExpr_type;
8303 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
8315 res = obj2ast_expr(state, tmp, &target, arena);
8320 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8332 res = obj2ast_expr(state, tmp, &value, arena);
8342 tp = state->BinOp_type;
8352 if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
8364 res = obj2ast_expr(state, tmp, &left, arena);
8369 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8381 res = obj2ast_operator(state, tmp, &op, arena);
8386 if (_PyObject_LookupAttr(obj, state->right, &tmp) < 0) {
8398 res = obj2ast_expr(state, tmp, &right, arena);
8408 tp = state->UnaryOp_type;
8417 if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
8429 res = obj2ast_unaryop(state, tmp, &op, arena);
8434 if (_PyObject_LookupAttr(obj, state->operand, &tmp) < 0) {
8446 res = obj2ast_expr(state, tmp, &operand, arena);
8456 tp = state->Lambda_type;
8465 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
8477 res = obj2ast_arguments(state, tmp, &args, arena);
8482 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8494 res = obj2ast_expr(state, tmp, &body, arena);
8504 tp = state->IfExp_type;
8514 if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
8526 res = obj2ast_expr(state, tmp, &test, arena);
8531 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
8543 res = obj2ast_expr(state, tmp, &body, arena);
8548 if (_PyObject_LookupAttr(obj, state->orelse, &tmp) < 0) {
8560 res = obj2ast_expr(state, tmp, &orelse, arena);
8570 tp = state->Dict_type;
8579 if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
8604 res = obj2ast_expr(state, tmp2, &val, arena);
8616 if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
8641 res = obj2ast_expr(state, tmp2, &val, arena);
8658 tp = state->Set_type;
8666 if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
8691 res = obj2ast_expr(state, tmp2, &val, arena);
8708 tp = state->ListComp_type;
8717 if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8729 res = obj2ast_expr(state, tmp, &elt, arena);
8734 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8759 res = obj2ast_comprehension(state, tmp2, &val, arena);
8776 tp = state->SetComp_type;
8785 if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8797 res = obj2ast_expr(state, tmp, &elt, arena);
8802 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8827 res = obj2ast_comprehension(state, tmp2, &val, arena);
8844 tp = state->DictComp_type;
8854 if (_PyObject_LookupAttr(obj, state->key, &tmp) < 0) {
8866 res = obj2ast_expr(state, tmp, &key, arena);
8871 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
8883 res = obj2ast_expr(state, tmp, &value, arena);
8888 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8913 res = obj2ast_comprehension(state, tmp2, &val, arena);
8930 tp = state->GeneratorExp_type;
8939 if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
8951 res = obj2ast_expr(state, tmp, &elt, arena);
8956 if (_PyObject_LookupAttr(obj, state->generators, &tmp) < 0) {
8981 res = obj2ast_comprehension(state, tmp2, &val, arena);
8998 tp = state->Await_type;
9006 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9018 res = obj2ast_expr(state, tmp, &value, arena);
9028 tp = state->Yield_type;
9036 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9048 res = obj2ast_expr(state, tmp, &value, arena);
9058 tp = state->YieldFrom_type;
9066 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9078 res = obj2ast_expr(state, tmp, &value, arena);
9088 tp = state->Compare_type;
9098 if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
9110 res = obj2ast_expr(state, tmp, &left, arena);
9115 if (_PyObject_LookupAttr(obj, state->ops, &tmp) < 0) {
9140 res = obj2ast_cmpop(state, tmp2, &val, arena);
9152 if (_PyObject_LookupAttr(obj, state->comparators, &tmp) < 0) {
9177 res = obj2ast_expr(state, tmp2, &val, arena);
9194 tp = state->Call_type;
9204 if (_PyObject_LookupAttr(obj, state->func, &tmp) < 0) {
9216 res = obj2ast_expr(state, tmp, &func, arena);
9221 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
9246 res = obj2ast_expr(state, tmp2, &val, arena);
9258 if (_PyObject_LookupAttr(obj, state->keywords, &tmp) < 0) {
9283 res = obj2ast_keyword(state, tmp2, &val, arena);
9300 tp = state->FormattedValue_type;
9310 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9322 res = obj2ast_expr(state, tmp, &value, arena);
9327 if (_PyObject_LookupAttr(obj, state->conversion, &tmp) < 0) {
9339 res = obj2ast_int(state, tmp, &conversion, arena);
9344 if (_PyObject_LookupAttr(obj, state->format_spec, &tmp) < 0) {
9356 res = obj2ast_expr(state, tmp, &format_spec, arena);
9367 tp = state->JoinedStr_type;
9375 if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
9400 res = obj2ast_expr(state, tmp2, &val, arena);
9417 tp = state->Constant_type;
9426 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9438 res = obj2ast_constant(state, tmp, &value, arena);
9443 if (_PyObject_LookupAttr(obj, state->kind, &tmp) < 0) {
9455 res = obj2ast_string(state, tmp, &kind, arena);
9465 tp = state->Attribute_type;
9475 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9487 res = obj2ast_expr(state, tmp, &value, arena);
9492 if (_PyObject_LookupAttr(obj, state->attr, &tmp) < 0) {
9504 res = obj2ast_identifier(state, tmp, &attr, arena);
9509 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9521 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9531 tp = state->Subscript_type;
9541 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9553 res = obj2ast_expr(state, tmp, &value, arena);
9558 if (_PyObject_LookupAttr(obj, state->slice, &tmp) < 0) {
9570 res = obj2ast_expr(state, tmp, &slice, arena);
9575 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9587 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9597 tp = state->Starred_type;
9606 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
9618 res = obj2ast_expr(state, tmp, &value, arena);
9623 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9635 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9645 tp = state->Name_type;
9654 if (_PyObject_LookupAttr(obj, state->id, &tmp) < 0) {
9666 res = obj2ast_identifier(state, tmp, &id, arena);
9671 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9683 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9693 tp = state->List_type;
9702 if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9727 res = obj2ast_expr(state, tmp2, &val, arena);
9739 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9751 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9761 tp = state->Tuple_type;
9770 if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
9795 res = obj2ast_expr(state, tmp2, &val, arena);
9807 if (_PyObject_LookupAttr(obj, state->ctx, &tmp) < 0) {
9819 res = obj2ast_expr_context(state, tmp, &ctx, arena);
9829 tp = state->Slice_type;
9839 if (_PyObject_LookupAttr(obj, state->lower, &tmp) < 0) {
9851 res = obj2ast_expr(state, tmp, &lower, arena);
9856 if (_PyObject_LookupAttr(obj, state->upper, &tmp) < 0) {
9868 res = obj2ast_expr(state, tmp, &upper, arena);
9873 if (_PyObject_LookupAttr(obj, state->step, &tmp) < 0) {
9885 res = obj2ast_expr(state, tmp, &step, arena);
9903 obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
9908 isinstance = PyObject_IsInstance(obj, state->Load_type);
9916 isinstance = PyObject_IsInstance(obj, state->Store_type);
9924 isinstance = PyObject_IsInstance(obj, state->Del_type);
9938 obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
9943 isinstance = PyObject_IsInstance(obj, state->And_type);
9951 isinstance = PyObject_IsInstance(obj, state->Or_type);
9965 obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
9970 isinstance = PyObject_IsInstance(obj, state->Add_type);
9978 isinstance = PyObject_IsInstance(obj, state->Sub_type);
9986 isinstance = PyObject_IsInstance(obj, state->Mult_type);
9994 isinstance = PyObject_IsInstance(obj, state->MatMult_type);
10002 isinstance = PyObject_IsInstance(obj, state->Div_type);
10010 isinstance = PyObject_IsInstance(obj, state->Mod_type);
10018 isinstance = PyObject_IsInstance(obj, state->Pow_type);
10026 isinstance = PyObject_IsInstance(obj, state->LShift_type);
10034 isinstance = PyObject_IsInstance(obj, state->RShift_type);
10042 isinstance = PyObject_IsInstance(obj, state->BitOr_type);
10050 isinstance = PyObject_IsInstance(obj, state->BitXor_type);
10058 isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
10066 isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
10080 obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
10085 isinstance = PyObject_IsInstance(obj, state->Invert_type);
10093 isinstance = PyObject_IsInstance(obj, state->Not_type);
10101 isinstance = PyObject_IsInstance(obj, state->UAdd_type);
10109 isinstance = PyObject_IsInstance(obj, state->USub_type);
10123 obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
10128 isinstance = PyObject_IsInstance(obj, state->Eq_type);
10136 isinstance = PyObject_IsInstance(obj, state->NotEq_type);
10144 isinstance = PyObject_IsInstance(obj, state->Lt_type);
10152 isinstance = PyObject_IsInstance(obj, state->LtE_type);
10160 isinstance = PyObject_IsInstance(obj, state->Gt_type);
10168 isinstance = PyObject_IsInstance(obj, state->GtE_type);
10176 isinstance = PyObject_IsInstance(obj, state->Is_type);
10184 isinstance = PyObject_IsInstance(obj, state->IsNot_type);
10192 isinstance = PyObject_IsInstance(obj, state->In_type);
10200 isinstance = PyObject_IsInstance(obj, state->NotIn_type);
10214 obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
10223 if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
10235 res = obj2ast_expr(state, tmp, &target, arena);
10240 if (_PyObject_LookupAttr(obj, state->iter, &tmp) < 0) {
10252 res = obj2ast_expr(state, tmp, &iter, arena);
10257 if (_PyObject_LookupAttr(obj, state->ifs, &tmp) < 0) {
10282 res = obj2ast_expr(state, tmp2, &val, arena);
10294 if (_PyObject_LookupAttr(obj, state->is_async, &tmp) < 0) {
10306 res = obj2ast_int(state, tmp, &is_async, arena);
10319 obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
10335 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10347 res = obj2ast_int(state, tmp, &lineno, arena);
10352 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10364 res = obj2ast_int(state, tmp, &col_offset, arena);
10369 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10381 res = obj2ast_int(state, tmp, &end_lineno, arena);
10386 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10398 res = obj2ast_int(state, tmp, &end_col_offset, arena);
10403 tp = state->ExceptHandler_type;
10413 if (_PyObject_LookupAttr(obj, state->type, &tmp) < 0) {
10425 res = obj2ast_expr(state, tmp, &type, arena);
10430 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
10442 res = obj2ast_identifier(state, tmp, &name, arena);
10447 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
10472 res = obj2ast_stmt(state, tmp2, &val, arena);
10497 obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
10509 if (_PyObject_LookupAttr(obj, state->posonlyargs, &tmp) < 0) {
10534 res = obj2ast_arg(state, tmp2, &val, arena);
10546 if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) {
10571 res = obj2ast_arg(state, tmp2, &val, arena);
10583 if (_PyObject_LookupAttr(obj, state->vararg, &tmp) < 0) {
10595 res = obj2ast_arg(state, tmp, &vararg, arena);
10600 if (_PyObject_LookupAttr(obj, state->kwonlyargs, &tmp) < 0) {
10625 res = obj2ast_arg(state, tmp2, &val, arena);
10637 if (_PyObject_LookupAttr(obj, state->kw_defaults, &tmp) < 0) {
10662 res = obj2ast_expr(state, tmp2, &val, arena);
10674 if (_PyObject_LookupAttr(obj, state->kwarg, &tmp) < 0) {
10686 res = obj2ast_arg(state, tmp, &kwarg, arena);
10691 if (_PyObject_LookupAttr(obj, state->defaults, &tmp) < 0) {
10716 res = obj2ast_expr(state, tmp2, &val, arena);
10737 obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
10748 if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10760 res = obj2ast_identifier(state, tmp, &arg, arena);
10765 if (_PyObject_LookupAttr(obj, state->annotation, &tmp) < 0) {
10777 res = obj2ast_expr(state, tmp, &annotation, arena);
10782 if (_PyObject_LookupAttr(obj, state->type_comment, &tmp) < 0) {
10794 res = obj2ast_string(state, tmp, &type_comment, arena);
10799 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10811 res = obj2ast_int(state, tmp, &lineno, arena);
10816 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10828 res = obj2ast_int(state, tmp, &col_offset, arena);
10833 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10845 res = obj2ast_int(state, tmp, &end_lineno, arena);
10850 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10862 res = obj2ast_int(state, tmp, &end_col_offset, arena);
10876 obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
10887 if (_PyObject_LookupAttr(obj, state->arg, &tmp) < 0) {
10899 res = obj2ast_identifier(state, tmp, &arg, arena);
10904 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
10916 res = obj2ast_expr(state, tmp, &value, arena);
10921 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
10933 res = obj2ast_int(state, tmp, &lineno, arena);
10938 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
10950 res = obj2ast_int(state, tmp, &col_offset, arena);
10955 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
10967 res = obj2ast_int(state, tmp, &end_lineno, arena);
10972 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
10984 res = obj2ast_int(state, tmp, &end_col_offset, arena);
10998 obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
11009 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11021 res = obj2ast_identifier(state, tmp, &name, arena);
11026 if (_PyObject_LookupAttr(obj, state->asname, &tmp) < 0) {
11038 res = obj2ast_identifier(state, tmp, &asname, arena);
11043 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11055 res = obj2ast_int(state, tmp, &lineno, arena);
11060 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
11072 res = obj2ast_int(state, tmp, &col_offset, arena);
11077 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
11089 res = obj2ast_int(state, tmp, &end_lineno, arena);
11094 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11106 res = obj2ast_int(state, tmp, &end_col_offset, arena);
11120 obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
11127 if (_PyObject_LookupAttr(obj, state->context_expr, &tmp) < 0) {
11139 res = obj2ast_expr(state, tmp, &context_expr, arena);
11144 if (_PyObject_LookupAttr(obj, state->optional_vars, &tmp) < 0) {
11156 res = obj2ast_expr(state, tmp, &optional_vars, arena);
11169 obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
11177 if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11189 res = obj2ast_pattern(state, tmp, &pattern, arena);
11194 if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) {
11206 res = obj2ast_expr(state, tmp, &guard, arena);
11211 if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
11236 res = obj2ast_stmt(state, tmp2, &val, arena);
11256 obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
11272 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11284 res = obj2ast_int(state, tmp, &lineno, arena);
11289 if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
11301 res = obj2ast_int(state, tmp, &col_offset, arena);
11306 if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
11318 res = obj2ast_int(state, tmp, &end_lineno, arena);
11323 if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
11335 res = obj2ast_int(state, tmp, &end_col_offset, arena);
11340 tp = state->MatchValue_type;
11348 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11360 res = obj2ast_expr(state, tmp, &value, arena);
11370 tp = state->MatchSingleton_type;
11378 if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
11390 res = obj2ast_constant(state, tmp, &value, arena);
11400 tp = state->MatchSequence_type;
11408 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11433 res = obj2ast_pattern(state, tmp2, &val, arena);
11450 tp = state->MatchMapping_type;
11460 if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
11485 res = obj2ast_expr(state, tmp2, &val, arena);
11497 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11522 res = obj2ast_pattern(state, tmp2, &val, arena);
11534 if (_PyObject_LookupAttr(obj, state->rest, &tmp) < 0) {
11546 res = obj2ast_identifier(state, tmp, &rest, arena);
11556 tp = state->MatchClass_type;
11567 if (_PyObject_LookupAttr(obj, state->cls, &tmp) < 0) {
11579 res = obj2ast_expr(state, tmp, &cls, arena);
11584 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11609 res = obj2ast_pattern(state, tmp2, &val, arena);
11621 if (_PyObject_LookupAttr(obj, state->kwd_attrs, &tmp) < 0) {
11646 res = obj2ast_identifier(state, tmp2, &val, arena);
11658 if (_PyObject_LookupAttr(obj, state->kwd_patterns, &tmp) < 0) {
11683 res = obj2ast_pattern(state, tmp2, &val, arena);
11701 tp = state->MatchStar_type;
11709 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11721 res = obj2ast_identifier(state, tmp, &name, arena);
11731 tp = state->MatchAs_type;
11740 if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
11752 res = obj2ast_pattern(state, tmp, &pattern, arena);
11757 if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
11769 res = obj2ast_identifier(state, tmp, &name, arena);
11779 tp = state->MatchOr_type;
11787 if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
11812 res = obj2ast_pattern(state, tmp2, &val, arena);
11837 obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
11849 tp = state->TypeIgnore_type;
11858 if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
11870 res = obj2ast_int(state, tmp, &lineno, arena);
11875 if (_PyObject_LookupAttr(obj, state->tag, &tmp) < 0) {
11887 res = obj2ast_string(state, tmp, &tag, arena);
11907 struct ast_state *state = get_ast_state();
11908 if (state == NULL) {
11911 if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
11923 if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
11926 if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
11929 if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
11932 if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
11935 if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
11939 if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
11942 if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
11946 state->AsyncFunctionDef_type) < 0) {
11949 if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
11952 if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
11955 if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
11958 if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
11961 if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
11964 if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
11967 if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
11970 if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
11973 if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
11976 if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
11979 if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
11982 if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
11985 if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
11988 if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
11991 if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
11994 if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
11997 if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
12000 if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
12003 if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
12006 if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
12009 if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
12012 if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
12015 if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
12018 if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
12021 if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
12024 if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
12027 if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
12030 if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
12033 if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
12036 if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
12039 if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
12042 if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
12045 if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
12048 if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
12051 if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
12054 if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
12057 if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
12060 if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
12064 if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
12067 if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
12070 if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
12073 if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
12076 if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
12079 if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
12083 if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
12086 if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
12089 if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
12092 if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
12095 if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
12098 if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
12101 if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
12104 if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
12107 if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
12110 if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
12114 if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
12117 if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
12120 if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
12123 if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
12126 if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
12129 if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
12132 if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
12135 if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
12138 if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
12141 if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
12144 if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
12147 if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
12150 if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
12153 if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
12156 if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
12159 if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
12162 if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
12165 if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
12168 if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
12171 if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
12174 if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
12177 if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
12180 if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
12183 if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
12186 if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
12189 if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
12192 if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
12195 if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
12198 if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
12201 if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
12204 if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
12207 if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
12210 if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
12213 if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
12216 if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
12219 if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
12222 if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
12226 if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
12230 if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
12234 if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
12237 if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
12240 if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
12243 if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
12246 if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
12249 if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
12252 if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
12255 if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
12258 if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
12262 if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
12266 if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
12270 if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
12273 if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
12276 if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
12279 if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
12282 if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
12285 if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
12299 // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
12313 struct ast_state *state = get_ast_state();
12314 if (state == NULL) {
12326 state->recursion_limit = (recursion_limit < INT_MAX / COMPILER_STACK_FRAME_SCALE) ?
12331 state->recursion_depth = starting_recursion_depth;
12333 PyObject *result = ast2obj_mod(state, t);
12336 if (result && state->recursion_depth != starting_recursion_depth) {
12339 starting_recursion_depth, state->recursion_depth);
12355 struct ast_state *state = get_ast_state();
12356 if (state == NULL) {
12361 req_type[0] = state->Module_type;
12362 req_type[1] = state->Expression_type;
12363 req_type[2] = state->Interactive_type;
12377 if (obj2ast_mod(state, ast, &res, arena) != 0)
12385 struct ast_state *state = get_ast_state();
12386 if (state == NULL) {
12389 return PyObject_IsInstance(obj, state->AST_type);