LCOV - code coverage report
Current view: top level - libreoffice/workdir/unxlngi6.pro/UnpackedTarball/python3/Python - Python-ast.c (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 682 4619 14.8 %
Date: 2012-12-17 Functions: 41 113 36.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* File automatically generated by Parser/asdl_c.py. */
       2             : 
       3             : #include <stddef.h>
       4             : 
       5             : #include "Python.h"
       6             : #include "Python-ast.h"
       7             : 
       8             : static PyTypeObject AST_type;
       9             : static PyTypeObject *mod_type;
      10             : static PyObject* ast2obj_mod(void*);
      11             : static PyTypeObject *Module_type;
      12             : _Py_IDENTIFIER(body);
      13             : static char *Module_fields[]={
      14             :         "body",
      15             : };
      16             : static PyTypeObject *Interactive_type;
      17             : static char *Interactive_fields[]={
      18             :         "body",
      19             : };
      20             : static PyTypeObject *Expression_type;
      21             : static char *Expression_fields[]={
      22             :         "body",
      23             : };
      24             : static PyTypeObject *Suite_type;
      25             : static char *Suite_fields[]={
      26             :         "body",
      27             : };
      28             : static PyTypeObject *stmt_type;
      29             : _Py_IDENTIFIER(lineno);
      30             : _Py_IDENTIFIER(col_offset);
      31             : static char *stmt_attributes[] = {
      32             :         "lineno",
      33             :         "col_offset",
      34             : };
      35             : static PyObject* ast2obj_stmt(void*);
      36             : static PyTypeObject *FunctionDef_type;
      37             : _Py_IDENTIFIER(name);
      38             : _Py_IDENTIFIER(args);
      39             : _Py_IDENTIFIER(decorator_list);
      40             : _Py_IDENTIFIER(returns);
      41             : static char *FunctionDef_fields[]={
      42             :         "name",
      43             :         "args",
      44             :         "body",
      45             :         "decorator_list",
      46             :         "returns",
      47             : };
      48             : static PyTypeObject *ClassDef_type;
      49             : _Py_IDENTIFIER(bases);
      50             : _Py_IDENTIFIER(keywords);
      51             : _Py_IDENTIFIER(starargs);
      52             : _Py_IDENTIFIER(kwargs);
      53             : static char *ClassDef_fields[]={
      54             :         "name",
      55             :         "bases",
      56             :         "keywords",
      57             :         "starargs",
      58             :         "kwargs",
      59             :         "body",
      60             :         "decorator_list",
      61             : };
      62             : static PyTypeObject *Return_type;
      63             : _Py_IDENTIFIER(value);
      64             : static char *Return_fields[]={
      65             :         "value",
      66             : };
      67             : static PyTypeObject *Delete_type;
      68             : _Py_IDENTIFIER(targets);
      69             : static char *Delete_fields[]={
      70             :         "targets",
      71             : };
      72             : static PyTypeObject *Assign_type;
      73             : static char *Assign_fields[]={
      74             :         "targets",
      75             :         "value",
      76             : };
      77             : static PyTypeObject *AugAssign_type;
      78             : _Py_IDENTIFIER(target);
      79             : _Py_IDENTIFIER(op);
      80             : static char *AugAssign_fields[]={
      81             :         "target",
      82             :         "op",
      83             :         "value",
      84             : };
      85             : static PyTypeObject *For_type;
      86             : _Py_IDENTIFIER(iter);
      87             : _Py_IDENTIFIER(orelse);
      88             : static char *For_fields[]={
      89             :         "target",
      90             :         "iter",
      91             :         "body",
      92             :         "orelse",
      93             : };
      94             : static PyTypeObject *While_type;
      95             : _Py_IDENTIFIER(test);
      96             : static char *While_fields[]={
      97             :         "test",
      98             :         "body",
      99             :         "orelse",
     100             : };
     101             : static PyTypeObject *If_type;
     102             : static char *If_fields[]={
     103             :         "test",
     104             :         "body",
     105             :         "orelse",
     106             : };
     107             : static PyTypeObject *With_type;
     108             : _Py_IDENTIFIER(items);
     109             : static char *With_fields[]={
     110             :         "items",
     111             :         "body",
     112             : };
     113             : static PyTypeObject *Raise_type;
     114             : _Py_IDENTIFIER(exc);
     115             : _Py_IDENTIFIER(cause);
     116             : static char *Raise_fields[]={
     117             :         "exc",
     118             :         "cause",
     119             : };
     120             : static PyTypeObject *Try_type;
     121             : _Py_IDENTIFIER(handlers);
     122             : _Py_IDENTIFIER(finalbody);
     123             : static char *Try_fields[]={
     124             :         "body",
     125             :         "handlers",
     126             :         "orelse",
     127             :         "finalbody",
     128             : };
     129             : static PyTypeObject *Assert_type;
     130             : _Py_IDENTIFIER(msg);
     131             : static char *Assert_fields[]={
     132             :         "test",
     133             :         "msg",
     134             : };
     135             : static PyTypeObject *Import_type;
     136             : _Py_IDENTIFIER(names);
     137             : static char *Import_fields[]={
     138             :         "names",
     139             : };
     140             : static PyTypeObject *ImportFrom_type;
     141             : _Py_IDENTIFIER(module);
     142             : _Py_IDENTIFIER(level);
     143             : static char *ImportFrom_fields[]={
     144             :         "module",
     145             :         "names",
     146             :         "level",
     147             : };
     148             : static PyTypeObject *Global_type;
     149             : static char *Global_fields[]={
     150             :         "names",
     151             : };
     152             : static PyTypeObject *Nonlocal_type;
     153             : static char *Nonlocal_fields[]={
     154             :         "names",
     155             : };
     156             : static PyTypeObject *Expr_type;
     157             : static char *Expr_fields[]={
     158             :         "value",
     159             : };
     160             : static PyTypeObject *Pass_type;
     161             : static PyTypeObject *Break_type;
     162             : static PyTypeObject *Continue_type;
     163             : static PyTypeObject *expr_type;
     164             : static char *expr_attributes[] = {
     165             :         "lineno",
     166             :         "col_offset",
     167             : };
     168             : static PyObject* ast2obj_expr(void*);
     169             : static PyTypeObject *BoolOp_type;
     170             : _Py_IDENTIFIER(values);
     171             : static char *BoolOp_fields[]={
     172             :         "op",
     173             :         "values",
     174             : };
     175             : static PyTypeObject *BinOp_type;
     176             : _Py_IDENTIFIER(left);
     177             : _Py_IDENTIFIER(right);
     178             : static char *BinOp_fields[]={
     179             :         "left",
     180             :         "op",
     181             :         "right",
     182             : };
     183             : static PyTypeObject *UnaryOp_type;
     184             : _Py_IDENTIFIER(operand);
     185             : static char *UnaryOp_fields[]={
     186             :         "op",
     187             :         "operand",
     188             : };
     189             : static PyTypeObject *Lambda_type;
     190             : static char *Lambda_fields[]={
     191             :         "args",
     192             :         "body",
     193             : };
     194             : static PyTypeObject *IfExp_type;
     195             : static char *IfExp_fields[]={
     196             :         "test",
     197             :         "body",
     198             :         "orelse",
     199             : };
     200             : static PyTypeObject *Dict_type;
     201             : _Py_IDENTIFIER(keys);
     202             : static char *Dict_fields[]={
     203             :         "keys",
     204             :         "values",
     205             : };
     206             : static PyTypeObject *Set_type;
     207             : _Py_IDENTIFIER(elts);
     208             : static char *Set_fields[]={
     209             :         "elts",
     210             : };
     211             : static PyTypeObject *ListComp_type;
     212             : _Py_IDENTIFIER(elt);
     213             : _Py_IDENTIFIER(generators);
     214             : static char *ListComp_fields[]={
     215             :         "elt",
     216             :         "generators",
     217             : };
     218             : static PyTypeObject *SetComp_type;
     219             : static char *SetComp_fields[]={
     220             :         "elt",
     221             :         "generators",
     222             : };
     223             : static PyTypeObject *DictComp_type;
     224             : _Py_IDENTIFIER(key);
     225             : static char *DictComp_fields[]={
     226             :         "key",
     227             :         "value",
     228             :         "generators",
     229             : };
     230             : static PyTypeObject *GeneratorExp_type;
     231             : static char *GeneratorExp_fields[]={
     232             :         "elt",
     233             :         "generators",
     234             : };
     235             : static PyTypeObject *Yield_type;
     236             : static char *Yield_fields[]={
     237             :         "value",
     238             : };
     239             : static PyTypeObject *YieldFrom_type;
     240             : static char *YieldFrom_fields[]={
     241             :         "value",
     242             : };
     243             : static PyTypeObject *Compare_type;
     244             : _Py_IDENTIFIER(ops);
     245             : _Py_IDENTIFIER(comparators);
     246             : static char *Compare_fields[]={
     247             :         "left",
     248             :         "ops",
     249             :         "comparators",
     250             : };
     251             : static PyTypeObject *Call_type;
     252             : _Py_IDENTIFIER(func);
     253             : static char *Call_fields[]={
     254             :         "func",
     255             :         "args",
     256             :         "keywords",
     257             :         "starargs",
     258             :         "kwargs",
     259             : };
     260             : static PyTypeObject *Num_type;
     261             : _Py_IDENTIFIER(n);
     262             : static char *Num_fields[]={
     263             :         "n",
     264             : };
     265             : static PyTypeObject *Str_type;
     266             : _Py_IDENTIFIER(s);
     267             : static char *Str_fields[]={
     268             :         "s",
     269             : };
     270             : static PyTypeObject *Bytes_type;
     271             : static char *Bytes_fields[]={
     272             :         "s",
     273             : };
     274             : static PyTypeObject *Ellipsis_type;
     275             : static PyTypeObject *Attribute_type;
     276             : _Py_IDENTIFIER(attr);
     277             : _Py_IDENTIFIER(ctx);
     278             : static char *Attribute_fields[]={
     279             :         "value",
     280             :         "attr",
     281             :         "ctx",
     282             : };
     283             : static PyTypeObject *Subscript_type;
     284             : _Py_IDENTIFIER(slice);
     285             : static char *Subscript_fields[]={
     286             :         "value",
     287             :         "slice",
     288             :         "ctx",
     289             : };
     290             : static PyTypeObject *Starred_type;
     291             : static char *Starred_fields[]={
     292             :         "value",
     293             :         "ctx",
     294             : };
     295             : static PyTypeObject *Name_type;
     296             : _Py_IDENTIFIER(id);
     297             : static char *Name_fields[]={
     298             :         "id",
     299             :         "ctx",
     300             : };
     301             : static PyTypeObject *List_type;
     302             : static char *List_fields[]={
     303             :         "elts",
     304             :         "ctx",
     305             : };
     306             : static PyTypeObject *Tuple_type;
     307             : static char *Tuple_fields[]={
     308             :         "elts",
     309             :         "ctx",
     310             : };
     311             : static PyTypeObject *expr_context_type;
     312             : static PyObject *Load_singleton, *Store_singleton, *Del_singleton,
     313             : *AugLoad_singleton, *AugStore_singleton, *Param_singleton;
     314             : static PyObject* ast2obj_expr_context(expr_context_ty);
     315             : static PyTypeObject *Load_type;
     316             : static PyTypeObject *Store_type;
     317             : static PyTypeObject *Del_type;
     318             : static PyTypeObject *AugLoad_type;
     319             : static PyTypeObject *AugStore_type;
     320             : static PyTypeObject *Param_type;
     321             : static PyTypeObject *slice_type;
     322             : static PyObject* ast2obj_slice(void*);
     323             : static PyTypeObject *Slice_type;
     324             : _Py_IDENTIFIER(lower);
     325             : _Py_IDENTIFIER(upper);
     326             : _Py_IDENTIFIER(step);
     327             : static char *Slice_fields[]={
     328             :         "lower",
     329             :         "upper",
     330             :         "step",
     331             : };
     332             : static PyTypeObject *ExtSlice_type;
     333             : _Py_IDENTIFIER(dims);
     334             : static char *ExtSlice_fields[]={
     335             :         "dims",
     336             : };
     337             : static PyTypeObject *Index_type;
     338             : static char *Index_fields[]={
     339             :         "value",
     340             : };
     341             : static PyTypeObject *boolop_type;
     342             : static PyObject *And_singleton, *Or_singleton;
     343             : static PyObject* ast2obj_boolop(boolop_ty);
     344             : static PyTypeObject *And_type;
     345             : static PyTypeObject *Or_type;
     346             : static PyTypeObject *operator_type;
     347             : static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton,
     348             : *Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton,
     349             : *RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton,
     350             : *FloorDiv_singleton;
     351             : static PyObject* ast2obj_operator(operator_ty);
     352             : static PyTypeObject *Add_type;
     353             : static PyTypeObject *Sub_type;
     354             : static PyTypeObject *Mult_type;
     355             : static PyTypeObject *Div_type;
     356             : static PyTypeObject *Mod_type;
     357             : static PyTypeObject *Pow_type;
     358             : static PyTypeObject *LShift_type;
     359             : static PyTypeObject *RShift_type;
     360             : static PyTypeObject *BitOr_type;
     361             : static PyTypeObject *BitXor_type;
     362             : static PyTypeObject *BitAnd_type;
     363             : static PyTypeObject *FloorDiv_type;
     364             : static PyTypeObject *unaryop_type;
     365             : static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton,
     366             : *USub_singleton;
     367             : static PyObject* ast2obj_unaryop(unaryop_ty);
     368             : static PyTypeObject *Invert_type;
     369             : static PyTypeObject *Not_type;
     370             : static PyTypeObject *UAdd_type;
     371             : static PyTypeObject *USub_type;
     372             : static PyTypeObject *cmpop_type;
     373             : static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton,
     374             : *Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton,
     375             : *NotIn_singleton;
     376             : static PyObject* ast2obj_cmpop(cmpop_ty);
     377             : static PyTypeObject *Eq_type;
     378             : static PyTypeObject *NotEq_type;
     379             : static PyTypeObject *Lt_type;
     380             : static PyTypeObject *LtE_type;
     381             : static PyTypeObject *Gt_type;
     382             : static PyTypeObject *GtE_type;
     383             : static PyTypeObject *Is_type;
     384             : static PyTypeObject *IsNot_type;
     385             : static PyTypeObject *In_type;
     386             : static PyTypeObject *NotIn_type;
     387             : static PyTypeObject *comprehension_type;
     388             : static PyObject* ast2obj_comprehension(void*);
     389             : _Py_IDENTIFIER(ifs);
     390             : static char *comprehension_fields[]={
     391             :         "target",
     392             :         "iter",
     393             :         "ifs",
     394             : };
     395             : static PyTypeObject *excepthandler_type;
     396             : static char *excepthandler_attributes[] = {
     397             :         "lineno",
     398             :         "col_offset",
     399             : };
     400             : static PyObject* ast2obj_excepthandler(void*);
     401             : static PyTypeObject *ExceptHandler_type;
     402             : _Py_IDENTIFIER(type);
     403             : static char *ExceptHandler_fields[]={
     404             :         "type",
     405             :         "name",
     406             :         "body",
     407             : };
     408             : static PyTypeObject *arguments_type;
     409             : static PyObject* ast2obj_arguments(void*);
     410             : _Py_IDENTIFIER(vararg);
     411             : _Py_IDENTIFIER(varargannotation);
     412             : _Py_IDENTIFIER(kwonlyargs);
     413             : _Py_IDENTIFIER(kwarg);
     414             : _Py_IDENTIFIER(kwargannotation);
     415             : _Py_IDENTIFIER(defaults);
     416             : _Py_IDENTIFIER(kw_defaults);
     417             : static char *arguments_fields[]={
     418             :         "args",
     419             :         "vararg",
     420             :         "varargannotation",
     421             :         "kwonlyargs",
     422             :         "kwarg",
     423             :         "kwargannotation",
     424             :         "defaults",
     425             :         "kw_defaults",
     426             : };
     427             : static PyTypeObject *arg_type;
     428             : static PyObject* ast2obj_arg(void*);
     429             : _Py_IDENTIFIER(arg);
     430             : _Py_IDENTIFIER(annotation);
     431             : static char *arg_fields[]={
     432             :         "arg",
     433             :         "annotation",
     434             : };
     435             : static PyTypeObject *keyword_type;
     436             : static PyObject* ast2obj_keyword(void*);
     437             : static char *keyword_fields[]={
     438             :         "arg",
     439             :         "value",
     440             : };
     441             : static PyTypeObject *alias_type;
     442             : static PyObject* ast2obj_alias(void*);
     443             : _Py_IDENTIFIER(asname);
     444             : static char *alias_fields[]={
     445             :         "name",
     446             :         "asname",
     447             : };
     448             : static PyTypeObject *withitem_type;
     449             : static PyObject* ast2obj_withitem(void*);
     450             : _Py_IDENTIFIER(context_expr);
     451             : _Py_IDENTIFIER(optional_vars);
     452             : static char *withitem_fields[]={
     453             :         "context_expr",
     454             :         "optional_vars",
     455             : };
     456             : 
     457             : 
     458             : typedef struct {
     459             :     PyObject_HEAD
     460             :     PyObject *dict;
     461             : } AST_object;
     462             : 
     463             : static void
     464           0 : ast_dealloc(AST_object *self)
     465             : {
     466           0 :     Py_CLEAR(self->dict);
     467           0 :     Py_TYPE(self)->tp_free(self);
     468           0 : }
     469             : 
     470             : static int
     471          68 : ast_traverse(AST_object *self, visitproc visit, void *arg)
     472             : {
     473          68 :     Py_VISIT(self->dict);
     474          68 :     return 0;
     475             : }
     476             : 
     477             : static void
     478           0 : ast_clear(AST_object *self)
     479             : {
     480           0 :     Py_CLEAR(self->dict);
     481           0 : }
     482             : 
     483             : static int
     484           0 : ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
     485             : {
     486             :     _Py_IDENTIFIER(_fields);
     487           0 :     Py_ssize_t i, numfields = 0;
     488           0 :     int res = -1;
     489             :     PyObject *key, *value, *fields;
     490           0 :     fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields);
     491           0 :     if (!fields)
     492           0 :         PyErr_Clear();
     493           0 :     if (fields) {
     494           0 :         numfields = PySequence_Size(fields);
     495           0 :         if (numfields == -1)
     496           0 :             goto cleanup;
     497             :     }
     498           0 :     res = 0; /* if no error occurs, this stays 0 to the end */
     499           0 :     if (PyTuple_GET_SIZE(args) > 0) {
     500           0 :         if (numfields != PyTuple_GET_SIZE(args)) {
     501           0 :             PyErr_Format(PyExc_TypeError, "%.400s constructor takes %s"
     502             :                          "%zd positional argument%s",
     503           0 :                          Py_TYPE(self)->tp_name,
     504             :                          numfields == 0 ? "" : "either 0 or ",
     505             :                          numfields, numfields == 1 ? "" : "s");
     506           0 :             res = -1;
     507           0 :             goto cleanup;
     508             :         }
     509           0 :         for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
     510             :             /* cannot be reached when fields is NULL */
     511           0 :             PyObject *name = PySequence_GetItem(fields, i);
     512           0 :             if (!name) {
     513           0 :                 res = -1;
     514           0 :                 goto cleanup;
     515             :             }
     516           0 :             res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
     517           0 :             Py_DECREF(name);
     518           0 :             if (res < 0)
     519           0 :                 goto cleanup;
     520             :         }
     521             :     }
     522           0 :     if (kw) {
     523           0 :         i = 0;  /* needed by PyDict_Next */
     524           0 :         while (PyDict_Next(kw, &i, &key, &value)) {
     525           0 :             res = PyObject_SetAttr(self, key, value);
     526           0 :             if (res < 0)
     527           0 :                 goto cleanup;
     528             :         }
     529             :     }
     530             :   cleanup:
     531           0 :     Py_XDECREF(fields);
     532           0 :     return res;
     533             : }
     534             : 
     535             : /* Pickling support */
     536             : static PyObject *
     537           0 : ast_type_reduce(PyObject *self, PyObject *unused)
     538             : {
     539             :     PyObject *res;
     540             :     _Py_IDENTIFIER(__dict__);
     541           0 :     PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
     542           0 :     if (dict == NULL) {
     543           0 :         if (PyErr_ExceptionMatches(PyExc_AttributeError))
     544           0 :             PyErr_Clear();
     545             :         else
     546           0 :             return NULL;
     547             :     }
     548           0 :     if (dict) {
     549           0 :         res = Py_BuildValue("O()O", Py_TYPE(self), dict);
     550           0 :         Py_DECREF(dict);
     551           0 :         return res;
     552             :     }
     553           0 :     return Py_BuildValue("O()", Py_TYPE(self));
     554             : }
     555             : 
     556             : static PyMethodDef ast_type_methods[] = {
     557             :     {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
     558             :     {NULL}
     559             : };
     560             : 
     561             : static PyGetSetDef ast_type_getsets[] = {
     562             :     {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
     563             :     {NULL}
     564             : };
     565             : 
     566             : static PyTypeObject AST_type = {
     567             :     PyVarObject_HEAD_INIT(&PyType_Type, 0)
     568             :     "_ast.AST",
     569             :     sizeof(AST_object),
     570             :     0,
     571             :     (destructor)ast_dealloc, /* tp_dealloc */
     572             :     0,                       /* tp_print */
     573             :     0,                       /* tp_getattr */
     574             :     0,                       /* tp_setattr */
     575             :     0,                       /* tp_reserved */
     576             :     0,                       /* tp_repr */
     577             :     0,                       /* tp_as_number */
     578             :     0,                       /* tp_as_sequence */
     579             :     0,                       /* tp_as_mapping */
     580             :     0,                       /* tp_hash */
     581             :     0,                       /* tp_call */
     582             :     0,                       /* tp_str */
     583             :     PyObject_GenericGetAttr, /* tp_getattro */
     584             :     PyObject_GenericSetAttr, /* tp_setattro */
     585             :     0,                       /* tp_as_buffer */
     586             :     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */
     587             :     0,                       /* tp_doc */
     588             :     (traverseproc)ast_traverse, /* tp_traverse */
     589             :     (inquiry)ast_clear,      /* tp_clear */
     590             :     0,                       /* tp_richcompare */
     591             :     0,                       /* tp_weaklistoffset */
     592             :     0,                       /* tp_iter */
     593             :     0,                       /* tp_iternext */
     594             :     ast_type_methods,        /* tp_methods */
     595             :     0,                       /* tp_members */
     596             :     ast_type_getsets,        /* tp_getset */
     597             :     0,                       /* tp_base */
     598             :     0,                       /* tp_dict */
     599             :     0,                       /* tp_descr_get */
     600             :     0,                       /* tp_descr_set */
     601             :     offsetof(AST_object, dict),/* tp_dictoffset */
     602             :     (initproc)ast_type_init, /* tp_init */
     603             :     PyType_GenericAlloc,     /* tp_alloc */
     604             :     PyType_GenericNew,       /* tp_new */
     605             :     PyObject_GC_Del,         /* tp_free */
     606             : };
     607             : 
     608             : 
     609         104 : static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields)
     610             : {
     611             :     PyObject *fnames, *result;
     612             :     int i;
     613         104 :     fnames = PyTuple_New(num_fields);
     614         104 :     if (!fnames) return NULL;
     615         232 :     for (i = 0; i < num_fields; i++) {
     616         128 :         PyObject *field = PyUnicode_FromString(fields[i]);
     617         128 :         if (!field) {
     618           0 :             Py_DECREF(fnames);
     619           0 :             return NULL;
     620             :         }
     621         128 :         PyTuple_SET_ITEM(fnames, i, field);
     622             :     }
     623         104 :     result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",
     624             :                     type, base, "_fields", fnames, "__module__", "_ast");
     625         104 :     Py_DECREF(fnames);
     626         104 :     return (PyTypeObject*)result;
     627             : }
     628             : 
     629          10 : static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
     630             : {
     631             :     int i, result;
     632             :     _Py_IDENTIFIER(_attributes);
     633          10 :     PyObject *s, *l = PyTuple_New(num_fields);
     634          10 :     if (!l)
     635           0 :         return 0;
     636          16 :     for (i = 0; i < num_fields; i++) {
     637           6 :         s = PyUnicode_FromString(attrs[i]);
     638           6 :         if (!s) {
     639           0 :             Py_DECREF(l);
     640           0 :             return 0;
     641             :         }
     642           6 :         PyTuple_SET_ITEM(l, i, s);
     643             :     }
     644          10 :     result = _PyObject_SetAttrId((PyObject*)type, &PyId__attributes, l) >= 0;
     645          10 :     Py_DECREF(l);
     646          10 :     return result;
     647             : }
     648             : 
     649             : /* Conversion AST -> Python */
     650             : 
     651           0 : static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
     652             : {
     653           0 :     Py_ssize_t i, n = asdl_seq_LEN(seq);
     654           0 :     PyObject *result = PyList_New(n);
     655             :     PyObject *value;
     656           0 :     if (!result)
     657           0 :         return NULL;
     658           0 :     for (i = 0; i < n; i++) {
     659           0 :         value = func(asdl_seq_GET(seq, i));
     660           0 :         if (!value) {
     661           0 :             Py_DECREF(result);
     662           0 :             return NULL;
     663             :         }
     664           0 :         PyList_SET_ITEM(result, i, value);
     665             :     }
     666           0 :     return result;
     667             : }
     668             : 
     669           0 : static PyObject* ast2obj_object(void *o)
     670             : {
     671           0 :     if (!o)
     672           0 :         o = Py_None;
     673           0 :     Py_INCREF((PyObject*)o);
     674           0 :     return (PyObject*)o;
     675             : }
     676             : #define ast2obj_identifier ast2obj_object
     677             : #define ast2obj_string ast2obj_object
     678             : #define ast2obj_bytes ast2obj_object
     679             : 
     680           0 : static PyObject* ast2obj_int(long b)
     681             : {
     682           0 :     return PyLong_FromLong(b);
     683             : }
     684             : 
     685             : /* Conversion Python -> AST */
     686             : 
     687           0 : static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
     688             : {
     689           0 :     if (obj == Py_None)
     690           0 :         obj = NULL;
     691           0 :     if (obj)
     692           0 :         PyArena_AddPyObject(arena, obj);
     693           0 :     Py_XINCREF(obj);
     694           0 :     *out = obj;
     695           0 :     return 0;
     696             : }
     697             : 
     698           0 : static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
     699             : {
     700           0 :     if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
     701           0 :         PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
     702           0 :         return 1;
     703             :     }
     704           0 :     return obj2ast_object(obj, out, arena);
     705             : }
     706             : 
     707           0 : static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
     708             : {
     709           0 :     if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
     710           0 :         PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
     711           0 :         return 1;
     712             :     }
     713           0 :     return obj2ast_object(obj, out, arena);
     714             : }
     715             : 
     716           0 : static int obj2ast_bytes(PyObject* obj, PyObject** out, PyArena* arena)
     717             : {
     718           0 :     if (!PyBytes_CheckExact(obj)) {
     719           0 :         PyErr_SetString(PyExc_TypeError, "AST bytes must be of type bytes");
     720           0 :         return 1;
     721             :     }
     722           0 :     return obj2ast_object(obj, out, arena);
     723             : }
     724             : 
     725           0 : static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
     726             : {
     727             :     int i;
     728           0 :     if (!PyLong_Check(obj)) {
     729           0 :         PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
     730           0 :         return 1;
     731             :     }
     732             : 
     733           0 :     i = (int)PyLong_AsLong(obj);
     734           0 :     if (i == -1 && PyErr_Occurred())
     735           0 :         return 1;
     736           0 :     *out = i;
     737           0 :     return 0;
     738             : }
     739             : 
     740           1 : static int add_ast_fields(void)
     741             : {
     742             :     PyObject *empty_tuple, *d;
     743           1 :     if (PyType_Ready(&AST_type) < 0)
     744           0 :         return -1;
     745           1 :     d = AST_type.tp_dict;
     746           1 :     empty_tuple = PyTuple_New(0);
     747           2 :     if (!empty_tuple ||
     748           2 :         PyDict_SetItemString(d, "_fields", empty_tuple) < 0 ||
     749           1 :         PyDict_SetItemString(d, "_attributes", empty_tuple) < 0) {
     750           0 :         Py_XDECREF(empty_tuple);
     751           0 :         return -1;
     752             :     }
     753           1 :     Py_DECREF(empty_tuple);
     754           1 :     return 0;
     755             : }
     756             : 
     757             : 
     758           1 : static int init_types(void)
     759             : {
     760             :         static int initialized;
     761           1 :         if (initialized) return 1;
     762           1 :         if (add_ast_fields() < 0) return 0;
     763           1 :         mod_type = make_type("mod", &AST_type, NULL, 0);
     764           1 :         if (!mod_type) return 0;
     765           1 :         if (!add_attributes(mod_type, NULL, 0)) return 0;
     766           1 :         Module_type = make_type("Module", mod_type, Module_fields, 1);
     767           1 :         if (!Module_type) return 0;
     768           1 :         Interactive_type = make_type("Interactive", mod_type,
     769             :                                      Interactive_fields, 1);
     770           1 :         if (!Interactive_type) return 0;
     771           1 :         Expression_type = make_type("Expression", mod_type, Expression_fields,
     772             :                                     1);
     773           1 :         if (!Expression_type) return 0;
     774           1 :         Suite_type = make_type("Suite", mod_type, Suite_fields, 1);
     775           1 :         if (!Suite_type) return 0;
     776           1 :         stmt_type = make_type("stmt", &AST_type, NULL, 0);
     777           1 :         if (!stmt_type) return 0;
     778           1 :         if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0;
     779           1 :         FunctionDef_type = make_type("FunctionDef", stmt_type,
     780             :                                      FunctionDef_fields, 5);
     781           1 :         if (!FunctionDef_type) return 0;
     782           1 :         ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7);
     783           1 :         if (!ClassDef_type) return 0;
     784           1 :         Return_type = make_type("Return", stmt_type, Return_fields, 1);
     785           1 :         if (!Return_type) return 0;
     786           1 :         Delete_type = make_type("Delete", stmt_type, Delete_fields, 1);
     787           1 :         if (!Delete_type) return 0;
     788           1 :         Assign_type = make_type("Assign", stmt_type, Assign_fields, 2);
     789           1 :         if (!Assign_type) return 0;
     790           1 :         AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3);
     791           1 :         if (!AugAssign_type) return 0;
     792           1 :         For_type = make_type("For", stmt_type, For_fields, 4);
     793           1 :         if (!For_type) return 0;
     794           1 :         While_type = make_type("While", stmt_type, While_fields, 3);
     795           1 :         if (!While_type) return 0;
     796           1 :         If_type = make_type("If", stmt_type, If_fields, 3);
     797           1 :         if (!If_type) return 0;
     798           1 :         With_type = make_type("With", stmt_type, With_fields, 2);
     799           1 :         if (!With_type) return 0;
     800           1 :         Raise_type = make_type("Raise", stmt_type, Raise_fields, 2);
     801           1 :         if (!Raise_type) return 0;
     802           1 :         Try_type = make_type("Try", stmt_type, Try_fields, 4);
     803           1 :         if (!Try_type) return 0;
     804           1 :         Assert_type = make_type("Assert", stmt_type, Assert_fields, 2);
     805           1 :         if (!Assert_type) return 0;
     806           1 :         Import_type = make_type("Import", stmt_type, Import_fields, 1);
     807           1 :         if (!Import_type) return 0;
     808           1 :         ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields,
     809             :                                     3);
     810           1 :         if (!ImportFrom_type) return 0;
     811           1 :         Global_type = make_type("Global", stmt_type, Global_fields, 1);
     812           1 :         if (!Global_type) return 0;
     813           1 :         Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1);
     814           1 :         if (!Nonlocal_type) return 0;
     815           1 :         Expr_type = make_type("Expr", stmt_type, Expr_fields, 1);
     816           1 :         if (!Expr_type) return 0;
     817           1 :         Pass_type = make_type("Pass", stmt_type, NULL, 0);
     818           1 :         if (!Pass_type) return 0;
     819           1 :         Break_type = make_type("Break", stmt_type, NULL, 0);
     820           1 :         if (!Break_type) return 0;
     821           1 :         Continue_type = make_type("Continue", stmt_type, NULL, 0);
     822           1 :         if (!Continue_type) return 0;
     823           1 :         expr_type = make_type("expr", &AST_type, NULL, 0);
     824           1 :         if (!expr_type) return 0;
     825           1 :         if (!add_attributes(expr_type, expr_attributes, 2)) return 0;
     826           1 :         BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2);
     827           1 :         if (!BoolOp_type) return 0;
     828           1 :         BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3);
     829           1 :         if (!BinOp_type) return 0;
     830           1 :         UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2);
     831           1 :         if (!UnaryOp_type) return 0;
     832           1 :         Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2);
     833           1 :         if (!Lambda_type) return 0;
     834           1 :         IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3);
     835           1 :         if (!IfExp_type) return 0;
     836           1 :         Dict_type = make_type("Dict", expr_type, Dict_fields, 2);
     837           1 :         if (!Dict_type) return 0;
     838           1 :         Set_type = make_type("Set", expr_type, Set_fields, 1);
     839           1 :         if (!Set_type) return 0;
     840           1 :         ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2);
     841           1 :         if (!ListComp_type) return 0;
     842           1 :         SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2);
     843           1 :         if (!SetComp_type) return 0;
     844           1 :         DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3);
     845           1 :         if (!DictComp_type) return 0;
     846           1 :         GeneratorExp_type = make_type("GeneratorExp", expr_type,
     847             :                                       GeneratorExp_fields, 2);
     848           1 :         if (!GeneratorExp_type) return 0;
     849           1 :         Yield_type = make_type("Yield", expr_type, Yield_fields, 1);
     850           1 :         if (!Yield_type) return 0;
     851           1 :         YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1);
     852           1 :         if (!YieldFrom_type) return 0;
     853           1 :         Compare_type = make_type("Compare", expr_type, Compare_fields, 3);
     854           1 :         if (!Compare_type) return 0;
     855           1 :         Call_type = make_type("Call", expr_type, Call_fields, 5);
     856           1 :         if (!Call_type) return 0;
     857           1 :         Num_type = make_type("Num", expr_type, Num_fields, 1);
     858           1 :         if (!Num_type) return 0;
     859           1 :         Str_type = make_type("Str", expr_type, Str_fields, 1);
     860           1 :         if (!Str_type) return 0;
     861           1 :         Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1);
     862           1 :         if (!Bytes_type) return 0;
     863           1 :         Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0);
     864           1 :         if (!Ellipsis_type) return 0;
     865           1 :         Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3);
     866           1 :         if (!Attribute_type) return 0;
     867           1 :         Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3);
     868           1 :         if (!Subscript_type) return 0;
     869           1 :         Starred_type = make_type("Starred", expr_type, Starred_fields, 2);
     870           1 :         if (!Starred_type) return 0;
     871           1 :         Name_type = make_type("Name", expr_type, Name_fields, 2);
     872           1 :         if (!Name_type) return 0;
     873           1 :         List_type = make_type("List", expr_type, List_fields, 2);
     874           1 :         if (!List_type) return 0;
     875           1 :         Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2);
     876           1 :         if (!Tuple_type) return 0;
     877           1 :         expr_context_type = make_type("expr_context", &AST_type, NULL, 0);
     878           1 :         if (!expr_context_type) return 0;
     879           1 :         if (!add_attributes(expr_context_type, NULL, 0)) return 0;
     880           1 :         Load_type = make_type("Load", expr_context_type, NULL, 0);
     881           1 :         if (!Load_type) return 0;
     882           1 :         Load_singleton = PyType_GenericNew(Load_type, NULL, NULL);
     883           1 :         if (!Load_singleton) return 0;
     884           1 :         Store_type = make_type("Store", expr_context_type, NULL, 0);
     885           1 :         if (!Store_type) return 0;
     886           1 :         Store_singleton = PyType_GenericNew(Store_type, NULL, NULL);
     887           1 :         if (!Store_singleton) return 0;
     888           1 :         Del_type = make_type("Del", expr_context_type, NULL, 0);
     889           1 :         if (!Del_type) return 0;
     890           1 :         Del_singleton = PyType_GenericNew(Del_type, NULL, NULL);
     891           1 :         if (!Del_singleton) return 0;
     892           1 :         AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0);
     893           1 :         if (!AugLoad_type) return 0;
     894           1 :         AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL);
     895           1 :         if (!AugLoad_singleton) return 0;
     896           1 :         AugStore_type = make_type("AugStore", expr_context_type, NULL, 0);
     897           1 :         if (!AugStore_type) return 0;
     898           1 :         AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL);
     899           1 :         if (!AugStore_singleton) return 0;
     900           1 :         Param_type = make_type("Param", expr_context_type, NULL, 0);
     901           1 :         if (!Param_type) return 0;
     902           1 :         Param_singleton = PyType_GenericNew(Param_type, NULL, NULL);
     903           1 :         if (!Param_singleton) return 0;
     904           1 :         slice_type = make_type("slice", &AST_type, NULL, 0);
     905           1 :         if (!slice_type) return 0;
     906           1 :         if (!add_attributes(slice_type, NULL, 0)) return 0;
     907           1 :         Slice_type = make_type("Slice", slice_type, Slice_fields, 3);
     908           1 :         if (!Slice_type) return 0;
     909           1 :         ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1);
     910           1 :         if (!ExtSlice_type) return 0;
     911           1 :         Index_type = make_type("Index", slice_type, Index_fields, 1);
     912           1 :         if (!Index_type) return 0;
     913           1 :         boolop_type = make_type("boolop", &AST_type, NULL, 0);
     914           1 :         if (!boolop_type) return 0;
     915           1 :         if (!add_attributes(boolop_type, NULL, 0)) return 0;
     916           1 :         And_type = make_type("And", boolop_type, NULL, 0);
     917           1 :         if (!And_type) return 0;
     918           1 :         And_singleton = PyType_GenericNew(And_type, NULL, NULL);
     919           1 :         if (!And_singleton) return 0;
     920           1 :         Or_type = make_type("Or", boolop_type, NULL, 0);
     921           1 :         if (!Or_type) return 0;
     922           1 :         Or_singleton = PyType_GenericNew(Or_type, NULL, NULL);
     923           1 :         if (!Or_singleton) return 0;
     924           1 :         operator_type = make_type("operator", &AST_type, NULL, 0);
     925           1 :         if (!operator_type) return 0;
     926           1 :         if (!add_attributes(operator_type, NULL, 0)) return 0;
     927           1 :         Add_type = make_type("Add", operator_type, NULL, 0);
     928           1 :         if (!Add_type) return 0;
     929           1 :         Add_singleton = PyType_GenericNew(Add_type, NULL, NULL);
     930           1 :         if (!Add_singleton) return 0;
     931           1 :         Sub_type = make_type("Sub", operator_type, NULL, 0);
     932           1 :         if (!Sub_type) return 0;
     933           1 :         Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL);
     934           1 :         if (!Sub_singleton) return 0;
     935           1 :         Mult_type = make_type("Mult", operator_type, NULL, 0);
     936           1 :         if (!Mult_type) return 0;
     937           1 :         Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL);
     938           1 :         if (!Mult_singleton) return 0;
     939           1 :         Div_type = make_type("Div", operator_type, NULL, 0);
     940           1 :         if (!Div_type) return 0;
     941           1 :         Div_singleton = PyType_GenericNew(Div_type, NULL, NULL);
     942           1 :         if (!Div_singleton) return 0;
     943           1 :         Mod_type = make_type("Mod", operator_type, NULL, 0);
     944           1 :         if (!Mod_type) return 0;
     945           1 :         Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL);
     946           1 :         if (!Mod_singleton) return 0;
     947           1 :         Pow_type = make_type("Pow", operator_type, NULL, 0);
     948           1 :         if (!Pow_type) return 0;
     949           1 :         Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL);
     950           1 :         if (!Pow_singleton) return 0;
     951           1 :         LShift_type = make_type("LShift", operator_type, NULL, 0);
     952           1 :         if (!LShift_type) return 0;
     953           1 :         LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL);
     954           1 :         if (!LShift_singleton) return 0;
     955           1 :         RShift_type = make_type("RShift", operator_type, NULL, 0);
     956           1 :         if (!RShift_type) return 0;
     957           1 :         RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL);
     958           1 :         if (!RShift_singleton) return 0;
     959           1 :         BitOr_type = make_type("BitOr", operator_type, NULL, 0);
     960           1 :         if (!BitOr_type) return 0;
     961           1 :         BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL);
     962           1 :         if (!BitOr_singleton) return 0;
     963           1 :         BitXor_type = make_type("BitXor", operator_type, NULL, 0);
     964           1 :         if (!BitXor_type) return 0;
     965           1 :         BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL);
     966           1 :         if (!BitXor_singleton) return 0;
     967           1 :         BitAnd_type = make_type("BitAnd", operator_type, NULL, 0);
     968           1 :         if (!BitAnd_type) return 0;
     969           1 :         BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL);
     970           1 :         if (!BitAnd_singleton) return 0;
     971           1 :         FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0);
     972           1 :         if (!FloorDiv_type) return 0;
     973           1 :         FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL);
     974           1 :         if (!FloorDiv_singleton) return 0;
     975           1 :         unaryop_type = make_type("unaryop", &AST_type, NULL, 0);
     976           1 :         if (!unaryop_type) return 0;
     977           1 :         if (!add_attributes(unaryop_type, NULL, 0)) return 0;
     978           1 :         Invert_type = make_type("Invert", unaryop_type, NULL, 0);
     979           1 :         if (!Invert_type) return 0;
     980           1 :         Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL);
     981           1 :         if (!Invert_singleton) return 0;
     982           1 :         Not_type = make_type("Not", unaryop_type, NULL, 0);
     983           1 :         if (!Not_type) return 0;
     984           1 :         Not_singleton = PyType_GenericNew(Not_type, NULL, NULL);
     985           1 :         if (!Not_singleton) return 0;
     986           1 :         UAdd_type = make_type("UAdd", unaryop_type, NULL, 0);
     987           1 :         if (!UAdd_type) return 0;
     988           1 :         UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL);
     989           1 :         if (!UAdd_singleton) return 0;
     990           1 :         USub_type = make_type("USub", unaryop_type, NULL, 0);
     991           1 :         if (!USub_type) return 0;
     992           1 :         USub_singleton = PyType_GenericNew(USub_type, NULL, NULL);
     993           1 :         if (!USub_singleton) return 0;
     994           1 :         cmpop_type = make_type("cmpop", &AST_type, NULL, 0);
     995           1 :         if (!cmpop_type) return 0;
     996           1 :         if (!add_attributes(cmpop_type, NULL, 0)) return 0;
     997           1 :         Eq_type = make_type("Eq", cmpop_type, NULL, 0);
     998           1 :         if (!Eq_type) return 0;
     999           1 :         Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL);
    1000           1 :         if (!Eq_singleton) return 0;
    1001           1 :         NotEq_type = make_type("NotEq", cmpop_type, NULL, 0);
    1002           1 :         if (!NotEq_type) return 0;
    1003           1 :         NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL);
    1004           1 :         if (!NotEq_singleton) return 0;
    1005           1 :         Lt_type = make_type("Lt", cmpop_type, NULL, 0);
    1006           1 :         if (!Lt_type) return 0;
    1007           1 :         Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL);
    1008           1 :         if (!Lt_singleton) return 0;
    1009           1 :         LtE_type = make_type("LtE", cmpop_type, NULL, 0);
    1010           1 :         if (!LtE_type) return 0;
    1011           1 :         LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL);
    1012           1 :         if (!LtE_singleton) return 0;
    1013           1 :         Gt_type = make_type("Gt", cmpop_type, NULL, 0);
    1014           1 :         if (!Gt_type) return 0;
    1015           1 :         Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL);
    1016           1 :         if (!Gt_singleton) return 0;
    1017           1 :         GtE_type = make_type("GtE", cmpop_type, NULL, 0);
    1018           1 :         if (!GtE_type) return 0;
    1019           1 :         GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL);
    1020           1 :         if (!GtE_singleton) return 0;
    1021           1 :         Is_type = make_type("Is", cmpop_type, NULL, 0);
    1022           1 :         if (!Is_type) return 0;
    1023           1 :         Is_singleton = PyType_GenericNew(Is_type, NULL, NULL);
    1024           1 :         if (!Is_singleton) return 0;
    1025           1 :         IsNot_type = make_type("IsNot", cmpop_type, NULL, 0);
    1026           1 :         if (!IsNot_type) return 0;
    1027           1 :         IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL);
    1028           1 :         if (!IsNot_singleton) return 0;
    1029           1 :         In_type = make_type("In", cmpop_type, NULL, 0);
    1030           1 :         if (!In_type) return 0;
    1031           1 :         In_singleton = PyType_GenericNew(In_type, NULL, NULL);
    1032           1 :         if (!In_singleton) return 0;
    1033           1 :         NotIn_type = make_type("NotIn", cmpop_type, NULL, 0);
    1034           1 :         if (!NotIn_type) return 0;
    1035           1 :         NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL);
    1036           1 :         if (!NotIn_singleton) return 0;
    1037           1 :         comprehension_type = make_type("comprehension", &AST_type,
    1038             :                                        comprehension_fields, 3);
    1039           1 :         if (!comprehension_type) return 0;
    1040           1 :         excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0);
    1041           1 :         if (!excepthandler_type) return 0;
    1042           1 :         if (!add_attributes(excepthandler_type, excepthandler_attributes, 2))
    1043           0 :             return 0;
    1044           1 :         ExceptHandler_type = make_type("ExceptHandler", excepthandler_type,
    1045             :                                        ExceptHandler_fields, 3);
    1046           1 :         if (!ExceptHandler_type) return 0;
    1047           1 :         arguments_type = make_type("arguments", &AST_type, arguments_fields, 8);
    1048           1 :         if (!arguments_type) return 0;
    1049           1 :         arg_type = make_type("arg", &AST_type, arg_fields, 2);
    1050           1 :         if (!arg_type) return 0;
    1051           1 :         keyword_type = make_type("keyword", &AST_type, keyword_fields, 2);
    1052           1 :         if (!keyword_type) return 0;
    1053           1 :         alias_type = make_type("alias", &AST_type, alias_fields, 2);
    1054           1 :         if (!alias_type) return 0;
    1055           1 :         withitem_type = make_type("withitem", &AST_type, withitem_fields, 2);
    1056           1 :         if (!withitem_type) return 0;
    1057           1 :         initialized = 1;
    1058           1 :         return 1;
    1059             : }
    1060             : 
    1061             : static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena);
    1062             : static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena);
    1063             : static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena);
    1064             : static int obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena*
    1065             :                                 arena);
    1066             : static int obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena);
    1067             : static int obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena);
    1068             : static int obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena);
    1069             : static int obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena);
    1070             : static int obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena);
    1071             : static int obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena*
    1072             :                                  arena);
    1073             : static int obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena*
    1074             :                                  arena);
    1075             : static int obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena);
    1076             : static int obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena);
    1077             : static int obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena);
    1078             : static int obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena);
    1079             : static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena);
    1080             : 
    1081             : mod_ty
    1082           3 : Module(asdl_seq * body, PyArena *arena)
    1083             : {
    1084             :         mod_ty p;
    1085           3 :         p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
    1086           3 :         if (!p)
    1087           0 :                 return NULL;
    1088           3 :         p->kind = Module_kind;
    1089           3 :         p->v.Module.body = body;
    1090           3 :         return p;
    1091             : }
    1092             : 
    1093             : mod_ty
    1094           0 : Interactive(asdl_seq * body, PyArena *arena)
    1095             : {
    1096             :         mod_ty p;
    1097           0 :         p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
    1098           0 :         if (!p)
    1099           0 :                 return NULL;
    1100           0 :         p->kind = Interactive_kind;
    1101           0 :         p->v.Interactive.body = body;
    1102           0 :         return p;
    1103             : }
    1104             : 
    1105             : mod_ty
    1106           0 : Expression(expr_ty body, PyArena *arena)
    1107             : {
    1108             :         mod_ty p;
    1109           0 :         if (!body) {
    1110           0 :                 PyErr_SetString(PyExc_ValueError,
    1111             :                                 "field body is required for Expression");
    1112           0 :                 return NULL;
    1113             :         }
    1114           0 :         p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
    1115           0 :         if (!p)
    1116           0 :                 return NULL;
    1117           0 :         p->kind = Expression_kind;
    1118           0 :         p->v.Expression.body = body;
    1119           0 :         return p;
    1120             : }
    1121             : 
    1122             : mod_ty
    1123           0 : Suite(asdl_seq * body, PyArena *arena)
    1124             : {
    1125             :         mod_ty p;
    1126           0 :         p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
    1127           0 :         if (!p)
    1128           0 :                 return NULL;
    1129           0 :         p->kind = Suite_kind;
    1130           0 :         p->v.Suite.body = body;
    1131           0 :         return p;
    1132             : }
    1133             : 
    1134             : stmt_ty
    1135          24 : FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
    1136             :             decorator_list, expr_ty returns, int lineno, int col_offset,
    1137             :             PyArena *arena)
    1138             : {
    1139             :         stmt_ty p;
    1140          24 :         if (!name) {
    1141           0 :                 PyErr_SetString(PyExc_ValueError,
    1142             :                                 "field name is required for FunctionDef");
    1143           0 :                 return NULL;
    1144             :         }
    1145          24 :         if (!args) {
    1146           0 :                 PyErr_SetString(PyExc_ValueError,
    1147             :                                 "field args is required for FunctionDef");
    1148           0 :                 return NULL;
    1149             :         }
    1150          24 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1151          24 :         if (!p)
    1152           0 :                 return NULL;
    1153          24 :         p->kind = FunctionDef_kind;
    1154          24 :         p->v.FunctionDef.name = name;
    1155          24 :         p->v.FunctionDef.args = args;
    1156          24 :         p->v.FunctionDef.body = body;
    1157          24 :         p->v.FunctionDef.decorator_list = decorator_list;
    1158          24 :         p->v.FunctionDef.returns = returns;
    1159          24 :         p->lineno = lineno;
    1160          24 :         p->col_offset = col_offset;
    1161          24 :         return p;
    1162             : }
    1163             : 
    1164             : stmt_ty
    1165           3 : ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty
    1166             :          starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list,
    1167             :          int lineno, int col_offset, PyArena *arena)
    1168             : {
    1169             :         stmt_ty p;
    1170           3 :         if (!name) {
    1171           0 :                 PyErr_SetString(PyExc_ValueError,
    1172             :                                 "field name is required for ClassDef");
    1173           0 :                 return NULL;
    1174             :         }
    1175           3 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1176           3 :         if (!p)
    1177           0 :                 return NULL;
    1178           3 :         p->kind = ClassDef_kind;
    1179           3 :         p->v.ClassDef.name = name;
    1180           3 :         p->v.ClassDef.bases = bases;
    1181           3 :         p->v.ClassDef.keywords = keywords;
    1182           3 :         p->v.ClassDef.starargs = starargs;
    1183           3 :         p->v.ClassDef.kwargs = kwargs;
    1184           3 :         p->v.ClassDef.body = body;
    1185           3 :         p->v.ClassDef.decorator_list = decorator_list;
    1186           3 :         p->lineno = lineno;
    1187           3 :         p->col_offset = col_offset;
    1188           3 :         return p;
    1189             : }
    1190             : 
    1191             : stmt_ty
    1192          26 : Return(expr_ty value, int lineno, int col_offset, PyArena *arena)
    1193             : {
    1194             :         stmt_ty p;
    1195          26 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1196          26 :         if (!p)
    1197           0 :                 return NULL;
    1198          26 :         p->kind = Return_kind;
    1199          26 :         p->v.Return.value = value;
    1200          26 :         p->lineno = lineno;
    1201          26 :         p->col_offset = col_offset;
    1202          26 :         return p;
    1203             : }
    1204             : 
    1205             : stmt_ty
    1206           0 : Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena)
    1207             : {
    1208             :         stmt_ty p;
    1209           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1210           0 :         if (!p)
    1211           0 :                 return NULL;
    1212           0 :         p->kind = Delete_kind;
    1213           0 :         p->v.Delete.targets = targets;
    1214           0 :         p->lineno = lineno;
    1215           0 :         p->col_offset = col_offset;
    1216           0 :         return p;
    1217             : }
    1218             : 
    1219             : stmt_ty
    1220          61 : Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena
    1221             :        *arena)
    1222             : {
    1223             :         stmt_ty p;
    1224          61 :         if (!value) {
    1225           0 :                 PyErr_SetString(PyExc_ValueError,
    1226             :                                 "field value is required for Assign");
    1227           0 :                 return NULL;
    1228             :         }
    1229          61 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1230          61 :         if (!p)
    1231           0 :                 return NULL;
    1232          61 :         p->kind = Assign_kind;
    1233          61 :         p->v.Assign.targets = targets;
    1234          61 :         p->v.Assign.value = value;
    1235          61 :         p->lineno = lineno;
    1236          61 :         p->col_offset = col_offset;
    1237          61 :         return p;
    1238             : }
    1239             : 
    1240             : stmt_ty
    1241           1 : AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
    1242             :           col_offset, PyArena *arena)
    1243             : {
    1244             :         stmt_ty p;
    1245           1 :         if (!target) {
    1246           0 :                 PyErr_SetString(PyExc_ValueError,
    1247             :                                 "field target is required for AugAssign");
    1248           0 :                 return NULL;
    1249             :         }
    1250           1 :         if (!op) {
    1251           0 :                 PyErr_SetString(PyExc_ValueError,
    1252             :                                 "field op is required for AugAssign");
    1253           0 :                 return NULL;
    1254             :         }
    1255           1 :         if (!value) {
    1256           0 :                 PyErr_SetString(PyExc_ValueError,
    1257             :                                 "field value is required for AugAssign");
    1258           0 :                 return NULL;
    1259             :         }
    1260           1 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1261           1 :         if (!p)
    1262           0 :                 return NULL;
    1263           1 :         p->kind = AugAssign_kind;
    1264           1 :         p->v.AugAssign.target = target;
    1265           1 :         p->v.AugAssign.op = op;
    1266           1 :         p->v.AugAssign.value = value;
    1267           1 :         p->lineno = lineno;
    1268           1 :         p->col_offset = col_offset;
    1269           1 :         return p;
    1270             : }
    1271             : 
    1272             : stmt_ty
    1273           2 : For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int
    1274             :     lineno, int col_offset, PyArena *arena)
    1275             : {
    1276             :         stmt_ty p;
    1277           2 :         if (!target) {
    1278           0 :                 PyErr_SetString(PyExc_ValueError,
    1279             :                                 "field target is required for For");
    1280           0 :                 return NULL;
    1281             :         }
    1282           2 :         if (!iter) {
    1283           0 :                 PyErr_SetString(PyExc_ValueError,
    1284             :                                 "field iter is required for For");
    1285           0 :                 return NULL;
    1286             :         }
    1287           2 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1288           2 :         if (!p)
    1289           0 :                 return NULL;
    1290           2 :         p->kind = For_kind;
    1291           2 :         p->v.For.target = target;
    1292           2 :         p->v.For.iter = iter;
    1293           2 :         p->v.For.body = body;
    1294           2 :         p->v.For.orelse = orelse;
    1295           2 :         p->lineno = lineno;
    1296           2 :         p->col_offset = col_offset;
    1297           2 :         return p;
    1298             : }
    1299             : 
    1300             : stmt_ty
    1301           1 : While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
    1302             :       col_offset, PyArena *arena)
    1303             : {
    1304             :         stmt_ty p;
    1305           1 :         if (!test) {
    1306           0 :                 PyErr_SetString(PyExc_ValueError,
    1307             :                                 "field test is required for While");
    1308           0 :                 return NULL;
    1309             :         }
    1310           1 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1311           1 :         if (!p)
    1312           0 :                 return NULL;
    1313           1 :         p->kind = While_kind;
    1314           1 :         p->v.While.test = test;
    1315           1 :         p->v.While.body = body;
    1316           1 :         p->v.While.orelse = orelse;
    1317           1 :         p->lineno = lineno;
    1318           1 :         p->col_offset = col_offset;
    1319           1 :         return p;
    1320             : }
    1321             : 
    1322             : stmt_ty
    1323          14 : If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
    1324             :    col_offset, PyArena *arena)
    1325             : {
    1326             :         stmt_ty p;
    1327          14 :         if (!test) {
    1328           0 :                 PyErr_SetString(PyExc_ValueError,
    1329             :                                 "field test is required for If");
    1330           0 :                 return NULL;
    1331             :         }
    1332          14 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1333          14 :         if (!p)
    1334           0 :                 return NULL;
    1335          14 :         p->kind = If_kind;
    1336          14 :         p->v.If.test = test;
    1337          14 :         p->v.If.body = body;
    1338          14 :         p->v.If.orelse = orelse;
    1339          14 :         p->lineno = lineno;
    1340          14 :         p->col_offset = col_offset;
    1341          14 :         return p;
    1342             : }
    1343             : 
    1344             : stmt_ty
    1345           0 : With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena
    1346             :      *arena)
    1347             : {
    1348             :         stmt_ty p;
    1349           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1350           0 :         if (!p)
    1351           0 :                 return NULL;
    1352           0 :         p->kind = With_kind;
    1353           0 :         p->v.With.items = items;
    1354           0 :         p->v.With.body = body;
    1355           0 :         p->lineno = lineno;
    1356           0 :         p->col_offset = col_offset;
    1357           0 :         return p;
    1358             : }
    1359             : 
    1360             : stmt_ty
    1361           4 : Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena)
    1362             : {
    1363             :         stmt_ty p;
    1364           4 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1365           4 :         if (!p)
    1366           0 :                 return NULL;
    1367           4 :         p->kind = Raise_kind;
    1368           4 :         p->v.Raise.exc = exc;
    1369           4 :         p->v.Raise.cause = cause;
    1370           4 :         p->lineno = lineno;
    1371           4 :         p->col_offset = col_offset;
    1372           4 :         return p;
    1373             : }
    1374             : 
    1375             : stmt_ty
    1376           5 : Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq *
    1377             :     finalbody, int lineno, int col_offset, PyArena *arena)
    1378             : {
    1379             :         stmt_ty p;
    1380           5 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1381           5 :         if (!p)
    1382           0 :                 return NULL;
    1383           5 :         p->kind = Try_kind;
    1384           5 :         p->v.Try.body = body;
    1385           5 :         p->v.Try.handlers = handlers;
    1386           5 :         p->v.Try.orelse = orelse;
    1387           5 :         p->v.Try.finalbody = finalbody;
    1388           5 :         p->lineno = lineno;
    1389           5 :         p->col_offset = col_offset;
    1390           5 :         return p;
    1391             : }
    1392             : 
    1393             : stmt_ty
    1394           0 : Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena)
    1395             : {
    1396             :         stmt_ty p;
    1397           0 :         if (!test) {
    1398           0 :                 PyErr_SetString(PyExc_ValueError,
    1399             :                                 "field test is required for Assert");
    1400           0 :                 return NULL;
    1401             :         }
    1402           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1403           0 :         if (!p)
    1404           0 :                 return NULL;
    1405           0 :         p->kind = Assert_kind;
    1406           0 :         p->v.Assert.test = test;
    1407           0 :         p->v.Assert.msg = msg;
    1408           0 :         p->lineno = lineno;
    1409           0 :         p->col_offset = col_offset;
    1410           0 :         return p;
    1411             : }
    1412             : 
    1413             : stmt_ty
    1414           4 : Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
    1415             : {
    1416             :         stmt_ty p;
    1417           4 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1418           4 :         if (!p)
    1419           0 :                 return NULL;
    1420           4 :         p->kind = Import_kind;
    1421           4 :         p->v.Import.names = names;
    1422           4 :         p->lineno = lineno;
    1423           4 :         p->col_offset = col_offset;
    1424           4 :         return p;
    1425             : }
    1426             : 
    1427             : stmt_ty
    1428          13 : ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
    1429             :            col_offset, PyArena *arena)
    1430             : {
    1431             :         stmt_ty p;
    1432          13 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1433          13 :         if (!p)
    1434           0 :                 return NULL;
    1435          13 :         p->kind = ImportFrom_kind;
    1436          13 :         p->v.ImportFrom.module = module;
    1437          13 :         p->v.ImportFrom.names = names;
    1438          13 :         p->v.ImportFrom.level = level;
    1439          13 :         p->lineno = lineno;
    1440          13 :         p->col_offset = col_offset;
    1441          13 :         return p;
    1442             : }
    1443             : 
    1444             : stmt_ty
    1445           0 : Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
    1446             : {
    1447             :         stmt_ty p;
    1448           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1449           0 :         if (!p)
    1450           0 :                 return NULL;
    1451           0 :         p->kind = Global_kind;
    1452           0 :         p->v.Global.names = names;
    1453           0 :         p->lineno = lineno;
    1454           0 :         p->col_offset = col_offset;
    1455           0 :         return p;
    1456             : }
    1457             : 
    1458             : stmt_ty
    1459           0 : Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
    1460             : {
    1461             :         stmt_ty p;
    1462           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1463           0 :         if (!p)
    1464           0 :                 return NULL;
    1465           0 :         p->kind = Nonlocal_kind;
    1466           0 :         p->v.Nonlocal.names = names;
    1467           0 :         p->lineno = lineno;
    1468           0 :         p->col_offset = col_offset;
    1469           0 :         return p;
    1470             : }
    1471             : 
    1472             : stmt_ty
    1473          27 : Expr(expr_ty value, int lineno, int col_offset, PyArena *arena)
    1474             : {
    1475             :         stmt_ty p;
    1476          27 :         if (!value) {
    1477           0 :                 PyErr_SetString(PyExc_ValueError,
    1478             :                                 "field value is required for Expr");
    1479           0 :                 return NULL;
    1480             :         }
    1481          27 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1482          27 :         if (!p)
    1483           0 :                 return NULL;
    1484          27 :         p->kind = Expr_kind;
    1485          27 :         p->v.Expr.value = value;
    1486          27 :         p->lineno = lineno;
    1487          27 :         p->col_offset = col_offset;
    1488          27 :         return p;
    1489             : }
    1490             : 
    1491             : stmt_ty
    1492           1 : Pass(int lineno, int col_offset, PyArena *arena)
    1493             : {
    1494             :         stmt_ty p;
    1495           1 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1496           1 :         if (!p)
    1497           0 :                 return NULL;
    1498           1 :         p->kind = Pass_kind;
    1499           1 :         p->lineno = lineno;
    1500           1 :         p->col_offset = col_offset;
    1501           1 :         return p;
    1502             : }
    1503             : 
    1504             : stmt_ty
    1505           0 : Break(int lineno, int col_offset, PyArena *arena)
    1506             : {
    1507             :         stmt_ty p;
    1508           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1509           0 :         if (!p)
    1510           0 :                 return NULL;
    1511           0 :         p->kind = Break_kind;
    1512           0 :         p->lineno = lineno;
    1513           0 :         p->col_offset = col_offset;
    1514           0 :         return p;
    1515             : }
    1516             : 
    1517             : stmt_ty
    1518           0 : Continue(int lineno, int col_offset, PyArena *arena)
    1519             : {
    1520             :         stmt_ty p;
    1521           0 :         p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
    1522           0 :         if (!p)
    1523           0 :                 return NULL;
    1524           0 :         p->kind = Continue_kind;
    1525           0 :         p->lineno = lineno;
    1526           0 :         p->col_offset = col_offset;
    1527           0 :         return p;
    1528             : }
    1529             : 
    1530             : expr_ty
    1531           5 : BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena
    1532             :        *arena)
    1533             : {
    1534             :         expr_ty p;
    1535           5 :         if (!op) {
    1536           0 :                 PyErr_SetString(PyExc_ValueError,
    1537             :                                 "field op is required for BoolOp");
    1538           0 :                 return NULL;
    1539             :         }
    1540           5 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1541           5 :         if (!p)
    1542           0 :                 return NULL;
    1543           5 :         p->kind = BoolOp_kind;
    1544           5 :         p->v.BoolOp.op = op;
    1545           5 :         p->v.BoolOp.values = values;
    1546           5 :         p->lineno = lineno;
    1547           5 :         p->col_offset = col_offset;
    1548           5 :         return p;
    1549             : }
    1550             : 
    1551             : expr_ty
    1552          20 : BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
    1553             :       PyArena *arena)
    1554             : {
    1555             :         expr_ty p;
    1556          20 :         if (!left) {
    1557           0 :                 PyErr_SetString(PyExc_ValueError,
    1558             :                                 "field left is required for BinOp");
    1559           0 :                 return NULL;
    1560             :         }
    1561          20 :         if (!op) {
    1562           0 :                 PyErr_SetString(PyExc_ValueError,
    1563             :                                 "field op is required for BinOp");
    1564           0 :                 return NULL;
    1565             :         }
    1566          20 :         if (!right) {
    1567           0 :                 PyErr_SetString(PyExc_ValueError,
    1568             :                                 "field right is required for BinOp");
    1569           0 :                 return NULL;
    1570             :         }
    1571          20 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1572          20 :         if (!p)
    1573           0 :                 return NULL;
    1574          20 :         p->kind = BinOp_kind;
    1575          20 :         p->v.BinOp.left = left;
    1576          20 :         p->v.BinOp.op = op;
    1577          20 :         p->v.BinOp.right = right;
    1578          20 :         p->lineno = lineno;
    1579          20 :         p->col_offset = col_offset;
    1580          20 :         return p;
    1581             : }
    1582             : 
    1583             : expr_ty
    1584           1 : UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena
    1585             :         *arena)
    1586             : {
    1587             :         expr_ty p;
    1588           1 :         if (!op) {
    1589           0 :                 PyErr_SetString(PyExc_ValueError,
    1590             :                                 "field op is required for UnaryOp");
    1591           0 :                 return NULL;
    1592             :         }
    1593           1 :         if (!operand) {
    1594           0 :                 PyErr_SetString(PyExc_ValueError,
    1595             :                                 "field operand is required for UnaryOp");
    1596           0 :                 return NULL;
    1597             :         }
    1598           1 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1599           1 :         if (!p)
    1600           0 :                 return NULL;
    1601           1 :         p->kind = UnaryOp_kind;
    1602           1 :         p->v.UnaryOp.op = op;
    1603           1 :         p->v.UnaryOp.operand = operand;
    1604           1 :         p->lineno = lineno;
    1605           1 :         p->col_offset = col_offset;
    1606           1 :         return p;
    1607             : }
    1608             : 
    1609             : expr_ty
    1610           0 : Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena
    1611             :        *arena)
    1612             : {
    1613             :         expr_ty p;
    1614           0 :         if (!args) {
    1615           0 :                 PyErr_SetString(PyExc_ValueError,
    1616             :                                 "field args is required for Lambda");
    1617           0 :                 return NULL;
    1618             :         }
    1619           0 :         if (!body) {
    1620           0 :                 PyErr_SetString(PyExc_ValueError,
    1621             :                                 "field body is required for Lambda");
    1622           0 :                 return NULL;
    1623             :         }
    1624           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1625           0 :         if (!p)
    1626           0 :                 return NULL;
    1627           0 :         p->kind = Lambda_kind;
    1628           0 :         p->v.Lambda.args = args;
    1629           0 :         p->v.Lambda.body = body;
    1630           0 :         p->lineno = lineno;
    1631           0 :         p->col_offset = col_offset;
    1632           0 :         return p;
    1633             : }
    1634             : 
    1635             : expr_ty
    1636           0 : IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
    1637             :       PyArena *arena)
    1638             : {
    1639             :         expr_ty p;
    1640           0 :         if (!test) {
    1641           0 :                 PyErr_SetString(PyExc_ValueError,
    1642             :                                 "field test is required for IfExp");
    1643           0 :                 return NULL;
    1644             :         }
    1645           0 :         if (!body) {
    1646           0 :                 PyErr_SetString(PyExc_ValueError,
    1647             :                                 "field body is required for IfExp");
    1648           0 :                 return NULL;
    1649             :         }
    1650           0 :         if (!orelse) {
    1651           0 :                 PyErr_SetString(PyExc_ValueError,
    1652             :                                 "field orelse is required for IfExp");
    1653           0 :                 return NULL;
    1654             :         }
    1655           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1656           0 :         if (!p)
    1657           0 :                 return NULL;
    1658           0 :         p->kind = IfExp_kind;
    1659           0 :         p->v.IfExp.test = test;
    1660           0 :         p->v.IfExp.body = body;
    1661           0 :         p->v.IfExp.orelse = orelse;
    1662           0 :         p->lineno = lineno;
    1663           0 :         p->col_offset = col_offset;
    1664           0 :         return p;
    1665             : }
    1666             : 
    1667             : expr_ty
    1668           1 : Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena
    1669             :      *arena)
    1670             : {
    1671             :         expr_ty p;
    1672           1 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1673           1 :         if (!p)
    1674           0 :                 return NULL;
    1675           1 :         p->kind = Dict_kind;
    1676           1 :         p->v.Dict.keys = keys;
    1677           1 :         p->v.Dict.values = values;
    1678           1 :         p->lineno = lineno;
    1679           1 :         p->col_offset = col_offset;
    1680           1 :         return p;
    1681             : }
    1682             : 
    1683             : expr_ty
    1684           0 : Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena)
    1685             : {
    1686             :         expr_ty p;
    1687           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1688           0 :         if (!p)
    1689           0 :                 return NULL;
    1690           0 :         p->kind = Set_kind;
    1691           0 :         p->v.Set.elts = elts;
    1692           0 :         p->lineno = lineno;
    1693           0 :         p->col_offset = col_offset;
    1694           0 :         return p;
    1695             : }
    1696             : 
    1697             : expr_ty
    1698           0 : ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
    1699             :          PyArena *arena)
    1700             : {
    1701             :         expr_ty p;
    1702           0 :         if (!elt) {
    1703           0 :                 PyErr_SetString(PyExc_ValueError,
    1704             :                                 "field elt is required for ListComp");
    1705           0 :                 return NULL;
    1706             :         }
    1707           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1708           0 :         if (!p)
    1709           0 :                 return NULL;
    1710           0 :         p->kind = ListComp_kind;
    1711           0 :         p->v.ListComp.elt = elt;
    1712           0 :         p->v.ListComp.generators = generators;
    1713           0 :         p->lineno = lineno;
    1714           0 :         p->col_offset = col_offset;
    1715           0 :         return p;
    1716             : }
    1717             : 
    1718             : expr_ty
    1719           0 : SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena
    1720             :         *arena)
    1721             : {
    1722             :         expr_ty p;
    1723           0 :         if (!elt) {
    1724           0 :                 PyErr_SetString(PyExc_ValueError,
    1725             :                                 "field elt is required for SetComp");
    1726           0 :                 return NULL;
    1727             :         }
    1728           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1729           0 :         if (!p)
    1730           0 :                 return NULL;
    1731           0 :         p->kind = SetComp_kind;
    1732           0 :         p->v.SetComp.elt = elt;
    1733           0 :         p->v.SetComp.generators = generators;
    1734           0 :         p->lineno = lineno;
    1735           0 :         p->col_offset = col_offset;
    1736           0 :         return p;
    1737             : }
    1738             : 
    1739             : expr_ty
    1740           0 : DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
    1741             :          col_offset, PyArena *arena)
    1742             : {
    1743             :         expr_ty p;
    1744           0 :         if (!key) {
    1745           0 :                 PyErr_SetString(PyExc_ValueError,
    1746             :                                 "field key is required for DictComp");
    1747           0 :                 return NULL;
    1748             :         }
    1749           0 :         if (!value) {
    1750           0 :                 PyErr_SetString(PyExc_ValueError,
    1751             :                                 "field value is required for DictComp");
    1752           0 :                 return NULL;
    1753             :         }
    1754           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1755           0 :         if (!p)
    1756           0 :                 return NULL;
    1757           0 :         p->kind = DictComp_kind;
    1758           0 :         p->v.DictComp.key = key;
    1759           0 :         p->v.DictComp.value = value;
    1760           0 :         p->v.DictComp.generators = generators;
    1761           0 :         p->lineno = lineno;
    1762           0 :         p->col_offset = col_offset;
    1763           0 :         return p;
    1764             : }
    1765             : 
    1766             : expr_ty
    1767           0 : GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
    1768             :              PyArena *arena)
    1769             : {
    1770             :         expr_ty p;
    1771           0 :         if (!elt) {
    1772           0 :                 PyErr_SetString(PyExc_ValueError,
    1773             :                                 "field elt is required for GeneratorExp");
    1774           0 :                 return NULL;
    1775             :         }
    1776           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1777           0 :         if (!p)
    1778           0 :                 return NULL;
    1779           0 :         p->kind = GeneratorExp_kind;
    1780           0 :         p->v.GeneratorExp.elt = elt;
    1781           0 :         p->v.GeneratorExp.generators = generators;
    1782           0 :         p->lineno = lineno;
    1783           0 :         p->col_offset = col_offset;
    1784           0 :         return p;
    1785             : }
    1786             : 
    1787             : expr_ty
    1788           0 : Yield(expr_ty value, int lineno, int col_offset, PyArena *arena)
    1789             : {
    1790             :         expr_ty p;
    1791           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1792           0 :         if (!p)
    1793           0 :                 return NULL;
    1794           0 :         p->kind = Yield_kind;
    1795           0 :         p->v.Yield.value = value;
    1796           0 :         p->lineno = lineno;
    1797           0 :         p->col_offset = col_offset;
    1798           0 :         return p;
    1799             : }
    1800             : 
    1801             : expr_ty
    1802           0 : YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena)
    1803             : {
    1804             :         expr_ty p;
    1805           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1806           0 :         if (!p)
    1807           0 :                 return NULL;
    1808           0 :         p->kind = YieldFrom_kind;
    1809           0 :         p->v.YieldFrom.value = value;
    1810           0 :         p->lineno = lineno;
    1811           0 :         p->col_offset = col_offset;
    1812           0 :         return p;
    1813             : }
    1814             : 
    1815             : expr_ty
    1816          20 : Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
    1817             :         int col_offset, PyArena *arena)
    1818             : {
    1819             :         expr_ty p;
    1820          20 :         if (!left) {
    1821           0 :                 PyErr_SetString(PyExc_ValueError,
    1822             :                                 "field left is required for Compare");
    1823           0 :                 return NULL;
    1824             :         }
    1825          20 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1826          20 :         if (!p)
    1827           0 :                 return NULL;
    1828          20 :         p->kind = Compare_kind;
    1829          20 :         p->v.Compare.left = left;
    1830          20 :         p->v.Compare.ops = ops;
    1831          20 :         p->v.Compare.comparators = comparators;
    1832          20 :         p->lineno = lineno;
    1833          20 :         p->col_offset = col_offset;
    1834          20 :         return p;
    1835             : }
    1836             : 
    1837             : expr_ty
    1838          84 : Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs,
    1839             :      expr_ty kwargs, int lineno, int col_offset, PyArena *arena)
    1840             : {
    1841             :         expr_ty p;
    1842          84 :         if (!func) {
    1843           0 :                 PyErr_SetString(PyExc_ValueError,
    1844             :                                 "field func is required for Call");
    1845           0 :                 return NULL;
    1846             :         }
    1847          84 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1848          84 :         if (!p)
    1849           0 :                 return NULL;
    1850          84 :         p->kind = Call_kind;
    1851          84 :         p->v.Call.func = func;
    1852          84 :         p->v.Call.args = args;
    1853          84 :         p->v.Call.keywords = keywords;
    1854          84 :         p->v.Call.starargs = starargs;
    1855          84 :         p->v.Call.kwargs = kwargs;
    1856          84 :         p->lineno = lineno;
    1857          84 :         p->col_offset = col_offset;
    1858          84 :         return p;
    1859             : }
    1860             : 
    1861             : expr_ty
    1862          33 : Num(object n, int lineno, int col_offset, PyArena *arena)
    1863             : {
    1864             :         expr_ty p;
    1865          33 :         if (!n) {
    1866           0 :                 PyErr_SetString(PyExc_ValueError,
    1867             :                                 "field n is required for Num");
    1868           0 :                 return NULL;
    1869             :         }
    1870          33 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1871          33 :         if (!p)
    1872           0 :                 return NULL;
    1873          33 :         p->kind = Num_kind;
    1874          33 :         p->v.Num.n = n;
    1875          33 :         p->lineno = lineno;
    1876          33 :         p->col_offset = col_offset;
    1877          33 :         return p;
    1878             : }
    1879             : 
    1880             : expr_ty
    1881          77 : Str(string s, int lineno, int col_offset, PyArena *arena)
    1882             : {
    1883             :         expr_ty p;
    1884          77 :         if (!s) {
    1885           0 :                 PyErr_SetString(PyExc_ValueError,
    1886             :                                 "field s is required for Str");
    1887           0 :                 return NULL;
    1888             :         }
    1889          77 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1890          77 :         if (!p)
    1891           0 :                 return NULL;
    1892          77 :         p->kind = Str_kind;
    1893          77 :         p->v.Str.s = s;
    1894          77 :         p->lineno = lineno;
    1895          77 :         p->col_offset = col_offset;
    1896          77 :         return p;
    1897             : }
    1898             : 
    1899             : expr_ty
    1900           0 : Bytes(bytes s, int lineno, int col_offset, PyArena *arena)
    1901             : {
    1902             :         expr_ty p;
    1903           0 :         if (!s) {
    1904           0 :                 PyErr_SetString(PyExc_ValueError,
    1905             :                                 "field s is required for Bytes");
    1906           0 :                 return NULL;
    1907             :         }
    1908           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1909           0 :         if (!p)
    1910           0 :                 return NULL;
    1911           0 :         p->kind = Bytes_kind;
    1912           0 :         p->v.Bytes.s = s;
    1913           0 :         p->lineno = lineno;
    1914           0 :         p->col_offset = col_offset;
    1915           0 :         return p;
    1916             : }
    1917             : 
    1918             : expr_ty
    1919           0 : Ellipsis(int lineno, int col_offset, PyArena *arena)
    1920             : {
    1921             :         expr_ty p;
    1922           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1923           0 :         if (!p)
    1924           0 :                 return NULL;
    1925           0 :         p->kind = Ellipsis_kind;
    1926           0 :         p->lineno = lineno;
    1927           0 :         p->col_offset = col_offset;
    1928           0 :         return p;
    1929             : }
    1930             : 
    1931             : expr_ty
    1932         109 : Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
    1933             :           col_offset, PyArena *arena)
    1934             : {
    1935             :         expr_ty p;
    1936         109 :         if (!value) {
    1937           0 :                 PyErr_SetString(PyExc_ValueError,
    1938             :                                 "field value is required for Attribute");
    1939           0 :                 return NULL;
    1940             :         }
    1941         109 :         if (!attr) {
    1942           0 :                 PyErr_SetString(PyExc_ValueError,
    1943             :                                 "field attr is required for Attribute");
    1944           0 :                 return NULL;
    1945             :         }
    1946         109 :         if (!ctx) {
    1947           0 :                 PyErr_SetString(PyExc_ValueError,
    1948             :                                 "field ctx is required for Attribute");
    1949           0 :                 return NULL;
    1950             :         }
    1951         109 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1952         109 :         if (!p)
    1953           0 :                 return NULL;
    1954         109 :         p->kind = Attribute_kind;
    1955         109 :         p->v.Attribute.value = value;
    1956         109 :         p->v.Attribute.attr = attr;
    1957         109 :         p->v.Attribute.ctx = ctx;
    1958         109 :         p->lineno = lineno;
    1959         109 :         p->col_offset = col_offset;
    1960         109 :         return p;
    1961             : }
    1962             : 
    1963             : expr_ty
    1964          21 : Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int
    1965             :           col_offset, PyArena *arena)
    1966             : {
    1967             :         expr_ty p;
    1968          21 :         if (!value) {
    1969           0 :                 PyErr_SetString(PyExc_ValueError,
    1970             :                                 "field value is required for Subscript");
    1971           0 :                 return NULL;
    1972             :         }
    1973          21 :         if (!slice) {
    1974           0 :                 PyErr_SetString(PyExc_ValueError,
    1975             :                                 "field slice is required for Subscript");
    1976           0 :                 return NULL;
    1977             :         }
    1978          21 :         if (!ctx) {
    1979           0 :                 PyErr_SetString(PyExc_ValueError,
    1980             :                                 "field ctx is required for Subscript");
    1981           0 :                 return NULL;
    1982             :         }
    1983          21 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    1984          21 :         if (!p)
    1985           0 :                 return NULL;
    1986          21 :         p->kind = Subscript_kind;
    1987          21 :         p->v.Subscript.value = value;
    1988          21 :         p->v.Subscript.slice = slice;
    1989          21 :         p->v.Subscript.ctx = ctx;
    1990          21 :         p->lineno = lineno;
    1991          21 :         p->col_offset = col_offset;
    1992          21 :         return p;
    1993             : }
    1994             : 
    1995             : expr_ty
    1996           0 : Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena
    1997             :         *arena)
    1998             : {
    1999             :         expr_ty p;
    2000           0 :         if (!value) {
    2001           0 :                 PyErr_SetString(PyExc_ValueError,
    2002             :                                 "field value is required for Starred");
    2003           0 :                 return NULL;
    2004             :         }
    2005           0 :         if (!ctx) {
    2006           0 :                 PyErr_SetString(PyExc_ValueError,
    2007             :                                 "field ctx is required for Starred");
    2008           0 :                 return NULL;
    2009             :         }
    2010           0 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    2011           0 :         if (!p)
    2012           0 :                 return NULL;
    2013           0 :         p->kind = Starred_kind;
    2014           0 :         p->v.Starred.value = value;
    2015           0 :         p->v.Starred.ctx = ctx;
    2016           0 :         p->lineno = lineno;
    2017           0 :         p->col_offset = col_offset;
    2018           0 :         return p;
    2019             : }
    2020             : 
    2021             : expr_ty
    2022         314 : Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena
    2023             :      *arena)
    2024             : {
    2025             :         expr_ty p;
    2026         314 :         if (!id) {
    2027           0 :                 PyErr_SetString(PyExc_ValueError,
    2028             :                                 "field id is required for Name");
    2029           0 :                 return NULL;
    2030             :         }
    2031         314 :         if (!ctx) {
    2032           0 :                 PyErr_SetString(PyExc_ValueError,
    2033             :                                 "field ctx is required for Name");
    2034           0 :                 return NULL;
    2035             :         }
    2036         314 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    2037         314 :         if (!p)
    2038           0 :                 return NULL;
    2039         314 :         p->kind = Name_kind;
    2040         314 :         p->v.Name.id = id;
    2041         314 :         p->v.Name.ctx = ctx;
    2042         314 :         p->lineno = lineno;
    2043         314 :         p->col_offset = col_offset;
    2044         314 :         return p;
    2045             : }
    2046             : 
    2047             : expr_ty
    2048           2 : List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
    2049             :      *arena)
    2050             : {
    2051             :         expr_ty p;
    2052           2 :         if (!ctx) {
    2053           0 :                 PyErr_SetString(PyExc_ValueError,
    2054             :                                 "field ctx is required for List");
    2055           0 :                 return NULL;
    2056             :         }
    2057           2 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    2058           2 :         if (!p)
    2059           0 :                 return NULL;
    2060           2 :         p->kind = List_kind;
    2061           2 :         p->v.List.elts = elts;
    2062           2 :         p->v.List.ctx = ctx;
    2063           2 :         p->lineno = lineno;
    2064           2 :         p->col_offset = col_offset;
    2065           2 :         return p;
    2066             : }
    2067             : 
    2068             : expr_ty
    2069          15 : Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena
    2070             :       *arena)
    2071             : {
    2072             :         expr_ty p;
    2073          15 :         if (!ctx) {
    2074           0 :                 PyErr_SetString(PyExc_ValueError,
    2075             :                                 "field ctx is required for Tuple");
    2076           0 :                 return NULL;
    2077             :         }
    2078          15 :         p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
    2079          15 :         if (!p)
    2080           0 :                 return NULL;
    2081          15 :         p->kind = Tuple_kind;
    2082          15 :         p->v.Tuple.elts = elts;
    2083          15 :         p->v.Tuple.ctx = ctx;
    2084          15 :         p->lineno = lineno;
    2085          15 :         p->col_offset = col_offset;
    2086          15 :         return p;
    2087             : }
    2088             : 
    2089             : slice_ty
    2090           4 : Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena)
    2091             : {
    2092             :         slice_ty p;
    2093           4 :         p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
    2094           4 :         if (!p)
    2095           0 :                 return NULL;
    2096           4 :         p->kind = Slice_kind;
    2097           4 :         p->v.Slice.lower = lower;
    2098           4 :         p->v.Slice.upper = upper;
    2099           4 :         p->v.Slice.step = step;
    2100           4 :         return p;
    2101             : }
    2102             : 
    2103             : slice_ty
    2104           0 : ExtSlice(asdl_seq * dims, PyArena *arena)
    2105             : {
    2106             :         slice_ty p;
    2107           0 :         p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
    2108           0 :         if (!p)
    2109           0 :                 return NULL;
    2110           0 :         p->kind = ExtSlice_kind;
    2111           0 :         p->v.ExtSlice.dims = dims;
    2112           0 :         return p;
    2113             : }
    2114             : 
    2115             : slice_ty
    2116          17 : Index(expr_ty value, PyArena *arena)
    2117             : {
    2118             :         slice_ty p;
    2119          17 :         if (!value) {
    2120           0 :                 PyErr_SetString(PyExc_ValueError,
    2121             :                                 "field value is required for Index");
    2122           0 :                 return NULL;
    2123             :         }
    2124          17 :         p = (slice_ty)PyArena_Malloc(arena, sizeof(*p));
    2125          17 :         if (!p)
    2126           0 :                 return NULL;
    2127          17 :         p->kind = Index_kind;
    2128          17 :         p->v.Index.value = value;
    2129          17 :         return p;
    2130             : }
    2131             : 
    2132             : comprehension_ty
    2133           0 : comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena)
    2134             : {
    2135             :         comprehension_ty p;
    2136           0 :         if (!target) {
    2137           0 :                 PyErr_SetString(PyExc_ValueError,
    2138             :                                 "field target is required for comprehension");
    2139           0 :                 return NULL;
    2140             :         }
    2141           0 :         if (!iter) {
    2142           0 :                 PyErr_SetString(PyExc_ValueError,
    2143             :                                 "field iter is required for comprehension");
    2144           0 :                 return NULL;
    2145             :         }
    2146           0 :         p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
    2147           0 :         if (!p)
    2148           0 :                 return NULL;
    2149           0 :         p->target = target;
    2150           0 :         p->iter = iter;
    2151           0 :         p->ifs = ifs;
    2152           0 :         return p;
    2153             : }
    2154             : 
    2155             : excepthandler_ty
    2156           5 : ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int
    2157             :               col_offset, PyArena *arena)
    2158             : {
    2159             :         excepthandler_ty p;
    2160           5 :         p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p));
    2161           5 :         if (!p)
    2162           0 :                 return NULL;
    2163           5 :         p->kind = ExceptHandler_kind;
    2164           5 :         p->v.ExceptHandler.type = type;
    2165           5 :         p->v.ExceptHandler.name = name;
    2166           5 :         p->v.ExceptHandler.body = body;
    2167           5 :         p->lineno = lineno;
    2168           5 :         p->col_offset = col_offset;
    2169           5 :         return p;
    2170             : }
    2171             : 
    2172             : arguments_ty
    2173          24 : arguments(asdl_seq * args, identifier vararg, expr_ty varargannotation,
    2174             :           asdl_seq * kwonlyargs, identifier kwarg, expr_ty kwargannotation,
    2175             :           asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena)
    2176             : {
    2177             :         arguments_ty p;
    2178          24 :         p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p));
    2179          24 :         if (!p)
    2180           0 :                 return NULL;
    2181          24 :         p->args = args;
    2182          24 :         p->vararg = vararg;
    2183          24 :         p->varargannotation = varargannotation;
    2184          24 :         p->kwonlyargs = kwonlyargs;
    2185          24 :         p->kwarg = kwarg;
    2186          24 :         p->kwargannotation = kwargannotation;
    2187          24 :         p->defaults = defaults;
    2188          24 :         p->kw_defaults = kw_defaults;
    2189          24 :         return p;
    2190             : }
    2191             : 
    2192             : arg_ty
    2193          51 : arg(identifier arg, expr_ty annotation, PyArena *arena)
    2194             : {
    2195             :         arg_ty p;
    2196          51 :         if (!arg) {
    2197           0 :                 PyErr_SetString(PyExc_ValueError,
    2198             :                                 "field arg is required for arg");
    2199           0 :                 return NULL;
    2200             :         }
    2201          51 :         p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
    2202          51 :         if (!p)
    2203           0 :                 return NULL;
    2204          51 :         p->arg = arg;
    2205          51 :         p->annotation = annotation;
    2206          51 :         return p;
    2207             : }
    2208             : 
    2209             : keyword_ty
    2210           9 : keyword(identifier arg, expr_ty value, PyArena *arena)
    2211             : {
    2212             :         keyword_ty p;
    2213           9 :         if (!arg) {
    2214           0 :                 PyErr_SetString(PyExc_ValueError,
    2215             :                                 "field arg is required for keyword");
    2216           0 :                 return NULL;
    2217             :         }
    2218           9 :         if (!value) {
    2219           0 :                 PyErr_SetString(PyExc_ValueError,
    2220             :                                 "field value is required for keyword");
    2221           0 :                 return NULL;
    2222             :         }
    2223           9 :         p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
    2224           9 :         if (!p)
    2225           0 :                 return NULL;
    2226           9 :         p->arg = arg;
    2227           9 :         p->value = value;
    2228           9 :         return p;
    2229             : }
    2230             : 
    2231             : alias_ty
    2232          40 : alias(identifier name, identifier asname, PyArena *arena)
    2233             : {
    2234             :         alias_ty p;
    2235          40 :         if (!name) {
    2236           0 :                 PyErr_SetString(PyExc_ValueError,
    2237             :                                 "field name is required for alias");
    2238           0 :                 return NULL;
    2239             :         }
    2240          40 :         p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
    2241          40 :         if (!p)
    2242           0 :                 return NULL;
    2243          40 :         p->name = name;
    2244          40 :         p->asname = asname;
    2245          40 :         return p;
    2246             : }
    2247             : 
    2248             : withitem_ty
    2249           0 : withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
    2250             : {
    2251             :         withitem_ty p;
    2252           0 :         if (!context_expr) {
    2253           0 :                 PyErr_SetString(PyExc_ValueError,
    2254             :                                 "field context_expr is required for withitem");
    2255           0 :                 return NULL;
    2256             :         }
    2257           0 :         p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p));
    2258           0 :         if (!p)
    2259           0 :                 return NULL;
    2260           0 :         p->context_expr = context_expr;
    2261           0 :         p->optional_vars = optional_vars;
    2262           0 :         return p;
    2263             : }
    2264             : 
    2265             : 
    2266             : PyObject*
    2267           0 : ast2obj_mod(void* _o)
    2268             : {
    2269           0 :         mod_ty o = (mod_ty)_o;
    2270           0 :         PyObject *result = NULL, *value = NULL;
    2271           0 :         if (!o) {
    2272           0 :                 Py_INCREF(Py_None);
    2273           0 :                 return Py_None;
    2274             :         }
    2275             : 
    2276           0 :         switch (o->kind) {
    2277             :         case Module_kind:
    2278           0 :                 result = PyType_GenericNew(Module_type, NULL, NULL);
    2279           0 :                 if (!result) goto failed;
    2280           0 :                 value = ast2obj_list(o->v.Module.body, ast2obj_stmt);
    2281           0 :                 if (!value) goto failed;
    2282           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2283           0 :                         goto failed;
    2284           0 :                 Py_DECREF(value);
    2285           0 :                 break;
    2286             :         case Interactive_kind:
    2287           0 :                 result = PyType_GenericNew(Interactive_type, NULL, NULL);
    2288           0 :                 if (!result) goto failed;
    2289           0 :                 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt);
    2290           0 :                 if (!value) goto failed;
    2291           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2292           0 :                         goto failed;
    2293           0 :                 Py_DECREF(value);
    2294           0 :                 break;
    2295             :         case Expression_kind:
    2296           0 :                 result = PyType_GenericNew(Expression_type, NULL, NULL);
    2297           0 :                 if (!result) goto failed;
    2298           0 :                 value = ast2obj_expr(o->v.Expression.body);
    2299           0 :                 if (!value) goto failed;
    2300           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2301           0 :                         goto failed;
    2302           0 :                 Py_DECREF(value);
    2303           0 :                 break;
    2304             :         case Suite_kind:
    2305           0 :                 result = PyType_GenericNew(Suite_type, NULL, NULL);
    2306           0 :                 if (!result) goto failed;
    2307           0 :                 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt);
    2308           0 :                 if (!value) goto failed;
    2309           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2310           0 :                         goto failed;
    2311           0 :                 Py_DECREF(value);
    2312           0 :                 break;
    2313             :         }
    2314           0 :         return result;
    2315             : failed:
    2316           0 :         Py_XDECREF(value);
    2317           0 :         Py_XDECREF(result);
    2318           0 :         return NULL;
    2319             : }
    2320             : 
    2321             : PyObject*
    2322           0 : ast2obj_stmt(void* _o)
    2323             : {
    2324           0 :         stmt_ty o = (stmt_ty)_o;
    2325           0 :         PyObject *result = NULL, *value = NULL;
    2326           0 :         if (!o) {
    2327           0 :                 Py_INCREF(Py_None);
    2328           0 :                 return Py_None;
    2329             :         }
    2330             : 
    2331           0 :         switch (o->kind) {
    2332             :         case FunctionDef_kind:
    2333           0 :                 result = PyType_GenericNew(FunctionDef_type, NULL, NULL);
    2334           0 :                 if (!result) goto failed;
    2335           0 :                 value = ast2obj_identifier(o->v.FunctionDef.name);
    2336           0 :                 if (!value) goto failed;
    2337           0 :                 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
    2338           0 :                         goto failed;
    2339           0 :                 Py_DECREF(value);
    2340           0 :                 value = ast2obj_arguments(o->v.FunctionDef.args);
    2341           0 :                 if (!value) goto failed;
    2342           0 :                 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
    2343           0 :                         goto failed;
    2344           0 :                 Py_DECREF(value);
    2345           0 :                 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt);
    2346           0 :                 if (!value) goto failed;
    2347           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2348           0 :                         goto failed;
    2349           0 :                 Py_DECREF(value);
    2350           0 :                 value = ast2obj_list(o->v.FunctionDef.decorator_list,
    2351             :                                      ast2obj_expr);
    2352           0 :                 if (!value) goto failed;
    2353           0 :                 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) ==
    2354             :                     -1)
    2355           0 :                         goto failed;
    2356           0 :                 Py_DECREF(value);
    2357           0 :                 value = ast2obj_expr(o->v.FunctionDef.returns);
    2358           0 :                 if (!value) goto failed;
    2359           0 :                 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1)
    2360           0 :                         goto failed;
    2361           0 :                 Py_DECREF(value);
    2362           0 :                 break;
    2363             :         case ClassDef_kind:
    2364           0 :                 result = PyType_GenericNew(ClassDef_type, NULL, NULL);
    2365           0 :                 if (!result) goto failed;
    2366           0 :                 value = ast2obj_identifier(o->v.ClassDef.name);
    2367           0 :                 if (!value) goto failed;
    2368           0 :                 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
    2369           0 :                         goto failed;
    2370           0 :                 Py_DECREF(value);
    2371           0 :                 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr);
    2372           0 :                 if (!value) goto failed;
    2373           0 :                 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1)
    2374           0 :                         goto failed;
    2375           0 :                 Py_DECREF(value);
    2376           0 :                 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword);
    2377           0 :                 if (!value) goto failed;
    2378           0 :                 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
    2379           0 :                         goto failed;
    2380           0 :                 Py_DECREF(value);
    2381           0 :                 value = ast2obj_expr(o->v.ClassDef.starargs);
    2382           0 :                 if (!value) goto failed;
    2383           0 :                 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
    2384           0 :                         goto failed;
    2385           0 :                 Py_DECREF(value);
    2386           0 :                 value = ast2obj_expr(o->v.ClassDef.kwargs);
    2387           0 :                 if (!value) goto failed;
    2388           0 :                 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
    2389           0 :                         goto failed;
    2390           0 :                 Py_DECREF(value);
    2391           0 :                 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt);
    2392           0 :                 if (!value) goto failed;
    2393           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2394           0 :                         goto failed;
    2395           0 :                 Py_DECREF(value);
    2396           0 :                 value = ast2obj_list(o->v.ClassDef.decorator_list,
    2397             :                                      ast2obj_expr);
    2398           0 :                 if (!value) goto failed;
    2399           0 :                 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) ==
    2400             :                     -1)
    2401           0 :                         goto failed;
    2402           0 :                 Py_DECREF(value);
    2403           0 :                 break;
    2404             :         case Return_kind:
    2405           0 :                 result = PyType_GenericNew(Return_type, NULL, NULL);
    2406           0 :                 if (!result) goto failed;
    2407           0 :                 value = ast2obj_expr(o->v.Return.value);
    2408           0 :                 if (!value) goto failed;
    2409           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2410           0 :                         goto failed;
    2411           0 :                 Py_DECREF(value);
    2412           0 :                 break;
    2413             :         case Delete_kind:
    2414           0 :                 result = PyType_GenericNew(Delete_type, NULL, NULL);
    2415           0 :                 if (!result) goto failed;
    2416           0 :                 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr);
    2417           0 :                 if (!value) goto failed;
    2418           0 :                 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
    2419           0 :                         goto failed;
    2420           0 :                 Py_DECREF(value);
    2421           0 :                 break;
    2422             :         case Assign_kind:
    2423           0 :                 result = PyType_GenericNew(Assign_type, NULL, NULL);
    2424           0 :                 if (!result) goto failed;
    2425           0 :                 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr);
    2426           0 :                 if (!value) goto failed;
    2427           0 :                 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1)
    2428           0 :                         goto failed;
    2429           0 :                 Py_DECREF(value);
    2430           0 :                 value = ast2obj_expr(o->v.Assign.value);
    2431           0 :                 if (!value) goto failed;
    2432           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2433           0 :                         goto failed;
    2434           0 :                 Py_DECREF(value);
    2435           0 :                 break;
    2436             :         case AugAssign_kind:
    2437           0 :                 result = PyType_GenericNew(AugAssign_type, NULL, NULL);
    2438           0 :                 if (!result) goto failed;
    2439           0 :                 value = ast2obj_expr(o->v.AugAssign.target);
    2440           0 :                 if (!value) goto failed;
    2441           0 :                 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
    2442           0 :                         goto failed;
    2443           0 :                 Py_DECREF(value);
    2444           0 :                 value = ast2obj_operator(o->v.AugAssign.op);
    2445           0 :                 if (!value) goto failed;
    2446           0 :                 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
    2447           0 :                         goto failed;
    2448           0 :                 Py_DECREF(value);
    2449           0 :                 value = ast2obj_expr(o->v.AugAssign.value);
    2450           0 :                 if (!value) goto failed;
    2451           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2452           0 :                         goto failed;
    2453           0 :                 Py_DECREF(value);
    2454           0 :                 break;
    2455             :         case For_kind:
    2456           0 :                 result = PyType_GenericNew(For_type, NULL, NULL);
    2457           0 :                 if (!result) goto failed;
    2458           0 :                 value = ast2obj_expr(o->v.For.target);
    2459           0 :                 if (!value) goto failed;
    2460           0 :                 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
    2461           0 :                         goto failed;
    2462           0 :                 Py_DECREF(value);
    2463           0 :                 value = ast2obj_expr(o->v.For.iter);
    2464           0 :                 if (!value) goto failed;
    2465           0 :                 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
    2466           0 :                         goto failed;
    2467           0 :                 Py_DECREF(value);
    2468           0 :                 value = ast2obj_list(o->v.For.body, ast2obj_stmt);
    2469           0 :                 if (!value) goto failed;
    2470           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2471           0 :                         goto failed;
    2472           0 :                 Py_DECREF(value);
    2473           0 :                 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt);
    2474           0 :                 if (!value) goto failed;
    2475           0 :                 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
    2476           0 :                         goto failed;
    2477           0 :                 Py_DECREF(value);
    2478           0 :                 break;
    2479             :         case While_kind:
    2480           0 :                 result = PyType_GenericNew(While_type, NULL, NULL);
    2481           0 :                 if (!result) goto failed;
    2482           0 :                 value = ast2obj_expr(o->v.While.test);
    2483           0 :                 if (!value) goto failed;
    2484           0 :                 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
    2485           0 :                         goto failed;
    2486           0 :                 Py_DECREF(value);
    2487           0 :                 value = ast2obj_list(o->v.While.body, ast2obj_stmt);
    2488           0 :                 if (!value) goto failed;
    2489           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2490           0 :                         goto failed;
    2491           0 :                 Py_DECREF(value);
    2492           0 :                 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt);
    2493           0 :                 if (!value) goto failed;
    2494           0 :                 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
    2495           0 :                         goto failed;
    2496           0 :                 Py_DECREF(value);
    2497           0 :                 break;
    2498             :         case If_kind:
    2499           0 :                 result = PyType_GenericNew(If_type, NULL, NULL);
    2500           0 :                 if (!result) goto failed;
    2501           0 :                 value = ast2obj_expr(o->v.If.test);
    2502           0 :                 if (!value) goto failed;
    2503           0 :                 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
    2504           0 :                         goto failed;
    2505           0 :                 Py_DECREF(value);
    2506           0 :                 value = ast2obj_list(o->v.If.body, ast2obj_stmt);
    2507           0 :                 if (!value) goto failed;
    2508           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2509           0 :                         goto failed;
    2510           0 :                 Py_DECREF(value);
    2511           0 :                 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt);
    2512           0 :                 if (!value) goto failed;
    2513           0 :                 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
    2514           0 :                         goto failed;
    2515           0 :                 Py_DECREF(value);
    2516           0 :                 break;
    2517             :         case With_kind:
    2518           0 :                 result = PyType_GenericNew(With_type, NULL, NULL);
    2519           0 :                 if (!result) goto failed;
    2520           0 :                 value = ast2obj_list(o->v.With.items, ast2obj_withitem);
    2521           0 :                 if (!value) goto failed;
    2522           0 :                 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1)
    2523           0 :                         goto failed;
    2524           0 :                 Py_DECREF(value);
    2525           0 :                 value = ast2obj_list(o->v.With.body, ast2obj_stmt);
    2526           0 :                 if (!value) goto failed;
    2527           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2528           0 :                         goto failed;
    2529           0 :                 Py_DECREF(value);
    2530           0 :                 break;
    2531             :         case Raise_kind:
    2532           0 :                 result = PyType_GenericNew(Raise_type, NULL, NULL);
    2533           0 :                 if (!result) goto failed;
    2534           0 :                 value = ast2obj_expr(o->v.Raise.exc);
    2535           0 :                 if (!value) goto failed;
    2536           0 :                 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1)
    2537           0 :                         goto failed;
    2538           0 :                 Py_DECREF(value);
    2539           0 :                 value = ast2obj_expr(o->v.Raise.cause);
    2540           0 :                 if (!value) goto failed;
    2541           0 :                 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1)
    2542           0 :                         goto failed;
    2543           0 :                 Py_DECREF(value);
    2544           0 :                 break;
    2545             :         case Try_kind:
    2546           0 :                 result = PyType_GenericNew(Try_type, NULL, NULL);
    2547           0 :                 if (!result) goto failed;
    2548           0 :                 value = ast2obj_list(o->v.Try.body, ast2obj_stmt);
    2549           0 :                 if (!value) goto failed;
    2550           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2551           0 :                         goto failed;
    2552           0 :                 Py_DECREF(value);
    2553           0 :                 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler);
    2554           0 :                 if (!value) goto failed;
    2555           0 :                 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1)
    2556           0 :                         goto failed;
    2557           0 :                 Py_DECREF(value);
    2558           0 :                 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt);
    2559           0 :                 if (!value) goto failed;
    2560           0 :                 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
    2561           0 :                         goto failed;
    2562           0 :                 Py_DECREF(value);
    2563           0 :                 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt);
    2564           0 :                 if (!value) goto failed;
    2565           0 :                 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1)
    2566           0 :                         goto failed;
    2567           0 :                 Py_DECREF(value);
    2568           0 :                 break;
    2569             :         case Assert_kind:
    2570           0 :                 result = PyType_GenericNew(Assert_type, NULL, NULL);
    2571           0 :                 if (!result) goto failed;
    2572           0 :                 value = ast2obj_expr(o->v.Assert.test);
    2573           0 :                 if (!value) goto failed;
    2574           0 :                 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
    2575           0 :                         goto failed;
    2576           0 :                 Py_DECREF(value);
    2577           0 :                 value = ast2obj_expr(o->v.Assert.msg);
    2578           0 :                 if (!value) goto failed;
    2579           0 :                 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1)
    2580           0 :                         goto failed;
    2581           0 :                 Py_DECREF(value);
    2582           0 :                 break;
    2583             :         case Import_kind:
    2584           0 :                 result = PyType_GenericNew(Import_type, NULL, NULL);
    2585           0 :                 if (!result) goto failed;
    2586           0 :                 value = ast2obj_list(o->v.Import.names, ast2obj_alias);
    2587           0 :                 if (!value) goto failed;
    2588           0 :                 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
    2589           0 :                         goto failed;
    2590           0 :                 Py_DECREF(value);
    2591           0 :                 break;
    2592             :         case ImportFrom_kind:
    2593           0 :                 result = PyType_GenericNew(ImportFrom_type, NULL, NULL);
    2594           0 :                 if (!result) goto failed;
    2595           0 :                 value = ast2obj_identifier(o->v.ImportFrom.module);
    2596           0 :                 if (!value) goto failed;
    2597           0 :                 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1)
    2598           0 :                         goto failed;
    2599           0 :                 Py_DECREF(value);
    2600           0 :                 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias);
    2601           0 :                 if (!value) goto failed;
    2602           0 :                 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
    2603           0 :                         goto failed;
    2604           0 :                 Py_DECREF(value);
    2605           0 :                 value = ast2obj_int(o->v.ImportFrom.level);
    2606           0 :                 if (!value) goto failed;
    2607           0 :                 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1)
    2608           0 :                         goto failed;
    2609           0 :                 Py_DECREF(value);
    2610           0 :                 break;
    2611             :         case Global_kind:
    2612           0 :                 result = PyType_GenericNew(Global_type, NULL, NULL);
    2613           0 :                 if (!result) goto failed;
    2614           0 :                 value = ast2obj_list(o->v.Global.names, ast2obj_identifier);
    2615           0 :                 if (!value) goto failed;
    2616           0 :                 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
    2617           0 :                         goto failed;
    2618           0 :                 Py_DECREF(value);
    2619           0 :                 break;
    2620             :         case Nonlocal_kind:
    2621           0 :                 result = PyType_GenericNew(Nonlocal_type, NULL, NULL);
    2622           0 :                 if (!result) goto failed;
    2623           0 :                 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier);
    2624           0 :                 if (!value) goto failed;
    2625           0 :                 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1)
    2626           0 :                         goto failed;
    2627           0 :                 Py_DECREF(value);
    2628           0 :                 break;
    2629             :         case Expr_kind:
    2630           0 :                 result = PyType_GenericNew(Expr_type, NULL, NULL);
    2631           0 :                 if (!result) goto failed;
    2632           0 :                 value = ast2obj_expr(o->v.Expr.value);
    2633           0 :                 if (!value) goto failed;
    2634           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2635           0 :                         goto failed;
    2636           0 :                 Py_DECREF(value);
    2637           0 :                 break;
    2638             :         case Pass_kind:
    2639           0 :                 result = PyType_GenericNew(Pass_type, NULL, NULL);
    2640           0 :                 if (!result) goto failed;
    2641           0 :                 break;
    2642             :         case Break_kind:
    2643           0 :                 result = PyType_GenericNew(Break_type, NULL, NULL);
    2644           0 :                 if (!result) goto failed;
    2645           0 :                 break;
    2646             :         case Continue_kind:
    2647           0 :                 result = PyType_GenericNew(Continue_type, NULL, NULL);
    2648           0 :                 if (!result) goto failed;
    2649           0 :                 break;
    2650             :         }
    2651           0 :         value = ast2obj_int(o->lineno);
    2652           0 :         if (!value) goto failed;
    2653           0 :         if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
    2654           0 :                 goto failed;
    2655           0 :         Py_DECREF(value);
    2656           0 :         value = ast2obj_int(o->col_offset);
    2657           0 :         if (!value) goto failed;
    2658           0 :         if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
    2659           0 :                 goto failed;
    2660           0 :         Py_DECREF(value);
    2661           0 :         return result;
    2662             : failed:
    2663           0 :         Py_XDECREF(value);
    2664           0 :         Py_XDECREF(result);
    2665           0 :         return NULL;
    2666             : }
    2667             : 
    2668             : PyObject*
    2669           0 : ast2obj_expr(void* _o)
    2670             : {
    2671           0 :         expr_ty o = (expr_ty)_o;
    2672           0 :         PyObject *result = NULL, *value = NULL;
    2673           0 :         if (!o) {
    2674           0 :                 Py_INCREF(Py_None);
    2675           0 :                 return Py_None;
    2676             :         }
    2677             : 
    2678           0 :         switch (o->kind) {
    2679             :         case BoolOp_kind:
    2680           0 :                 result = PyType_GenericNew(BoolOp_type, NULL, NULL);
    2681           0 :                 if (!result) goto failed;
    2682           0 :                 value = ast2obj_boolop(o->v.BoolOp.op);
    2683           0 :                 if (!value) goto failed;
    2684           0 :                 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
    2685           0 :                         goto failed;
    2686           0 :                 Py_DECREF(value);
    2687           0 :                 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr);
    2688           0 :                 if (!value) goto failed;
    2689           0 :                 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
    2690           0 :                         goto failed;
    2691           0 :                 Py_DECREF(value);
    2692           0 :                 break;
    2693             :         case BinOp_kind:
    2694           0 :                 result = PyType_GenericNew(BinOp_type, NULL, NULL);
    2695           0 :                 if (!result) goto failed;
    2696           0 :                 value = ast2obj_expr(o->v.BinOp.left);
    2697           0 :                 if (!value) goto failed;
    2698           0 :                 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
    2699           0 :                         goto failed;
    2700           0 :                 Py_DECREF(value);
    2701           0 :                 value = ast2obj_operator(o->v.BinOp.op);
    2702           0 :                 if (!value) goto failed;
    2703           0 :                 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
    2704           0 :                         goto failed;
    2705           0 :                 Py_DECREF(value);
    2706           0 :                 value = ast2obj_expr(o->v.BinOp.right);
    2707           0 :                 if (!value) goto failed;
    2708           0 :                 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1)
    2709           0 :                         goto failed;
    2710           0 :                 Py_DECREF(value);
    2711           0 :                 break;
    2712             :         case UnaryOp_kind:
    2713           0 :                 result = PyType_GenericNew(UnaryOp_type, NULL, NULL);
    2714           0 :                 if (!result) goto failed;
    2715           0 :                 value = ast2obj_unaryop(o->v.UnaryOp.op);
    2716           0 :                 if (!value) goto failed;
    2717           0 :                 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1)
    2718           0 :                         goto failed;
    2719           0 :                 Py_DECREF(value);
    2720           0 :                 value = ast2obj_expr(o->v.UnaryOp.operand);
    2721           0 :                 if (!value) goto failed;
    2722           0 :                 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1)
    2723           0 :                         goto failed;
    2724           0 :                 Py_DECREF(value);
    2725           0 :                 break;
    2726             :         case Lambda_kind:
    2727           0 :                 result = PyType_GenericNew(Lambda_type, NULL, NULL);
    2728           0 :                 if (!result) goto failed;
    2729           0 :                 value = ast2obj_arguments(o->v.Lambda.args);
    2730           0 :                 if (!value) goto failed;
    2731           0 :                 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
    2732           0 :                         goto failed;
    2733           0 :                 Py_DECREF(value);
    2734           0 :                 value = ast2obj_expr(o->v.Lambda.body);
    2735           0 :                 if (!value) goto failed;
    2736           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2737           0 :                         goto failed;
    2738           0 :                 Py_DECREF(value);
    2739           0 :                 break;
    2740             :         case IfExp_kind:
    2741           0 :                 result = PyType_GenericNew(IfExp_type, NULL, NULL);
    2742           0 :                 if (!result) goto failed;
    2743           0 :                 value = ast2obj_expr(o->v.IfExp.test);
    2744           0 :                 if (!value) goto failed;
    2745           0 :                 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1)
    2746           0 :                         goto failed;
    2747           0 :                 Py_DECREF(value);
    2748           0 :                 value = ast2obj_expr(o->v.IfExp.body);
    2749           0 :                 if (!value) goto failed;
    2750           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    2751           0 :                         goto failed;
    2752           0 :                 Py_DECREF(value);
    2753           0 :                 value = ast2obj_expr(o->v.IfExp.orelse);
    2754           0 :                 if (!value) goto failed;
    2755           0 :                 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1)
    2756           0 :                         goto failed;
    2757           0 :                 Py_DECREF(value);
    2758           0 :                 break;
    2759             :         case Dict_kind:
    2760           0 :                 result = PyType_GenericNew(Dict_type, NULL, NULL);
    2761           0 :                 if (!result) goto failed;
    2762           0 :                 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr);
    2763           0 :                 if (!value) goto failed;
    2764           0 :                 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1)
    2765           0 :                         goto failed;
    2766           0 :                 Py_DECREF(value);
    2767           0 :                 value = ast2obj_list(o->v.Dict.values, ast2obj_expr);
    2768           0 :                 if (!value) goto failed;
    2769           0 :                 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1)
    2770           0 :                         goto failed;
    2771           0 :                 Py_DECREF(value);
    2772           0 :                 break;
    2773             :         case Set_kind:
    2774           0 :                 result = PyType_GenericNew(Set_type, NULL, NULL);
    2775           0 :                 if (!result) goto failed;
    2776           0 :                 value = ast2obj_list(o->v.Set.elts, ast2obj_expr);
    2777           0 :                 if (!value) goto failed;
    2778           0 :                 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
    2779           0 :                         goto failed;
    2780           0 :                 Py_DECREF(value);
    2781           0 :                 break;
    2782             :         case ListComp_kind:
    2783           0 :                 result = PyType_GenericNew(ListComp_type, NULL, NULL);
    2784           0 :                 if (!result) goto failed;
    2785           0 :                 value = ast2obj_expr(o->v.ListComp.elt);
    2786           0 :                 if (!value) goto failed;
    2787           0 :                 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
    2788           0 :                         goto failed;
    2789           0 :                 Py_DECREF(value);
    2790           0 :                 value = ast2obj_list(o->v.ListComp.generators,
    2791             :                                      ast2obj_comprehension);
    2792           0 :                 if (!value) goto failed;
    2793           0 :                 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
    2794           0 :                         goto failed;
    2795           0 :                 Py_DECREF(value);
    2796           0 :                 break;
    2797             :         case SetComp_kind:
    2798           0 :                 result = PyType_GenericNew(SetComp_type, NULL, NULL);
    2799           0 :                 if (!result) goto failed;
    2800           0 :                 value = ast2obj_expr(o->v.SetComp.elt);
    2801           0 :                 if (!value) goto failed;
    2802           0 :                 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
    2803           0 :                         goto failed;
    2804           0 :                 Py_DECREF(value);
    2805           0 :                 value = ast2obj_list(o->v.SetComp.generators,
    2806             :                                      ast2obj_comprehension);
    2807           0 :                 if (!value) goto failed;
    2808           0 :                 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
    2809           0 :                         goto failed;
    2810           0 :                 Py_DECREF(value);
    2811           0 :                 break;
    2812             :         case DictComp_kind:
    2813           0 :                 result = PyType_GenericNew(DictComp_type, NULL, NULL);
    2814           0 :                 if (!result) goto failed;
    2815           0 :                 value = ast2obj_expr(o->v.DictComp.key);
    2816           0 :                 if (!value) goto failed;
    2817           0 :                 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1)
    2818           0 :                         goto failed;
    2819           0 :                 Py_DECREF(value);
    2820           0 :                 value = ast2obj_expr(o->v.DictComp.value);
    2821           0 :                 if (!value) goto failed;
    2822           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2823           0 :                         goto failed;
    2824           0 :                 Py_DECREF(value);
    2825           0 :                 value = ast2obj_list(o->v.DictComp.generators,
    2826             :                                      ast2obj_comprehension);
    2827           0 :                 if (!value) goto failed;
    2828           0 :                 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
    2829           0 :                         goto failed;
    2830           0 :                 Py_DECREF(value);
    2831           0 :                 break;
    2832             :         case GeneratorExp_kind:
    2833           0 :                 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL);
    2834           0 :                 if (!result) goto failed;
    2835           0 :                 value = ast2obj_expr(o->v.GeneratorExp.elt);
    2836           0 :                 if (!value) goto failed;
    2837           0 :                 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1)
    2838           0 :                         goto failed;
    2839           0 :                 Py_DECREF(value);
    2840           0 :                 value = ast2obj_list(o->v.GeneratorExp.generators,
    2841             :                                      ast2obj_comprehension);
    2842           0 :                 if (!value) goto failed;
    2843           0 :                 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1)
    2844           0 :                         goto failed;
    2845           0 :                 Py_DECREF(value);
    2846           0 :                 break;
    2847             :         case Yield_kind:
    2848           0 :                 result = PyType_GenericNew(Yield_type, NULL, NULL);
    2849           0 :                 if (!result) goto failed;
    2850           0 :                 value = ast2obj_expr(o->v.Yield.value);
    2851           0 :                 if (!value) goto failed;
    2852           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2853           0 :                         goto failed;
    2854           0 :                 Py_DECREF(value);
    2855           0 :                 break;
    2856             :         case YieldFrom_kind:
    2857           0 :                 result = PyType_GenericNew(YieldFrom_type, NULL, NULL);
    2858           0 :                 if (!result) goto failed;
    2859           0 :                 value = ast2obj_expr(o->v.YieldFrom.value);
    2860           0 :                 if (!value) goto failed;
    2861           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2862           0 :                         goto failed;
    2863           0 :                 Py_DECREF(value);
    2864           0 :                 break;
    2865             :         case Compare_kind:
    2866           0 :                 result = PyType_GenericNew(Compare_type, NULL, NULL);
    2867           0 :                 if (!result) goto failed;
    2868           0 :                 value = ast2obj_expr(o->v.Compare.left);
    2869           0 :                 if (!value) goto failed;
    2870           0 :                 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1)
    2871           0 :                         goto failed;
    2872           0 :                 Py_DECREF(value);
    2873             :                 {
    2874           0 :                         Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
    2875           0 :                         value = PyList_New(n);
    2876           0 :                         if (!value) goto failed;
    2877           0 :                         for(i = 0; i < n; i++)
    2878           0 :                                 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
    2879             :                 }
    2880           0 :                 if (!value) goto failed;
    2881           0 :                 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1)
    2882           0 :                         goto failed;
    2883           0 :                 Py_DECREF(value);
    2884           0 :                 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr);
    2885           0 :                 if (!value) goto failed;
    2886           0 :                 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1)
    2887           0 :                         goto failed;
    2888           0 :                 Py_DECREF(value);
    2889           0 :                 break;
    2890             :         case Call_kind:
    2891           0 :                 result = PyType_GenericNew(Call_type, NULL, NULL);
    2892           0 :                 if (!result) goto failed;
    2893           0 :                 value = ast2obj_expr(o->v.Call.func);
    2894           0 :                 if (!value) goto failed;
    2895           0 :                 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1)
    2896           0 :                         goto failed;
    2897           0 :                 Py_DECREF(value);
    2898           0 :                 value = ast2obj_list(o->v.Call.args, ast2obj_expr);
    2899           0 :                 if (!value) goto failed;
    2900           0 :                 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
    2901           0 :                         goto failed;
    2902           0 :                 Py_DECREF(value);
    2903           0 :                 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword);
    2904           0 :                 if (!value) goto failed;
    2905           0 :                 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1)
    2906           0 :                         goto failed;
    2907           0 :                 Py_DECREF(value);
    2908           0 :                 value = ast2obj_expr(o->v.Call.starargs);
    2909           0 :                 if (!value) goto failed;
    2910           0 :                 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1)
    2911           0 :                         goto failed;
    2912           0 :                 Py_DECREF(value);
    2913           0 :                 value = ast2obj_expr(o->v.Call.kwargs);
    2914           0 :                 if (!value) goto failed;
    2915           0 :                 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1)
    2916           0 :                         goto failed;
    2917           0 :                 Py_DECREF(value);
    2918           0 :                 break;
    2919             :         case Num_kind:
    2920           0 :                 result = PyType_GenericNew(Num_type, NULL, NULL);
    2921           0 :                 if (!result) goto failed;
    2922           0 :                 value = ast2obj_object(o->v.Num.n);
    2923           0 :                 if (!value) goto failed;
    2924           0 :                 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1)
    2925           0 :                         goto failed;
    2926           0 :                 Py_DECREF(value);
    2927           0 :                 break;
    2928             :         case Str_kind:
    2929           0 :                 result = PyType_GenericNew(Str_type, NULL, NULL);
    2930           0 :                 if (!result) goto failed;
    2931           0 :                 value = ast2obj_string(o->v.Str.s);
    2932           0 :                 if (!value) goto failed;
    2933           0 :                 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
    2934           0 :                         goto failed;
    2935           0 :                 Py_DECREF(value);
    2936           0 :                 break;
    2937             :         case Bytes_kind:
    2938           0 :                 result = PyType_GenericNew(Bytes_type, NULL, NULL);
    2939           0 :                 if (!result) goto failed;
    2940           0 :                 value = ast2obj_bytes(o->v.Bytes.s);
    2941           0 :                 if (!value) goto failed;
    2942           0 :                 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1)
    2943           0 :                         goto failed;
    2944           0 :                 Py_DECREF(value);
    2945           0 :                 break;
    2946             :         case Ellipsis_kind:
    2947           0 :                 result = PyType_GenericNew(Ellipsis_type, NULL, NULL);
    2948           0 :                 if (!result) goto failed;
    2949           0 :                 break;
    2950             :         case Attribute_kind:
    2951           0 :                 result = PyType_GenericNew(Attribute_type, NULL, NULL);
    2952           0 :                 if (!result) goto failed;
    2953           0 :                 value = ast2obj_expr(o->v.Attribute.value);
    2954           0 :                 if (!value) goto failed;
    2955           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2956           0 :                         goto failed;
    2957           0 :                 Py_DECREF(value);
    2958           0 :                 value = ast2obj_identifier(o->v.Attribute.attr);
    2959           0 :                 if (!value) goto failed;
    2960           0 :                 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1)
    2961           0 :                         goto failed;
    2962           0 :                 Py_DECREF(value);
    2963           0 :                 value = ast2obj_expr_context(o->v.Attribute.ctx);
    2964           0 :                 if (!value) goto failed;
    2965           0 :                 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
    2966           0 :                         goto failed;
    2967           0 :                 Py_DECREF(value);
    2968           0 :                 break;
    2969             :         case Subscript_kind:
    2970           0 :                 result = PyType_GenericNew(Subscript_type, NULL, NULL);
    2971           0 :                 if (!result) goto failed;
    2972           0 :                 value = ast2obj_expr(o->v.Subscript.value);
    2973           0 :                 if (!value) goto failed;
    2974           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2975           0 :                         goto failed;
    2976           0 :                 Py_DECREF(value);
    2977           0 :                 value = ast2obj_slice(o->v.Subscript.slice);
    2978           0 :                 if (!value) goto failed;
    2979           0 :                 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1)
    2980           0 :                         goto failed;
    2981           0 :                 Py_DECREF(value);
    2982           0 :                 value = ast2obj_expr_context(o->v.Subscript.ctx);
    2983           0 :                 if (!value) goto failed;
    2984           0 :                 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
    2985           0 :                         goto failed;
    2986           0 :                 Py_DECREF(value);
    2987           0 :                 break;
    2988             :         case Starred_kind:
    2989           0 :                 result = PyType_GenericNew(Starred_type, NULL, NULL);
    2990           0 :                 if (!result) goto failed;
    2991           0 :                 value = ast2obj_expr(o->v.Starred.value);
    2992           0 :                 if (!value) goto failed;
    2993           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    2994           0 :                         goto failed;
    2995           0 :                 Py_DECREF(value);
    2996           0 :                 value = ast2obj_expr_context(o->v.Starred.ctx);
    2997           0 :                 if (!value) goto failed;
    2998           0 :                 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
    2999           0 :                         goto failed;
    3000           0 :                 Py_DECREF(value);
    3001           0 :                 break;
    3002             :         case Name_kind:
    3003           0 :                 result = PyType_GenericNew(Name_type, NULL, NULL);
    3004           0 :                 if (!result) goto failed;
    3005           0 :                 value = ast2obj_identifier(o->v.Name.id);
    3006           0 :                 if (!value) goto failed;
    3007           0 :                 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1)
    3008           0 :                         goto failed;
    3009           0 :                 Py_DECREF(value);
    3010           0 :                 value = ast2obj_expr_context(o->v.Name.ctx);
    3011           0 :                 if (!value) goto failed;
    3012           0 :                 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
    3013           0 :                         goto failed;
    3014           0 :                 Py_DECREF(value);
    3015           0 :                 break;
    3016             :         case List_kind:
    3017           0 :                 result = PyType_GenericNew(List_type, NULL, NULL);
    3018           0 :                 if (!result) goto failed;
    3019           0 :                 value = ast2obj_list(o->v.List.elts, ast2obj_expr);
    3020           0 :                 if (!value) goto failed;
    3021           0 :                 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
    3022           0 :                         goto failed;
    3023           0 :                 Py_DECREF(value);
    3024           0 :                 value = ast2obj_expr_context(o->v.List.ctx);
    3025           0 :                 if (!value) goto failed;
    3026           0 :                 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
    3027           0 :                         goto failed;
    3028           0 :                 Py_DECREF(value);
    3029           0 :                 break;
    3030             :         case Tuple_kind:
    3031           0 :                 result = PyType_GenericNew(Tuple_type, NULL, NULL);
    3032           0 :                 if (!result) goto failed;
    3033           0 :                 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr);
    3034           0 :                 if (!value) goto failed;
    3035           0 :                 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1)
    3036           0 :                         goto failed;
    3037           0 :                 Py_DECREF(value);
    3038           0 :                 value = ast2obj_expr_context(o->v.Tuple.ctx);
    3039           0 :                 if (!value) goto failed;
    3040           0 :                 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1)
    3041           0 :                         goto failed;
    3042           0 :                 Py_DECREF(value);
    3043           0 :                 break;
    3044             :         }
    3045           0 :         value = ast2obj_int(o->lineno);
    3046           0 :         if (!value) goto failed;
    3047           0 :         if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
    3048           0 :                 goto failed;
    3049           0 :         Py_DECREF(value);
    3050           0 :         value = ast2obj_int(o->col_offset);
    3051           0 :         if (!value) goto failed;
    3052           0 :         if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
    3053           0 :                 goto failed;
    3054           0 :         Py_DECREF(value);
    3055           0 :         return result;
    3056             : failed:
    3057           0 :         Py_XDECREF(value);
    3058           0 :         Py_XDECREF(result);
    3059           0 :         return NULL;
    3060             : }
    3061             : 
    3062           0 : PyObject* ast2obj_expr_context(expr_context_ty o)
    3063             : {
    3064           0 :         switch(o) {
    3065             :                 case Load:
    3066           0 :                         Py_INCREF(Load_singleton);
    3067           0 :                         return Load_singleton;
    3068             :                 case Store:
    3069           0 :                         Py_INCREF(Store_singleton);
    3070           0 :                         return Store_singleton;
    3071             :                 case Del:
    3072           0 :                         Py_INCREF(Del_singleton);
    3073           0 :                         return Del_singleton;
    3074             :                 case AugLoad:
    3075           0 :                         Py_INCREF(AugLoad_singleton);
    3076           0 :                         return AugLoad_singleton;
    3077             :                 case AugStore:
    3078           0 :                         Py_INCREF(AugStore_singleton);
    3079           0 :                         return AugStore_singleton;
    3080             :                 case Param:
    3081           0 :                         Py_INCREF(Param_singleton);
    3082           0 :                         return Param_singleton;
    3083             :                 default:
    3084             :                         /* should never happen, but just in case ... */
    3085           0 :                         PyErr_Format(PyExc_SystemError, "unknown expr_context found");
    3086           0 :                         return NULL;
    3087             :         }
    3088             : }
    3089             : PyObject*
    3090           0 : ast2obj_slice(void* _o)
    3091             : {
    3092           0 :         slice_ty o = (slice_ty)_o;
    3093           0 :         PyObject *result = NULL, *value = NULL;
    3094           0 :         if (!o) {
    3095           0 :                 Py_INCREF(Py_None);
    3096           0 :                 return Py_None;
    3097             :         }
    3098             : 
    3099           0 :         switch (o->kind) {
    3100             :         case Slice_kind:
    3101           0 :                 result = PyType_GenericNew(Slice_type, NULL, NULL);
    3102           0 :                 if (!result) goto failed;
    3103           0 :                 value = ast2obj_expr(o->v.Slice.lower);
    3104           0 :                 if (!value) goto failed;
    3105           0 :                 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1)
    3106           0 :                         goto failed;
    3107           0 :                 Py_DECREF(value);
    3108           0 :                 value = ast2obj_expr(o->v.Slice.upper);
    3109           0 :                 if (!value) goto failed;
    3110           0 :                 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1)
    3111           0 :                         goto failed;
    3112           0 :                 Py_DECREF(value);
    3113           0 :                 value = ast2obj_expr(o->v.Slice.step);
    3114           0 :                 if (!value) goto failed;
    3115           0 :                 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1)
    3116           0 :                         goto failed;
    3117           0 :                 Py_DECREF(value);
    3118           0 :                 break;
    3119             :         case ExtSlice_kind:
    3120           0 :                 result = PyType_GenericNew(ExtSlice_type, NULL, NULL);
    3121           0 :                 if (!result) goto failed;
    3122           0 :                 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice);
    3123           0 :                 if (!value) goto failed;
    3124           0 :                 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1)
    3125           0 :                         goto failed;
    3126           0 :                 Py_DECREF(value);
    3127           0 :                 break;
    3128             :         case Index_kind:
    3129           0 :                 result = PyType_GenericNew(Index_type, NULL, NULL);
    3130           0 :                 if (!result) goto failed;
    3131           0 :                 value = ast2obj_expr(o->v.Index.value);
    3132           0 :                 if (!value) goto failed;
    3133           0 :                 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    3134           0 :                         goto failed;
    3135           0 :                 Py_DECREF(value);
    3136           0 :                 break;
    3137             :         }
    3138           0 :         return result;
    3139             : failed:
    3140           0 :         Py_XDECREF(value);
    3141           0 :         Py_XDECREF(result);
    3142           0 :         return NULL;
    3143             : }
    3144             : 
    3145           0 : PyObject* ast2obj_boolop(boolop_ty o)
    3146             : {
    3147           0 :         switch(o) {
    3148             :                 case And:
    3149           0 :                         Py_INCREF(And_singleton);
    3150           0 :                         return And_singleton;
    3151             :                 case Or:
    3152           0 :                         Py_INCREF(Or_singleton);
    3153           0 :                         return Or_singleton;
    3154             :                 default:
    3155             :                         /* should never happen, but just in case ... */
    3156           0 :                         PyErr_Format(PyExc_SystemError, "unknown boolop found");
    3157           0 :                         return NULL;
    3158             :         }
    3159             : }
    3160           0 : PyObject* ast2obj_operator(operator_ty o)
    3161             : {
    3162           0 :         switch(o) {
    3163             :                 case Add:
    3164           0 :                         Py_INCREF(Add_singleton);
    3165           0 :                         return Add_singleton;
    3166             :                 case Sub:
    3167           0 :                         Py_INCREF(Sub_singleton);
    3168           0 :                         return Sub_singleton;
    3169             :                 case Mult:
    3170           0 :                         Py_INCREF(Mult_singleton);
    3171           0 :                         return Mult_singleton;
    3172             :                 case Div:
    3173           0 :                         Py_INCREF(Div_singleton);
    3174           0 :                         return Div_singleton;
    3175             :                 case Mod:
    3176           0 :                         Py_INCREF(Mod_singleton);
    3177           0 :                         return Mod_singleton;
    3178             :                 case Pow:
    3179           0 :                         Py_INCREF(Pow_singleton);
    3180           0 :                         return Pow_singleton;
    3181             :                 case LShift:
    3182           0 :                         Py_INCREF(LShift_singleton);
    3183           0 :                         return LShift_singleton;
    3184             :                 case RShift:
    3185           0 :                         Py_INCREF(RShift_singleton);
    3186           0 :                         return RShift_singleton;
    3187             :                 case BitOr:
    3188           0 :                         Py_INCREF(BitOr_singleton);
    3189           0 :                         return BitOr_singleton;
    3190             :                 case BitXor:
    3191           0 :                         Py_INCREF(BitXor_singleton);
    3192           0 :                         return BitXor_singleton;
    3193             :                 case BitAnd:
    3194           0 :                         Py_INCREF(BitAnd_singleton);
    3195           0 :                         return BitAnd_singleton;
    3196             :                 case FloorDiv:
    3197           0 :                         Py_INCREF(FloorDiv_singleton);
    3198           0 :                         return FloorDiv_singleton;
    3199             :                 default:
    3200             :                         /* should never happen, but just in case ... */
    3201           0 :                         PyErr_Format(PyExc_SystemError, "unknown operator found");
    3202           0 :                         return NULL;
    3203             :         }
    3204             : }
    3205           0 : PyObject* ast2obj_unaryop(unaryop_ty o)
    3206             : {
    3207           0 :         switch(o) {
    3208             :                 case Invert:
    3209           0 :                         Py_INCREF(Invert_singleton);
    3210           0 :                         return Invert_singleton;
    3211             :                 case Not:
    3212           0 :                         Py_INCREF(Not_singleton);
    3213           0 :                         return Not_singleton;
    3214             :                 case UAdd:
    3215           0 :                         Py_INCREF(UAdd_singleton);
    3216           0 :                         return UAdd_singleton;
    3217             :                 case USub:
    3218           0 :                         Py_INCREF(USub_singleton);
    3219           0 :                         return USub_singleton;
    3220             :                 default:
    3221             :                         /* should never happen, but just in case ... */
    3222           0 :                         PyErr_Format(PyExc_SystemError, "unknown unaryop found");
    3223           0 :                         return NULL;
    3224             :         }
    3225             : }
    3226           0 : PyObject* ast2obj_cmpop(cmpop_ty o)
    3227             : {
    3228           0 :         switch(o) {
    3229             :                 case Eq:
    3230           0 :                         Py_INCREF(Eq_singleton);
    3231           0 :                         return Eq_singleton;
    3232             :                 case NotEq:
    3233           0 :                         Py_INCREF(NotEq_singleton);
    3234           0 :                         return NotEq_singleton;
    3235             :                 case Lt:
    3236           0 :                         Py_INCREF(Lt_singleton);
    3237           0 :                         return Lt_singleton;
    3238             :                 case LtE:
    3239           0 :                         Py_INCREF(LtE_singleton);
    3240           0 :                         return LtE_singleton;
    3241             :                 case Gt:
    3242           0 :                         Py_INCREF(Gt_singleton);
    3243           0 :                         return Gt_singleton;
    3244             :                 case GtE:
    3245           0 :                         Py_INCREF(GtE_singleton);
    3246           0 :                         return GtE_singleton;
    3247             :                 case Is:
    3248           0 :                         Py_INCREF(Is_singleton);
    3249           0 :                         return Is_singleton;
    3250             :                 case IsNot:
    3251           0 :                         Py_INCREF(IsNot_singleton);
    3252           0 :                         return IsNot_singleton;
    3253             :                 case In:
    3254           0 :                         Py_INCREF(In_singleton);
    3255           0 :                         return In_singleton;
    3256             :                 case NotIn:
    3257           0 :                         Py_INCREF(NotIn_singleton);
    3258           0 :                         return NotIn_singleton;
    3259             :                 default:
    3260             :                         /* should never happen, but just in case ... */
    3261           0 :                         PyErr_Format(PyExc_SystemError, "unknown cmpop found");
    3262           0 :                         return NULL;
    3263             :         }
    3264             : }
    3265             : PyObject*
    3266           0 : ast2obj_comprehension(void* _o)
    3267             : {
    3268           0 :         comprehension_ty o = (comprehension_ty)_o;
    3269           0 :         PyObject *result = NULL, *value = NULL;
    3270           0 :         if (!o) {
    3271           0 :                 Py_INCREF(Py_None);
    3272           0 :                 return Py_None;
    3273             :         }
    3274             : 
    3275           0 :         result = PyType_GenericNew(comprehension_type, NULL, NULL);
    3276           0 :         if (!result) return NULL;
    3277           0 :         value = ast2obj_expr(o->target);
    3278           0 :         if (!value) goto failed;
    3279           0 :         if (_PyObject_SetAttrId(result, &PyId_target, value) == -1)
    3280           0 :                 goto failed;
    3281           0 :         Py_DECREF(value);
    3282           0 :         value = ast2obj_expr(o->iter);
    3283           0 :         if (!value) goto failed;
    3284           0 :         if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1)
    3285           0 :                 goto failed;
    3286           0 :         Py_DECREF(value);
    3287           0 :         value = ast2obj_list(o->ifs, ast2obj_expr);
    3288           0 :         if (!value) goto failed;
    3289           0 :         if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1)
    3290           0 :                 goto failed;
    3291           0 :         Py_DECREF(value);
    3292           0 :         return result;
    3293             : failed:
    3294           0 :         Py_XDECREF(value);
    3295           0 :         Py_XDECREF(result);
    3296           0 :         return NULL;
    3297             : }
    3298             : 
    3299             : PyObject*
    3300           0 : ast2obj_excepthandler(void* _o)
    3301             : {
    3302           0 :         excepthandler_ty o = (excepthandler_ty)_o;
    3303           0 :         PyObject *result = NULL, *value = NULL;
    3304           0 :         if (!o) {
    3305           0 :                 Py_INCREF(Py_None);
    3306           0 :                 return Py_None;
    3307             :         }
    3308             : 
    3309           0 :         switch (o->kind) {
    3310             :         case ExceptHandler_kind:
    3311           0 :                 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL);
    3312           0 :                 if (!result) goto failed;
    3313           0 :                 value = ast2obj_expr(o->v.ExceptHandler.type);
    3314           0 :                 if (!value) goto failed;
    3315           0 :                 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1)
    3316           0 :                         goto failed;
    3317           0 :                 Py_DECREF(value);
    3318           0 :                 value = ast2obj_identifier(o->v.ExceptHandler.name);
    3319           0 :                 if (!value) goto failed;
    3320           0 :                 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
    3321           0 :                         goto failed;
    3322           0 :                 Py_DECREF(value);
    3323           0 :                 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt);
    3324           0 :                 if (!value) goto failed;
    3325           0 :                 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1)
    3326           0 :                         goto failed;
    3327           0 :                 Py_DECREF(value);
    3328           0 :                 break;
    3329             :         }
    3330           0 :         value = ast2obj_int(o->lineno);
    3331           0 :         if (!value) goto failed;
    3332           0 :         if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0)
    3333           0 :                 goto failed;
    3334           0 :         Py_DECREF(value);
    3335           0 :         value = ast2obj_int(o->col_offset);
    3336           0 :         if (!value) goto failed;
    3337           0 :         if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0)
    3338           0 :                 goto failed;
    3339           0 :         Py_DECREF(value);
    3340           0 :         return result;
    3341             : failed:
    3342           0 :         Py_XDECREF(value);
    3343           0 :         Py_XDECREF(result);
    3344           0 :         return NULL;
    3345             : }
    3346             : 
    3347             : PyObject*
    3348           0 : ast2obj_arguments(void* _o)
    3349             : {
    3350           0 :         arguments_ty o = (arguments_ty)_o;
    3351           0 :         PyObject *result = NULL, *value = NULL;
    3352           0 :         if (!o) {
    3353           0 :                 Py_INCREF(Py_None);
    3354           0 :                 return Py_None;
    3355             :         }
    3356             : 
    3357           0 :         result = PyType_GenericNew(arguments_type, NULL, NULL);
    3358           0 :         if (!result) return NULL;
    3359           0 :         value = ast2obj_list(o->args, ast2obj_arg);
    3360           0 :         if (!value) goto failed;
    3361           0 :         if (_PyObject_SetAttrId(result, &PyId_args, value) == -1)
    3362           0 :                 goto failed;
    3363           0 :         Py_DECREF(value);
    3364           0 :         value = ast2obj_identifier(o->vararg);
    3365           0 :         if (!value) goto failed;
    3366           0 :         if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1)
    3367           0 :                 goto failed;
    3368           0 :         Py_DECREF(value);
    3369           0 :         value = ast2obj_expr(o->varargannotation);
    3370           0 :         if (!value) goto failed;
    3371           0 :         if (_PyObject_SetAttrId(result, &PyId_varargannotation, value) == -1)
    3372           0 :                 goto failed;
    3373           0 :         Py_DECREF(value);
    3374           0 :         value = ast2obj_list(o->kwonlyargs, ast2obj_arg);
    3375           0 :         if (!value) goto failed;
    3376           0 :         if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1)
    3377           0 :                 goto failed;
    3378           0 :         Py_DECREF(value);
    3379           0 :         value = ast2obj_identifier(o->kwarg);
    3380           0 :         if (!value) goto failed;
    3381           0 :         if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1)
    3382           0 :                 goto failed;
    3383           0 :         Py_DECREF(value);
    3384           0 :         value = ast2obj_expr(o->kwargannotation);
    3385           0 :         if (!value) goto failed;
    3386           0 :         if (_PyObject_SetAttrId(result, &PyId_kwargannotation, value) == -1)
    3387           0 :                 goto failed;
    3388           0 :         Py_DECREF(value);
    3389           0 :         value = ast2obj_list(o->defaults, ast2obj_expr);
    3390           0 :         if (!value) goto failed;
    3391           0 :         if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1)
    3392           0 :                 goto failed;
    3393           0 :         Py_DECREF(value);
    3394           0 :         value = ast2obj_list(o->kw_defaults, ast2obj_expr);
    3395           0 :         if (!value) goto failed;
    3396           0 :         if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1)
    3397           0 :                 goto failed;
    3398           0 :         Py_DECREF(value);
    3399           0 :         return result;
    3400             : failed:
    3401           0 :         Py_XDECREF(value);
    3402           0 :         Py_XDECREF(result);
    3403           0 :         return NULL;
    3404             : }
    3405             : 
    3406             : PyObject*
    3407           0 : ast2obj_arg(void* _o)
    3408             : {
    3409           0 :         arg_ty o = (arg_ty)_o;
    3410           0 :         PyObject *result = NULL, *value = NULL;
    3411           0 :         if (!o) {
    3412           0 :                 Py_INCREF(Py_None);
    3413           0 :                 return Py_None;
    3414             :         }
    3415             : 
    3416           0 :         result = PyType_GenericNew(arg_type, NULL, NULL);
    3417           0 :         if (!result) return NULL;
    3418           0 :         value = ast2obj_identifier(o->arg);
    3419           0 :         if (!value) goto failed;
    3420           0 :         if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
    3421           0 :                 goto failed;
    3422           0 :         Py_DECREF(value);
    3423           0 :         value = ast2obj_expr(o->annotation);
    3424           0 :         if (!value) goto failed;
    3425           0 :         if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1)
    3426           0 :                 goto failed;
    3427           0 :         Py_DECREF(value);
    3428           0 :         return result;
    3429             : failed:
    3430           0 :         Py_XDECREF(value);
    3431           0 :         Py_XDECREF(result);
    3432           0 :         return NULL;
    3433             : }
    3434             : 
    3435             : PyObject*
    3436           0 : ast2obj_keyword(void* _o)
    3437             : {
    3438           0 :         keyword_ty o = (keyword_ty)_o;
    3439           0 :         PyObject *result = NULL, *value = NULL;
    3440           0 :         if (!o) {
    3441           0 :                 Py_INCREF(Py_None);
    3442           0 :                 return Py_None;
    3443             :         }
    3444             : 
    3445           0 :         result = PyType_GenericNew(keyword_type, NULL, NULL);
    3446           0 :         if (!result) return NULL;
    3447           0 :         value = ast2obj_identifier(o->arg);
    3448           0 :         if (!value) goto failed;
    3449           0 :         if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1)
    3450           0 :                 goto failed;
    3451           0 :         Py_DECREF(value);
    3452           0 :         value = ast2obj_expr(o->value);
    3453           0 :         if (!value) goto failed;
    3454           0 :         if (_PyObject_SetAttrId(result, &PyId_value, value) == -1)
    3455           0 :                 goto failed;
    3456           0 :         Py_DECREF(value);
    3457           0 :         return result;
    3458             : failed:
    3459           0 :         Py_XDECREF(value);
    3460           0 :         Py_XDECREF(result);
    3461           0 :         return NULL;
    3462             : }
    3463             : 
    3464             : PyObject*
    3465           0 : ast2obj_alias(void* _o)
    3466             : {
    3467           0 :         alias_ty o = (alias_ty)_o;
    3468           0 :         PyObject *result = NULL, *value = NULL;
    3469           0 :         if (!o) {
    3470           0 :                 Py_INCREF(Py_None);
    3471           0 :                 return Py_None;
    3472             :         }
    3473             : 
    3474           0 :         result = PyType_GenericNew(alias_type, NULL, NULL);
    3475           0 :         if (!result) return NULL;
    3476           0 :         value = ast2obj_identifier(o->name);
    3477           0 :         if (!value) goto failed;
    3478           0 :         if (_PyObject_SetAttrId(result, &PyId_name, value) == -1)
    3479           0 :                 goto failed;
    3480           0 :         Py_DECREF(value);
    3481           0 :         value = ast2obj_identifier(o->asname);
    3482           0 :         if (!value) goto failed;
    3483           0 :         if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1)
    3484           0 :                 goto failed;
    3485           0 :         Py_DECREF(value);
    3486           0 :         return result;
    3487             : failed:
    3488           0 :         Py_XDECREF(value);
    3489           0 :         Py_XDECREF(result);
    3490           0 :         return NULL;
    3491             : }
    3492             : 
    3493             : PyObject*
    3494           0 : ast2obj_withitem(void* _o)
    3495             : {
    3496           0 :         withitem_ty o = (withitem_ty)_o;
    3497           0 :         PyObject *result = NULL, *value = NULL;
    3498           0 :         if (!o) {
    3499           0 :                 Py_INCREF(Py_None);
    3500           0 :                 return Py_None;
    3501             :         }
    3502             : 
    3503           0 :         result = PyType_GenericNew(withitem_type, NULL, NULL);
    3504           0 :         if (!result) return NULL;
    3505           0 :         value = ast2obj_expr(o->context_expr);
    3506           0 :         if (!value) goto failed;
    3507           0 :         if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1)
    3508           0 :                 goto failed;
    3509           0 :         Py_DECREF(value);
    3510           0 :         value = ast2obj_expr(o->optional_vars);
    3511           0 :         if (!value) goto failed;
    3512           0 :         if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1)
    3513           0 :                 goto failed;
    3514           0 :         Py_DECREF(value);
    3515           0 :         return result;
    3516             : failed:
    3517           0 :         Py_XDECREF(value);
    3518           0 :         Py_XDECREF(result);
    3519           0 :         return NULL;
    3520             : }
    3521             : 
    3522             : 
    3523             : int
    3524           0 : obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
    3525             : {
    3526             :         int isinstance;
    3527             : 
    3528           0 :         PyObject *tmp = NULL;
    3529             : 
    3530           0 :         if (obj == Py_None) {
    3531           0 :                 *out = NULL;
    3532           0 :                 return 0;
    3533             :         }
    3534           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type);
    3535           0 :         if (isinstance == -1) {
    3536           0 :                 return 1;
    3537             :         }
    3538           0 :         if (isinstance) {
    3539             :                 asdl_seq* body;
    3540             : 
    3541           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    3542             :                         int res;
    3543             :                         Py_ssize_t len;
    3544             :                         Py_ssize_t i;
    3545           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    3546           0 :                         if (tmp == NULL) goto failed;
    3547           0 :                         if (!PyList_Check(tmp)) {
    3548           0 :                                 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3549           0 :                                 goto failed;
    3550             :                         }
    3551           0 :                         len = PyList_GET_SIZE(tmp);
    3552           0 :                         body = asdl_seq_new(len, arena);
    3553           0 :                         if (body == NULL) goto failed;
    3554           0 :                         for (i = 0; i < len; i++) {
    3555             :                                 stmt_ty value;
    3556           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    3557           0 :                                 if (res != 0) goto failed;
    3558           0 :                                 asdl_seq_SET(body, i, value);
    3559             :                         }
    3560           0 :                         Py_XDECREF(tmp);
    3561           0 :                         tmp = NULL;
    3562             :                 } else {
    3563           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
    3564           0 :                         return 1;
    3565             :                 }
    3566           0 :                 *out = Module(body, arena);
    3567           0 :                 if (*out == NULL) goto failed;
    3568           0 :                 return 0;
    3569             :         }
    3570           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type);
    3571           0 :         if (isinstance == -1) {
    3572           0 :                 return 1;
    3573             :         }
    3574           0 :         if (isinstance) {
    3575             :                 asdl_seq* body;
    3576             : 
    3577           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    3578             :                         int res;
    3579             :                         Py_ssize_t len;
    3580             :                         Py_ssize_t i;
    3581           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    3582           0 :                         if (tmp == NULL) goto failed;
    3583           0 :                         if (!PyList_Check(tmp)) {
    3584           0 :                                 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3585           0 :                                 goto failed;
    3586             :                         }
    3587           0 :                         len = PyList_GET_SIZE(tmp);
    3588           0 :                         body = asdl_seq_new(len, arena);
    3589           0 :                         if (body == NULL) goto failed;
    3590           0 :                         for (i = 0; i < len; i++) {
    3591             :                                 stmt_ty value;
    3592           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    3593           0 :                                 if (res != 0) goto failed;
    3594           0 :                                 asdl_seq_SET(body, i, value);
    3595             :                         }
    3596           0 :                         Py_XDECREF(tmp);
    3597           0 :                         tmp = NULL;
    3598             :                 } else {
    3599           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
    3600           0 :                         return 1;
    3601             :                 }
    3602           0 :                 *out = Interactive(body, arena);
    3603           0 :                 if (*out == NULL) goto failed;
    3604           0 :                 return 0;
    3605             :         }
    3606           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type);
    3607           0 :         if (isinstance == -1) {
    3608           0 :                 return 1;
    3609             :         }
    3610           0 :         if (isinstance) {
    3611             :                 expr_ty body;
    3612             : 
    3613           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    3614             :                         int res;
    3615           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    3616           0 :                         if (tmp == NULL) goto failed;
    3617           0 :                         res = obj2ast_expr(tmp, &body, arena);
    3618           0 :                         if (res != 0) goto failed;
    3619           0 :                         Py_XDECREF(tmp);
    3620           0 :                         tmp = NULL;
    3621             :                 } else {
    3622           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
    3623           0 :                         return 1;
    3624             :                 }
    3625           0 :                 *out = Expression(body, arena);
    3626           0 :                 if (*out == NULL) goto failed;
    3627           0 :                 return 0;
    3628             :         }
    3629           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type);
    3630           0 :         if (isinstance == -1) {
    3631           0 :                 return 1;
    3632             :         }
    3633           0 :         if (isinstance) {
    3634             :                 asdl_seq* body;
    3635             : 
    3636           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    3637             :                         int res;
    3638             :                         Py_ssize_t len;
    3639             :                         Py_ssize_t i;
    3640           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    3641           0 :                         if (tmp == NULL) goto failed;
    3642           0 :                         if (!PyList_Check(tmp)) {
    3643           0 :                                 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3644           0 :                                 goto failed;
    3645             :                         }
    3646           0 :                         len = PyList_GET_SIZE(tmp);
    3647           0 :                         body = asdl_seq_new(len, arena);
    3648           0 :                         if (body == NULL) goto failed;
    3649           0 :                         for (i = 0; i < len; i++) {
    3650             :                                 stmt_ty value;
    3651           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    3652           0 :                                 if (res != 0) goto failed;
    3653           0 :                                 asdl_seq_SET(body, i, value);
    3654             :                         }
    3655           0 :                         Py_XDECREF(tmp);
    3656           0 :                         tmp = NULL;
    3657             :                 } else {
    3658           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
    3659           0 :                         return 1;
    3660             :                 }
    3661           0 :                 *out = Suite(body, arena);
    3662           0 :                 if (*out == NULL) goto failed;
    3663           0 :                 return 0;
    3664             :         }
    3665             : 
    3666           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
    3667             :         failed:
    3668           0 :         Py_XDECREF(tmp);
    3669           0 :         return 1;
    3670             : }
    3671             : 
    3672             : int
    3673           0 : obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
    3674             : {
    3675             :         int isinstance;
    3676             : 
    3677           0 :         PyObject *tmp = NULL;
    3678             :         int lineno;
    3679             :         int col_offset;
    3680             : 
    3681           0 :         if (obj == Py_None) {
    3682           0 :                 *out = NULL;
    3683           0 :                 return 0;
    3684             :         }
    3685           0 :         if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
    3686             :                 int res;
    3687           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
    3688           0 :                 if (tmp == NULL) goto failed;
    3689           0 :                 res = obj2ast_int(tmp, &lineno, arena);
    3690           0 :                 if (res != 0) goto failed;
    3691           0 :                 Py_XDECREF(tmp);
    3692           0 :                 tmp = NULL;
    3693             :         } else {
    3694           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
    3695           0 :                 return 1;
    3696             :         }
    3697           0 :         if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
    3698             :                 int res;
    3699           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
    3700           0 :                 if (tmp == NULL) goto failed;
    3701           0 :                 res = obj2ast_int(tmp, &col_offset, arena);
    3702           0 :                 if (res != 0) goto failed;
    3703           0 :                 Py_XDECREF(tmp);
    3704           0 :                 tmp = NULL;
    3705             :         } else {
    3706           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
    3707           0 :                 return 1;
    3708             :         }
    3709           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type);
    3710           0 :         if (isinstance == -1) {
    3711           0 :                 return 1;
    3712             :         }
    3713           0 :         if (isinstance) {
    3714             :                 identifier name;
    3715             :                 arguments_ty args;
    3716             :                 asdl_seq* body;
    3717             :                 asdl_seq* decorator_list;
    3718             :                 expr_ty returns;
    3719             : 
    3720           0 :                 if (_PyObject_HasAttrId(obj, &PyId_name)) {
    3721             :                         int res;
    3722           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_name);
    3723           0 :                         if (tmp == NULL) goto failed;
    3724           0 :                         res = obj2ast_identifier(tmp, &name, arena);
    3725           0 :                         if (res != 0) goto failed;
    3726           0 :                         Py_XDECREF(tmp);
    3727           0 :                         tmp = NULL;
    3728             :                 } else {
    3729           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
    3730           0 :                         return 1;
    3731             :                 }
    3732           0 :                 if (_PyObject_HasAttrId(obj, &PyId_args)) {
    3733             :                         int res;
    3734           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_args);
    3735           0 :                         if (tmp == NULL) goto failed;
    3736           0 :                         res = obj2ast_arguments(tmp, &args, arena);
    3737           0 :                         if (res != 0) goto failed;
    3738           0 :                         Py_XDECREF(tmp);
    3739           0 :                         tmp = NULL;
    3740             :                 } else {
    3741           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
    3742           0 :                         return 1;
    3743             :                 }
    3744           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    3745             :                         int res;
    3746             :                         Py_ssize_t len;
    3747             :                         Py_ssize_t i;
    3748           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    3749           0 :                         if (tmp == NULL) goto failed;
    3750           0 :                         if (!PyList_Check(tmp)) {
    3751           0 :                                 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3752             :                                 goto failed;
    3753             :                         }
    3754           0 :                         len = PyList_GET_SIZE(tmp);
    3755           0 :                         body = asdl_seq_new(len, arena);
    3756           0 :                         if (body == NULL) goto failed;
    3757           0 :                         for (i = 0; i < len; i++) {
    3758             :                                 stmt_ty value;
    3759           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    3760           0 :                                 if (res != 0) goto failed;
    3761           0 :                                 asdl_seq_SET(body, i, value);
    3762             :                         }
    3763           0 :                         Py_XDECREF(tmp);
    3764           0 :                         tmp = NULL;
    3765             :                 } else {
    3766           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
    3767           0 :                         return 1;
    3768             :                 }
    3769           0 :                 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
    3770             :                         int res;
    3771             :                         Py_ssize_t len;
    3772             :                         Py_ssize_t i;
    3773           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
    3774           0 :                         if (tmp == NULL) goto failed;
    3775           0 :                         if (!PyList_Check(tmp)) {
    3776           0 :                                 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3777             :                                 goto failed;
    3778             :                         }
    3779           0 :                         len = PyList_GET_SIZE(tmp);
    3780           0 :                         decorator_list = asdl_seq_new(len, arena);
    3781           0 :                         if (decorator_list == NULL) goto failed;
    3782           0 :                         for (i = 0; i < len; i++) {
    3783             :                                 expr_ty value;
    3784           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    3785           0 :                                 if (res != 0) goto failed;
    3786           0 :                                 asdl_seq_SET(decorator_list, i, value);
    3787             :                         }
    3788           0 :                         Py_XDECREF(tmp);
    3789           0 :                         tmp = NULL;
    3790             :                 } else {
    3791           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
    3792           0 :                         return 1;
    3793             :                 }
    3794           0 :                 if (_PyObject_HasAttrId(obj, &PyId_returns)) {
    3795             :                         int res;
    3796           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_returns);
    3797           0 :                         if (tmp == NULL) goto failed;
    3798           0 :                         res = obj2ast_expr(tmp, &returns, arena);
    3799           0 :                         if (res != 0) goto failed;
    3800           0 :                         Py_XDECREF(tmp);
    3801           0 :                         tmp = NULL;
    3802             :                 } else {
    3803           0 :                         returns = NULL;
    3804             :                 }
    3805           0 :                 *out = FunctionDef(name, args, body, decorator_list, returns,
    3806             :                                    lineno, col_offset, arena);
    3807           0 :                 if (*out == NULL) goto failed;
    3808           0 :                 return 0;
    3809             :         }
    3810           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type);
    3811           0 :         if (isinstance == -1) {
    3812           0 :                 return 1;
    3813             :         }
    3814           0 :         if (isinstance) {
    3815             :                 identifier name;
    3816             :                 asdl_seq* bases;
    3817             :                 asdl_seq* keywords;
    3818             :                 expr_ty starargs;
    3819             :                 expr_ty kwargs;
    3820             :                 asdl_seq* body;
    3821             :                 asdl_seq* decorator_list;
    3822             : 
    3823           0 :                 if (_PyObject_HasAttrId(obj, &PyId_name)) {
    3824             :                         int res;
    3825           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_name);
    3826           0 :                         if (tmp == NULL) goto failed;
    3827           0 :                         res = obj2ast_identifier(tmp, &name, arena);
    3828           0 :                         if (res != 0) goto failed;
    3829           0 :                         Py_XDECREF(tmp);
    3830           0 :                         tmp = NULL;
    3831             :                 } else {
    3832           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
    3833           0 :                         return 1;
    3834             :                 }
    3835           0 :                 if (_PyObject_HasAttrId(obj, &PyId_bases)) {
    3836             :                         int res;
    3837             :                         Py_ssize_t len;
    3838             :                         Py_ssize_t i;
    3839           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_bases);
    3840           0 :                         if (tmp == NULL) goto failed;
    3841           0 :                         if (!PyList_Check(tmp)) {
    3842           0 :                                 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3843             :                                 goto failed;
    3844             :                         }
    3845           0 :                         len = PyList_GET_SIZE(tmp);
    3846           0 :                         bases = asdl_seq_new(len, arena);
    3847           0 :                         if (bases == NULL) goto failed;
    3848           0 :                         for (i = 0; i < len; i++) {
    3849             :                                 expr_ty value;
    3850           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    3851           0 :                                 if (res != 0) goto failed;
    3852           0 :                                 asdl_seq_SET(bases, i, value);
    3853             :                         }
    3854           0 :                         Py_XDECREF(tmp);
    3855           0 :                         tmp = NULL;
    3856             :                 } else {
    3857           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
    3858           0 :                         return 1;
    3859             :                 }
    3860           0 :                 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
    3861             :                         int res;
    3862             :                         Py_ssize_t len;
    3863             :                         Py_ssize_t i;
    3864           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
    3865           0 :                         if (tmp == NULL) goto failed;
    3866           0 :                         if (!PyList_Check(tmp)) {
    3867           0 :                                 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3868             :                                 goto failed;
    3869             :                         }
    3870           0 :                         len = PyList_GET_SIZE(tmp);
    3871           0 :                         keywords = asdl_seq_new(len, arena);
    3872           0 :                         if (keywords == NULL) goto failed;
    3873           0 :                         for (i = 0; i < len; i++) {
    3874             :                                 keyword_ty value;
    3875           0 :                                 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
    3876           0 :                                 if (res != 0) goto failed;
    3877           0 :                                 asdl_seq_SET(keywords, i, value);
    3878             :                         }
    3879           0 :                         Py_XDECREF(tmp);
    3880           0 :                         tmp = NULL;
    3881             :                 } else {
    3882           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
    3883           0 :                         return 1;
    3884             :                 }
    3885           0 :                 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
    3886             :                         int res;
    3887           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
    3888           0 :                         if (tmp == NULL) goto failed;
    3889           0 :                         res = obj2ast_expr(tmp, &starargs, arena);
    3890           0 :                         if (res != 0) goto failed;
    3891           0 :                         Py_XDECREF(tmp);
    3892           0 :                         tmp = NULL;
    3893             :                 } else {
    3894           0 :                         starargs = NULL;
    3895             :                 }
    3896           0 :                 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
    3897             :                         int res;
    3898           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
    3899           0 :                         if (tmp == NULL) goto failed;
    3900           0 :                         res = obj2ast_expr(tmp, &kwargs, arena);
    3901           0 :                         if (res != 0) goto failed;
    3902           0 :                         Py_XDECREF(tmp);
    3903           0 :                         tmp = NULL;
    3904             :                 } else {
    3905           0 :                         kwargs = NULL;
    3906             :                 }
    3907           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    3908             :                         int res;
    3909             :                         Py_ssize_t len;
    3910             :                         Py_ssize_t i;
    3911           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    3912           0 :                         if (tmp == NULL) goto failed;
    3913           0 :                         if (!PyList_Check(tmp)) {
    3914           0 :                                 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3915             :                                 goto failed;
    3916             :                         }
    3917           0 :                         len = PyList_GET_SIZE(tmp);
    3918           0 :                         body = asdl_seq_new(len, arena);
    3919           0 :                         if (body == NULL) goto failed;
    3920           0 :                         for (i = 0; i < len; i++) {
    3921             :                                 stmt_ty value;
    3922           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    3923           0 :                                 if (res != 0) goto failed;
    3924           0 :                                 asdl_seq_SET(body, i, value);
    3925             :                         }
    3926           0 :                         Py_XDECREF(tmp);
    3927           0 :                         tmp = NULL;
    3928             :                 } else {
    3929           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
    3930           0 :                         return 1;
    3931             :                 }
    3932           0 :                 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
    3933             :                         int res;
    3934             :                         Py_ssize_t len;
    3935             :                         Py_ssize_t i;
    3936           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
    3937           0 :                         if (tmp == NULL) goto failed;
    3938           0 :                         if (!PyList_Check(tmp)) {
    3939           0 :                                 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3940             :                                 goto failed;
    3941             :                         }
    3942           0 :                         len = PyList_GET_SIZE(tmp);
    3943           0 :                         decorator_list = asdl_seq_new(len, arena);
    3944           0 :                         if (decorator_list == NULL) goto failed;
    3945           0 :                         for (i = 0; i < len; i++) {
    3946             :                                 expr_ty value;
    3947           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    3948           0 :                                 if (res != 0) goto failed;
    3949           0 :                                 asdl_seq_SET(decorator_list, i, value);
    3950             :                         }
    3951           0 :                         Py_XDECREF(tmp);
    3952           0 :                         tmp = NULL;
    3953             :                 } else {
    3954           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
    3955           0 :                         return 1;
    3956             :                 }
    3957           0 :                 *out = ClassDef(name, bases, keywords, starargs, kwargs, body,
    3958             :                                 decorator_list, lineno, col_offset, arena);
    3959           0 :                 if (*out == NULL) goto failed;
    3960           0 :                 return 0;
    3961             :         }
    3962           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type);
    3963           0 :         if (isinstance == -1) {
    3964           0 :                 return 1;
    3965             :         }
    3966           0 :         if (isinstance) {
    3967             :                 expr_ty value;
    3968             : 
    3969           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    3970             :                         int res;
    3971           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    3972           0 :                         if (tmp == NULL) goto failed;
    3973           0 :                         res = obj2ast_expr(tmp, &value, arena);
    3974           0 :                         if (res != 0) goto failed;
    3975           0 :                         Py_XDECREF(tmp);
    3976           0 :                         tmp = NULL;
    3977             :                 } else {
    3978           0 :                         value = NULL;
    3979             :                 }
    3980           0 :                 *out = Return(value, lineno, col_offset, arena);
    3981           0 :                 if (*out == NULL) goto failed;
    3982           0 :                 return 0;
    3983             :         }
    3984           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type);
    3985           0 :         if (isinstance == -1) {
    3986           0 :                 return 1;
    3987             :         }
    3988           0 :         if (isinstance) {
    3989             :                 asdl_seq* targets;
    3990             : 
    3991           0 :                 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
    3992             :                         int res;
    3993             :                         Py_ssize_t len;
    3994             :                         Py_ssize_t i;
    3995           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_targets);
    3996           0 :                         if (tmp == NULL) goto failed;
    3997           0 :                         if (!PyList_Check(tmp)) {
    3998           0 :                                 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    3999           0 :                                 goto failed;
    4000             :                         }
    4001           0 :                         len = PyList_GET_SIZE(tmp);
    4002           0 :                         targets = asdl_seq_new(len, arena);
    4003           0 :                         if (targets == NULL) goto failed;
    4004           0 :                         for (i = 0; i < len; i++) {
    4005             :                                 expr_ty value;
    4006           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    4007           0 :                                 if (res != 0) goto failed;
    4008           0 :                                 asdl_seq_SET(targets, i, value);
    4009             :                         }
    4010           0 :                         Py_XDECREF(tmp);
    4011           0 :                         tmp = NULL;
    4012             :                 } else {
    4013           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
    4014           0 :                         return 1;
    4015             :                 }
    4016           0 :                 *out = Delete(targets, lineno, col_offset, arena);
    4017           0 :                 if (*out == NULL) goto failed;
    4018           0 :                 return 0;
    4019             :         }
    4020           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type);
    4021           0 :         if (isinstance == -1) {
    4022           0 :                 return 1;
    4023             :         }
    4024           0 :         if (isinstance) {
    4025             :                 asdl_seq* targets;
    4026             :                 expr_ty value;
    4027             : 
    4028           0 :                 if (_PyObject_HasAttrId(obj, &PyId_targets)) {
    4029             :                         int res;
    4030             :                         Py_ssize_t len;
    4031             :                         Py_ssize_t i;
    4032           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_targets);
    4033           0 :                         if (tmp == NULL) goto failed;
    4034           0 :                         if (!PyList_Check(tmp)) {
    4035           0 :                                 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4036             :                                 goto failed;
    4037             :                         }
    4038           0 :                         len = PyList_GET_SIZE(tmp);
    4039           0 :                         targets = asdl_seq_new(len, arena);
    4040           0 :                         if (targets == NULL) goto failed;
    4041           0 :                         for (i = 0; i < len; i++) {
    4042             :                                 expr_ty value;
    4043           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    4044           0 :                                 if (res != 0) goto failed;
    4045           0 :                                 asdl_seq_SET(targets, i, value);
    4046             :                         }
    4047           0 :                         Py_XDECREF(tmp);
    4048           0 :                         tmp = NULL;
    4049             :                 } else {
    4050           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
    4051           0 :                         return 1;
    4052             :                 }
    4053           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    4054             :                         int res;
    4055           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    4056           0 :                         if (tmp == NULL) goto failed;
    4057           0 :                         res = obj2ast_expr(tmp, &value, arena);
    4058           0 :                         if (res != 0) goto failed;
    4059           0 :                         Py_XDECREF(tmp);
    4060           0 :                         tmp = NULL;
    4061             :                 } else {
    4062           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
    4063           0 :                         return 1;
    4064             :                 }
    4065           0 :                 *out = Assign(targets, value, lineno, col_offset, arena);
    4066           0 :                 if (*out == NULL) goto failed;
    4067           0 :                 return 0;
    4068             :         }
    4069           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type);
    4070           0 :         if (isinstance == -1) {
    4071           0 :                 return 1;
    4072             :         }
    4073           0 :         if (isinstance) {
    4074             :                 expr_ty target;
    4075             :                 operator_ty op;
    4076             :                 expr_ty value;
    4077             : 
    4078           0 :                 if (_PyObject_HasAttrId(obj, &PyId_target)) {
    4079             :                         int res;
    4080           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_target);
    4081           0 :                         if (tmp == NULL) goto failed;
    4082           0 :                         res = obj2ast_expr(tmp, &target, arena);
    4083           0 :                         if (res != 0) goto failed;
    4084           0 :                         Py_XDECREF(tmp);
    4085           0 :                         tmp = NULL;
    4086             :                 } else {
    4087           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
    4088           0 :                         return 1;
    4089             :                 }
    4090           0 :                 if (_PyObject_HasAttrId(obj, &PyId_op)) {
    4091             :                         int res;
    4092           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_op);
    4093           0 :                         if (tmp == NULL) goto failed;
    4094           0 :                         res = obj2ast_operator(tmp, &op, arena);
    4095           0 :                         if (res != 0) goto failed;
    4096           0 :                         Py_XDECREF(tmp);
    4097           0 :                         tmp = NULL;
    4098             :                 } else {
    4099           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
    4100           0 :                         return 1;
    4101             :                 }
    4102           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    4103             :                         int res;
    4104           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    4105           0 :                         if (tmp == NULL) goto failed;
    4106           0 :                         res = obj2ast_expr(tmp, &value, arena);
    4107           0 :                         if (res != 0) goto failed;
    4108           0 :                         Py_XDECREF(tmp);
    4109           0 :                         tmp = NULL;
    4110             :                 } else {
    4111           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
    4112           0 :                         return 1;
    4113             :                 }
    4114           0 :                 *out = AugAssign(target, op, value, lineno, col_offset, arena);
    4115           0 :                 if (*out == NULL) goto failed;
    4116           0 :                 return 0;
    4117             :         }
    4118           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)For_type);
    4119           0 :         if (isinstance == -1) {
    4120           0 :                 return 1;
    4121             :         }
    4122           0 :         if (isinstance) {
    4123             :                 expr_ty target;
    4124             :                 expr_ty iter;
    4125             :                 asdl_seq* body;
    4126             :                 asdl_seq* orelse;
    4127             : 
    4128           0 :                 if (_PyObject_HasAttrId(obj, &PyId_target)) {
    4129             :                         int res;
    4130           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_target);
    4131           0 :                         if (tmp == NULL) goto failed;
    4132           0 :                         res = obj2ast_expr(tmp, &target, arena);
    4133           0 :                         if (res != 0) goto failed;
    4134           0 :                         Py_XDECREF(tmp);
    4135           0 :                         tmp = NULL;
    4136             :                 } else {
    4137           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
    4138           0 :                         return 1;
    4139             :                 }
    4140           0 :                 if (_PyObject_HasAttrId(obj, &PyId_iter)) {
    4141             :                         int res;
    4142           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_iter);
    4143           0 :                         if (tmp == NULL) goto failed;
    4144           0 :                         res = obj2ast_expr(tmp, &iter, arena);
    4145           0 :                         if (res != 0) goto failed;
    4146           0 :                         Py_XDECREF(tmp);
    4147           0 :                         tmp = NULL;
    4148             :                 } else {
    4149           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
    4150           0 :                         return 1;
    4151             :                 }
    4152           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    4153             :                         int res;
    4154             :                         Py_ssize_t len;
    4155             :                         Py_ssize_t i;
    4156           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    4157           0 :                         if (tmp == NULL) goto failed;
    4158           0 :                         if (!PyList_Check(tmp)) {
    4159           0 :                                 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4160             :                                 goto failed;
    4161             :                         }
    4162           0 :                         len = PyList_GET_SIZE(tmp);
    4163           0 :                         body = asdl_seq_new(len, arena);
    4164           0 :                         if (body == NULL) goto failed;
    4165           0 :                         for (i = 0; i < len; i++) {
    4166             :                                 stmt_ty value;
    4167           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4168           0 :                                 if (res != 0) goto failed;
    4169           0 :                                 asdl_seq_SET(body, i, value);
    4170             :                         }
    4171           0 :                         Py_XDECREF(tmp);
    4172           0 :                         tmp = NULL;
    4173             :                 } else {
    4174           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
    4175           0 :                         return 1;
    4176             :                 }
    4177           0 :                 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
    4178             :                         int res;
    4179             :                         Py_ssize_t len;
    4180             :                         Py_ssize_t i;
    4181           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
    4182           0 :                         if (tmp == NULL) goto failed;
    4183           0 :                         if (!PyList_Check(tmp)) {
    4184           0 :                                 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4185             :                                 goto failed;
    4186             :                         }
    4187           0 :                         len = PyList_GET_SIZE(tmp);
    4188           0 :                         orelse = asdl_seq_new(len, arena);
    4189           0 :                         if (orelse == NULL) goto failed;
    4190           0 :                         for (i = 0; i < len; i++) {
    4191             :                                 stmt_ty value;
    4192           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4193           0 :                                 if (res != 0) goto failed;
    4194           0 :                                 asdl_seq_SET(orelse, i, value);
    4195             :                         }
    4196           0 :                         Py_XDECREF(tmp);
    4197           0 :                         tmp = NULL;
    4198             :                 } else {
    4199           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
    4200           0 :                         return 1;
    4201             :                 }
    4202           0 :                 *out = For(target, iter, body, orelse, lineno, col_offset,
    4203             :                            arena);
    4204           0 :                 if (*out == NULL) goto failed;
    4205           0 :                 return 0;
    4206             :         }
    4207           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)While_type);
    4208           0 :         if (isinstance == -1) {
    4209           0 :                 return 1;
    4210             :         }
    4211           0 :         if (isinstance) {
    4212             :                 expr_ty test;
    4213             :                 asdl_seq* body;
    4214             :                 asdl_seq* orelse;
    4215             : 
    4216           0 :                 if (_PyObject_HasAttrId(obj, &PyId_test)) {
    4217             :                         int res;
    4218           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_test);
    4219           0 :                         if (tmp == NULL) goto failed;
    4220           0 :                         res = obj2ast_expr(tmp, &test, arena);
    4221           0 :                         if (res != 0) goto failed;
    4222           0 :                         Py_XDECREF(tmp);
    4223           0 :                         tmp = NULL;
    4224             :                 } else {
    4225           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
    4226           0 :                         return 1;
    4227             :                 }
    4228           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    4229             :                         int res;
    4230             :                         Py_ssize_t len;
    4231             :                         Py_ssize_t i;
    4232           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    4233           0 :                         if (tmp == NULL) goto failed;
    4234           0 :                         if (!PyList_Check(tmp)) {
    4235           0 :                                 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4236             :                                 goto failed;
    4237             :                         }
    4238           0 :                         len = PyList_GET_SIZE(tmp);
    4239           0 :                         body = asdl_seq_new(len, arena);
    4240           0 :                         if (body == NULL) goto failed;
    4241           0 :                         for (i = 0; i < len; i++) {
    4242             :                                 stmt_ty value;
    4243           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4244           0 :                                 if (res != 0) goto failed;
    4245           0 :                                 asdl_seq_SET(body, i, value);
    4246             :                         }
    4247           0 :                         Py_XDECREF(tmp);
    4248           0 :                         tmp = NULL;
    4249             :                 } else {
    4250           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
    4251           0 :                         return 1;
    4252             :                 }
    4253           0 :                 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
    4254             :                         int res;
    4255             :                         Py_ssize_t len;
    4256             :                         Py_ssize_t i;
    4257           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
    4258           0 :                         if (tmp == NULL) goto failed;
    4259           0 :                         if (!PyList_Check(tmp)) {
    4260           0 :                                 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4261             :                                 goto failed;
    4262             :                         }
    4263           0 :                         len = PyList_GET_SIZE(tmp);
    4264           0 :                         orelse = asdl_seq_new(len, arena);
    4265           0 :                         if (orelse == NULL) goto failed;
    4266           0 :                         for (i = 0; i < len; i++) {
    4267             :                                 stmt_ty value;
    4268           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4269           0 :                                 if (res != 0) goto failed;
    4270           0 :                                 asdl_seq_SET(orelse, i, value);
    4271             :                         }
    4272           0 :                         Py_XDECREF(tmp);
    4273           0 :                         tmp = NULL;
    4274             :                 } else {
    4275           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
    4276           0 :                         return 1;
    4277             :                 }
    4278           0 :                 *out = While(test, body, orelse, lineno, col_offset, arena);
    4279           0 :                 if (*out == NULL) goto failed;
    4280           0 :                 return 0;
    4281             :         }
    4282           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)If_type);
    4283           0 :         if (isinstance == -1) {
    4284           0 :                 return 1;
    4285             :         }
    4286           0 :         if (isinstance) {
    4287             :                 expr_ty test;
    4288             :                 asdl_seq* body;
    4289             :                 asdl_seq* orelse;
    4290             : 
    4291           0 :                 if (_PyObject_HasAttrId(obj, &PyId_test)) {
    4292             :                         int res;
    4293           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_test);
    4294           0 :                         if (tmp == NULL) goto failed;
    4295           0 :                         res = obj2ast_expr(tmp, &test, arena);
    4296           0 :                         if (res != 0) goto failed;
    4297           0 :                         Py_XDECREF(tmp);
    4298           0 :                         tmp = NULL;
    4299             :                 } else {
    4300           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
    4301           0 :                         return 1;
    4302             :                 }
    4303           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    4304             :                         int res;
    4305             :                         Py_ssize_t len;
    4306             :                         Py_ssize_t i;
    4307           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    4308           0 :                         if (tmp == NULL) goto failed;
    4309           0 :                         if (!PyList_Check(tmp)) {
    4310           0 :                                 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4311             :                                 goto failed;
    4312             :                         }
    4313           0 :                         len = PyList_GET_SIZE(tmp);
    4314           0 :                         body = asdl_seq_new(len, arena);
    4315           0 :                         if (body == NULL) goto failed;
    4316           0 :                         for (i = 0; i < len; i++) {
    4317             :                                 stmt_ty value;
    4318           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4319           0 :                                 if (res != 0) goto failed;
    4320           0 :                                 asdl_seq_SET(body, i, value);
    4321             :                         }
    4322           0 :                         Py_XDECREF(tmp);
    4323           0 :                         tmp = NULL;
    4324             :                 } else {
    4325           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
    4326           0 :                         return 1;
    4327             :                 }
    4328           0 :                 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
    4329             :                         int res;
    4330             :                         Py_ssize_t len;
    4331             :                         Py_ssize_t i;
    4332           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
    4333           0 :                         if (tmp == NULL) goto failed;
    4334           0 :                         if (!PyList_Check(tmp)) {
    4335           0 :                                 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4336             :                                 goto failed;
    4337             :                         }
    4338           0 :                         len = PyList_GET_SIZE(tmp);
    4339           0 :                         orelse = asdl_seq_new(len, arena);
    4340           0 :                         if (orelse == NULL) goto failed;
    4341           0 :                         for (i = 0; i < len; i++) {
    4342             :                                 stmt_ty value;
    4343           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4344           0 :                                 if (res != 0) goto failed;
    4345           0 :                                 asdl_seq_SET(orelse, i, value);
    4346             :                         }
    4347           0 :                         Py_XDECREF(tmp);
    4348           0 :                         tmp = NULL;
    4349             :                 } else {
    4350           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
    4351           0 :                         return 1;
    4352             :                 }
    4353           0 :                 *out = If(test, body, orelse, lineno, col_offset, arena);
    4354           0 :                 if (*out == NULL) goto failed;
    4355           0 :                 return 0;
    4356             :         }
    4357           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)With_type);
    4358           0 :         if (isinstance == -1) {
    4359           0 :                 return 1;
    4360             :         }
    4361           0 :         if (isinstance) {
    4362             :                 asdl_seq* items;
    4363             :                 asdl_seq* body;
    4364             : 
    4365           0 :                 if (_PyObject_HasAttrId(obj, &PyId_items)) {
    4366             :                         int res;
    4367             :                         Py_ssize_t len;
    4368             :                         Py_ssize_t i;
    4369           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_items);
    4370           0 :                         if (tmp == NULL) goto failed;
    4371           0 :                         if (!PyList_Check(tmp)) {
    4372           0 :                                 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4373           0 :                                 goto failed;
    4374             :                         }
    4375           0 :                         len = PyList_GET_SIZE(tmp);
    4376           0 :                         items = asdl_seq_new(len, arena);
    4377           0 :                         if (items == NULL) goto failed;
    4378           0 :                         for (i = 0; i < len; i++) {
    4379             :                                 withitem_ty value;
    4380           0 :                                 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
    4381           0 :                                 if (res != 0) goto failed;
    4382           0 :                                 asdl_seq_SET(items, i, value);
    4383             :                         }
    4384           0 :                         Py_XDECREF(tmp);
    4385           0 :                         tmp = NULL;
    4386             :                 } else {
    4387           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
    4388           0 :                         return 1;
    4389             :                 }
    4390           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    4391             :                         int res;
    4392             :                         Py_ssize_t len;
    4393             :                         Py_ssize_t i;
    4394           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    4395           0 :                         if (tmp == NULL) goto failed;
    4396           0 :                         if (!PyList_Check(tmp)) {
    4397           0 :                                 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4398           0 :                                 goto failed;
    4399             :                         }
    4400           0 :                         len = PyList_GET_SIZE(tmp);
    4401           0 :                         body = asdl_seq_new(len, arena);
    4402           0 :                         if (body == NULL) goto failed;
    4403           0 :                         for (i = 0; i < len; i++) {
    4404             :                                 stmt_ty value;
    4405           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4406           0 :                                 if (res != 0) goto failed;
    4407           0 :                                 asdl_seq_SET(body, i, value);
    4408             :                         }
    4409           0 :                         Py_XDECREF(tmp);
    4410           0 :                         tmp = NULL;
    4411             :                 } else {
    4412           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
    4413           0 :                         return 1;
    4414             :                 }
    4415           0 :                 *out = With(items, body, lineno, col_offset, arena);
    4416           0 :                 if (*out == NULL) goto failed;
    4417           0 :                 return 0;
    4418             :         }
    4419           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type);
    4420           0 :         if (isinstance == -1) {
    4421           0 :                 return 1;
    4422             :         }
    4423           0 :         if (isinstance) {
    4424             :                 expr_ty exc;
    4425             :                 expr_ty cause;
    4426             : 
    4427           0 :                 if (_PyObject_HasAttrId(obj, &PyId_exc)) {
    4428             :                         int res;
    4429           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_exc);
    4430           0 :                         if (tmp == NULL) goto failed;
    4431           0 :                         res = obj2ast_expr(tmp, &exc, arena);
    4432           0 :                         if (res != 0) goto failed;
    4433           0 :                         Py_XDECREF(tmp);
    4434           0 :                         tmp = NULL;
    4435             :                 } else {
    4436           0 :                         exc = NULL;
    4437             :                 }
    4438           0 :                 if (_PyObject_HasAttrId(obj, &PyId_cause)) {
    4439             :                         int res;
    4440           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_cause);
    4441           0 :                         if (tmp == NULL) goto failed;
    4442           0 :                         res = obj2ast_expr(tmp, &cause, arena);
    4443           0 :                         if (res != 0) goto failed;
    4444           0 :                         Py_XDECREF(tmp);
    4445           0 :                         tmp = NULL;
    4446             :                 } else {
    4447           0 :                         cause = NULL;
    4448             :                 }
    4449           0 :                 *out = Raise(exc, cause, lineno, col_offset, arena);
    4450           0 :                 if (*out == NULL) goto failed;
    4451           0 :                 return 0;
    4452             :         }
    4453           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type);
    4454           0 :         if (isinstance == -1) {
    4455           0 :                 return 1;
    4456             :         }
    4457           0 :         if (isinstance) {
    4458             :                 asdl_seq* body;
    4459             :                 asdl_seq* handlers;
    4460             :                 asdl_seq* orelse;
    4461             :                 asdl_seq* finalbody;
    4462             : 
    4463           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    4464             :                         int res;
    4465             :                         Py_ssize_t len;
    4466             :                         Py_ssize_t i;
    4467           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    4468           0 :                         if (tmp == NULL) goto failed;
    4469           0 :                         if (!PyList_Check(tmp)) {
    4470           0 :                                 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4471           0 :                                 goto failed;
    4472             :                         }
    4473           0 :                         len = PyList_GET_SIZE(tmp);
    4474           0 :                         body = asdl_seq_new(len, arena);
    4475           0 :                         if (body == NULL) goto failed;
    4476           0 :                         for (i = 0; i < len; i++) {
    4477             :                                 stmt_ty value;
    4478           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4479           0 :                                 if (res != 0) goto failed;
    4480           0 :                                 asdl_seq_SET(body, i, value);
    4481             :                         }
    4482           0 :                         Py_XDECREF(tmp);
    4483           0 :                         tmp = NULL;
    4484             :                 } else {
    4485           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
    4486           0 :                         return 1;
    4487             :                 }
    4488           0 :                 if (_PyObject_HasAttrId(obj, &PyId_handlers)) {
    4489             :                         int res;
    4490             :                         Py_ssize_t len;
    4491             :                         Py_ssize_t i;
    4492           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_handlers);
    4493           0 :                         if (tmp == NULL) goto failed;
    4494           0 :                         if (!PyList_Check(tmp)) {
    4495           0 :                                 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4496           0 :                                 goto failed;
    4497             :                         }
    4498           0 :                         len = PyList_GET_SIZE(tmp);
    4499           0 :                         handlers = asdl_seq_new(len, arena);
    4500           0 :                         if (handlers == NULL) goto failed;
    4501           0 :                         for (i = 0; i < len; i++) {
    4502             :                                 excepthandler_ty value;
    4503           0 :                                 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena);
    4504           0 :                                 if (res != 0) goto failed;
    4505           0 :                                 asdl_seq_SET(handlers, i, value);
    4506             :                         }
    4507           0 :                         Py_XDECREF(tmp);
    4508           0 :                         tmp = NULL;
    4509             :                 } else {
    4510           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
    4511           0 :                         return 1;
    4512             :                 }
    4513           0 :                 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
    4514             :                         int res;
    4515             :                         Py_ssize_t len;
    4516             :                         Py_ssize_t i;
    4517           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
    4518           0 :                         if (tmp == NULL) goto failed;
    4519           0 :                         if (!PyList_Check(tmp)) {
    4520           0 :                                 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4521           0 :                                 goto failed;
    4522             :                         }
    4523           0 :                         len = PyList_GET_SIZE(tmp);
    4524           0 :                         orelse = asdl_seq_new(len, arena);
    4525           0 :                         if (orelse == NULL) goto failed;
    4526           0 :                         for (i = 0; i < len; i++) {
    4527             :                                 stmt_ty value;
    4528           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4529           0 :                                 if (res != 0) goto failed;
    4530           0 :                                 asdl_seq_SET(orelse, i, value);
    4531             :                         }
    4532           0 :                         Py_XDECREF(tmp);
    4533           0 :                         tmp = NULL;
    4534             :                 } else {
    4535           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
    4536           0 :                         return 1;
    4537             :                 }
    4538           0 :                 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) {
    4539             :                         int res;
    4540             :                         Py_ssize_t len;
    4541             :                         Py_ssize_t i;
    4542           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_finalbody);
    4543           0 :                         if (tmp == NULL) goto failed;
    4544           0 :                         if (!PyList_Check(tmp)) {
    4545           0 :                                 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4546           0 :                                 goto failed;
    4547             :                         }
    4548           0 :                         len = PyList_GET_SIZE(tmp);
    4549           0 :                         finalbody = asdl_seq_new(len, arena);
    4550           0 :                         if (finalbody == NULL) goto failed;
    4551           0 :                         for (i = 0; i < len; i++) {
    4552             :                                 stmt_ty value;
    4553           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    4554           0 :                                 if (res != 0) goto failed;
    4555           0 :                                 asdl_seq_SET(finalbody, i, value);
    4556             :                         }
    4557           0 :                         Py_XDECREF(tmp);
    4558           0 :                         tmp = NULL;
    4559             :                 } else {
    4560           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
    4561           0 :                         return 1;
    4562             :                 }
    4563           0 :                 *out = Try(body, handlers, orelse, finalbody, lineno,
    4564             :                            col_offset, arena);
    4565           0 :                 if (*out == NULL) goto failed;
    4566           0 :                 return 0;
    4567             :         }
    4568           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type);
    4569           0 :         if (isinstance == -1) {
    4570           0 :                 return 1;
    4571             :         }
    4572           0 :         if (isinstance) {
    4573             :                 expr_ty test;
    4574             :                 expr_ty msg;
    4575             : 
    4576           0 :                 if (_PyObject_HasAttrId(obj, &PyId_test)) {
    4577             :                         int res;
    4578           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_test);
    4579           0 :                         if (tmp == NULL) goto failed;
    4580           0 :                         res = obj2ast_expr(tmp, &test, arena);
    4581           0 :                         if (res != 0) goto failed;
    4582           0 :                         Py_XDECREF(tmp);
    4583           0 :                         tmp = NULL;
    4584             :                 } else {
    4585           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
    4586           0 :                         return 1;
    4587             :                 }
    4588           0 :                 if (_PyObject_HasAttrId(obj, &PyId_msg)) {
    4589             :                         int res;
    4590           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_msg);
    4591           0 :                         if (tmp == NULL) goto failed;
    4592           0 :                         res = obj2ast_expr(tmp, &msg, arena);
    4593           0 :                         if (res != 0) goto failed;
    4594           0 :                         Py_XDECREF(tmp);
    4595           0 :                         tmp = NULL;
    4596             :                 } else {
    4597           0 :                         msg = NULL;
    4598             :                 }
    4599           0 :                 *out = Assert(test, msg, lineno, col_offset, arena);
    4600           0 :                 if (*out == NULL) goto failed;
    4601           0 :                 return 0;
    4602             :         }
    4603           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type);
    4604           0 :         if (isinstance == -1) {
    4605           0 :                 return 1;
    4606             :         }
    4607           0 :         if (isinstance) {
    4608             :                 asdl_seq* names;
    4609             : 
    4610           0 :                 if (_PyObject_HasAttrId(obj, &PyId_names)) {
    4611             :                         int res;
    4612             :                         Py_ssize_t len;
    4613             :                         Py_ssize_t i;
    4614           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_names);
    4615           0 :                         if (tmp == NULL) goto failed;
    4616           0 :                         if (!PyList_Check(tmp)) {
    4617           0 :                                 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4618           0 :                                 goto failed;
    4619             :                         }
    4620           0 :                         len = PyList_GET_SIZE(tmp);
    4621           0 :                         names = asdl_seq_new(len, arena);
    4622           0 :                         if (names == NULL) goto failed;
    4623           0 :                         for (i = 0; i < len; i++) {
    4624             :                                 alias_ty value;
    4625           0 :                                 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
    4626           0 :                                 if (res != 0) goto failed;
    4627           0 :                                 asdl_seq_SET(names, i, value);
    4628             :                         }
    4629           0 :                         Py_XDECREF(tmp);
    4630           0 :                         tmp = NULL;
    4631             :                 } else {
    4632           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
    4633           0 :                         return 1;
    4634             :                 }
    4635           0 :                 *out = Import(names, lineno, col_offset, arena);
    4636           0 :                 if (*out == NULL) goto failed;
    4637           0 :                 return 0;
    4638             :         }
    4639           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type);
    4640           0 :         if (isinstance == -1) {
    4641           0 :                 return 1;
    4642             :         }
    4643           0 :         if (isinstance) {
    4644             :                 identifier module;
    4645             :                 asdl_seq* names;
    4646             :                 int level;
    4647             : 
    4648           0 :                 if (_PyObject_HasAttrId(obj, &PyId_module)) {
    4649             :                         int res;
    4650           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_module);
    4651           0 :                         if (tmp == NULL) goto failed;
    4652           0 :                         res = obj2ast_identifier(tmp, &module, arena);
    4653           0 :                         if (res != 0) goto failed;
    4654           0 :                         Py_XDECREF(tmp);
    4655           0 :                         tmp = NULL;
    4656             :                 } else {
    4657           0 :                         module = NULL;
    4658             :                 }
    4659           0 :                 if (_PyObject_HasAttrId(obj, &PyId_names)) {
    4660             :                         int res;
    4661             :                         Py_ssize_t len;
    4662             :                         Py_ssize_t i;
    4663           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_names);
    4664           0 :                         if (tmp == NULL) goto failed;
    4665           0 :                         if (!PyList_Check(tmp)) {
    4666           0 :                                 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4667             :                                 goto failed;
    4668             :                         }
    4669           0 :                         len = PyList_GET_SIZE(tmp);
    4670           0 :                         names = asdl_seq_new(len, arena);
    4671           0 :                         if (names == NULL) goto failed;
    4672           0 :                         for (i = 0; i < len; i++) {
    4673             :                                 alias_ty value;
    4674           0 :                                 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
    4675           0 :                                 if (res != 0) goto failed;
    4676           0 :                                 asdl_seq_SET(names, i, value);
    4677             :                         }
    4678           0 :                         Py_XDECREF(tmp);
    4679           0 :                         tmp = NULL;
    4680             :                 } else {
    4681           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
    4682           0 :                         return 1;
    4683             :                 }
    4684           0 :                 if (_PyObject_HasAttrId(obj, &PyId_level)) {
    4685             :                         int res;
    4686           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_level);
    4687           0 :                         if (tmp == NULL) goto failed;
    4688           0 :                         res = obj2ast_int(tmp, &level, arena);
    4689           0 :                         if (res != 0) goto failed;
    4690           0 :                         Py_XDECREF(tmp);
    4691           0 :                         tmp = NULL;
    4692             :                 } else {
    4693           0 :                         level = 0;
    4694             :                 }
    4695           0 :                 *out = ImportFrom(module, names, level, lineno, col_offset,
    4696             :                                   arena);
    4697           0 :                 if (*out == NULL) goto failed;
    4698           0 :                 return 0;
    4699             :         }
    4700           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type);
    4701           0 :         if (isinstance == -1) {
    4702           0 :                 return 1;
    4703             :         }
    4704           0 :         if (isinstance) {
    4705             :                 asdl_seq* names;
    4706             : 
    4707           0 :                 if (_PyObject_HasAttrId(obj, &PyId_names)) {
    4708             :                         int res;
    4709             :                         Py_ssize_t len;
    4710             :                         Py_ssize_t i;
    4711           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_names);
    4712           0 :                         if (tmp == NULL) goto failed;
    4713           0 :                         if (!PyList_Check(tmp)) {
    4714           0 :                                 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4715           0 :                                 goto failed;
    4716             :                         }
    4717           0 :                         len = PyList_GET_SIZE(tmp);
    4718           0 :                         names = asdl_seq_new(len, arena);
    4719           0 :                         if (names == NULL) goto failed;
    4720           0 :                         for (i = 0; i < len; i++) {
    4721             :                                 identifier value;
    4722           0 :                                 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
    4723           0 :                                 if (res != 0) goto failed;
    4724           0 :                                 asdl_seq_SET(names, i, value);
    4725             :                         }
    4726           0 :                         Py_XDECREF(tmp);
    4727           0 :                         tmp = NULL;
    4728             :                 } else {
    4729           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
    4730           0 :                         return 1;
    4731             :                 }
    4732           0 :                 *out = Global(names, lineno, col_offset, arena);
    4733           0 :                 if (*out == NULL) goto failed;
    4734           0 :                 return 0;
    4735             :         }
    4736           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type);
    4737           0 :         if (isinstance == -1) {
    4738           0 :                 return 1;
    4739             :         }
    4740           0 :         if (isinstance) {
    4741             :                 asdl_seq* names;
    4742             : 
    4743           0 :                 if (_PyObject_HasAttrId(obj, &PyId_names)) {
    4744             :                         int res;
    4745             :                         Py_ssize_t len;
    4746             :                         Py_ssize_t i;
    4747           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_names);
    4748           0 :                         if (tmp == NULL) goto failed;
    4749           0 :                         if (!PyList_Check(tmp)) {
    4750           0 :                                 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4751           0 :                                 goto failed;
    4752             :                         }
    4753           0 :                         len = PyList_GET_SIZE(tmp);
    4754           0 :                         names = asdl_seq_new(len, arena);
    4755           0 :                         if (names == NULL) goto failed;
    4756           0 :                         for (i = 0; i < len; i++) {
    4757             :                                 identifier value;
    4758           0 :                                 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
    4759           0 :                                 if (res != 0) goto failed;
    4760           0 :                                 asdl_seq_SET(names, i, value);
    4761             :                         }
    4762           0 :                         Py_XDECREF(tmp);
    4763           0 :                         tmp = NULL;
    4764             :                 } else {
    4765           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
    4766           0 :                         return 1;
    4767             :                 }
    4768           0 :                 *out = Nonlocal(names, lineno, col_offset, arena);
    4769           0 :                 if (*out == NULL) goto failed;
    4770           0 :                 return 0;
    4771             :         }
    4772           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type);
    4773           0 :         if (isinstance == -1) {
    4774           0 :                 return 1;
    4775             :         }
    4776           0 :         if (isinstance) {
    4777             :                 expr_ty value;
    4778             : 
    4779           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    4780             :                         int res;
    4781           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    4782           0 :                         if (tmp == NULL) goto failed;
    4783           0 :                         res = obj2ast_expr(tmp, &value, arena);
    4784           0 :                         if (res != 0) goto failed;
    4785           0 :                         Py_XDECREF(tmp);
    4786           0 :                         tmp = NULL;
    4787             :                 } else {
    4788           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
    4789           0 :                         return 1;
    4790             :                 }
    4791           0 :                 *out = Expr(value, lineno, col_offset, arena);
    4792           0 :                 if (*out == NULL) goto failed;
    4793           0 :                 return 0;
    4794             :         }
    4795           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type);
    4796           0 :         if (isinstance == -1) {
    4797           0 :                 return 1;
    4798             :         }
    4799           0 :         if (isinstance) {
    4800             : 
    4801           0 :                 *out = Pass(lineno, col_offset, arena);
    4802           0 :                 if (*out == NULL) goto failed;
    4803           0 :                 return 0;
    4804             :         }
    4805           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type);
    4806           0 :         if (isinstance == -1) {
    4807           0 :                 return 1;
    4808             :         }
    4809           0 :         if (isinstance) {
    4810             : 
    4811           0 :                 *out = Break(lineno, col_offset, arena);
    4812           0 :                 if (*out == NULL) goto failed;
    4813           0 :                 return 0;
    4814             :         }
    4815           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type);
    4816           0 :         if (isinstance == -1) {
    4817           0 :                 return 1;
    4818             :         }
    4819           0 :         if (isinstance) {
    4820             : 
    4821           0 :                 *out = Continue(lineno, col_offset, arena);
    4822           0 :                 if (*out == NULL) goto failed;
    4823           0 :                 return 0;
    4824             :         }
    4825             : 
    4826           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
    4827             :         failed:
    4828           0 :         Py_XDECREF(tmp);
    4829           0 :         return 1;
    4830             : }
    4831             : 
    4832             : int
    4833           0 : obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
    4834             : {
    4835             :         int isinstance;
    4836             : 
    4837           0 :         PyObject *tmp = NULL;
    4838             :         int lineno;
    4839             :         int col_offset;
    4840             : 
    4841           0 :         if (obj == Py_None) {
    4842           0 :                 *out = NULL;
    4843           0 :                 return 0;
    4844             :         }
    4845           0 :         if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
    4846             :                 int res;
    4847           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
    4848           0 :                 if (tmp == NULL) goto failed;
    4849           0 :                 res = obj2ast_int(tmp, &lineno, arena);
    4850           0 :                 if (res != 0) goto failed;
    4851           0 :                 Py_XDECREF(tmp);
    4852           0 :                 tmp = NULL;
    4853             :         } else {
    4854           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
    4855           0 :                 return 1;
    4856             :         }
    4857           0 :         if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
    4858             :                 int res;
    4859           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
    4860           0 :                 if (tmp == NULL) goto failed;
    4861           0 :                 res = obj2ast_int(tmp, &col_offset, arena);
    4862           0 :                 if (res != 0) goto failed;
    4863           0 :                 Py_XDECREF(tmp);
    4864           0 :                 tmp = NULL;
    4865             :         } else {
    4866           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
    4867           0 :                 return 1;
    4868             :         }
    4869           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type);
    4870           0 :         if (isinstance == -1) {
    4871           0 :                 return 1;
    4872             :         }
    4873           0 :         if (isinstance) {
    4874             :                 boolop_ty op;
    4875             :                 asdl_seq* values;
    4876             : 
    4877           0 :                 if (_PyObject_HasAttrId(obj, &PyId_op)) {
    4878             :                         int res;
    4879           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_op);
    4880           0 :                         if (tmp == NULL) goto failed;
    4881           0 :                         res = obj2ast_boolop(tmp, &op, arena);
    4882           0 :                         if (res != 0) goto failed;
    4883           0 :                         Py_XDECREF(tmp);
    4884           0 :                         tmp = NULL;
    4885             :                 } else {
    4886           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
    4887           0 :                         return 1;
    4888             :                 }
    4889           0 :                 if (_PyObject_HasAttrId(obj, &PyId_values)) {
    4890             :                         int res;
    4891             :                         Py_ssize_t len;
    4892             :                         Py_ssize_t i;
    4893           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_values);
    4894           0 :                         if (tmp == NULL) goto failed;
    4895           0 :                         if (!PyList_Check(tmp)) {
    4896           0 :                                 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    4897             :                                 goto failed;
    4898             :                         }
    4899           0 :                         len = PyList_GET_SIZE(tmp);
    4900           0 :                         values = asdl_seq_new(len, arena);
    4901           0 :                         if (values == NULL) goto failed;
    4902           0 :                         for (i = 0; i < len; i++) {
    4903             :                                 expr_ty value;
    4904           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    4905           0 :                                 if (res != 0) goto failed;
    4906           0 :                                 asdl_seq_SET(values, i, value);
    4907             :                         }
    4908           0 :                         Py_XDECREF(tmp);
    4909           0 :                         tmp = NULL;
    4910             :                 } else {
    4911           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
    4912           0 :                         return 1;
    4913             :                 }
    4914           0 :                 *out = BoolOp(op, values, lineno, col_offset, arena);
    4915           0 :                 if (*out == NULL) goto failed;
    4916           0 :                 return 0;
    4917             :         }
    4918           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type);
    4919           0 :         if (isinstance == -1) {
    4920           0 :                 return 1;
    4921             :         }
    4922           0 :         if (isinstance) {
    4923             :                 expr_ty left;
    4924             :                 operator_ty op;
    4925             :                 expr_ty right;
    4926             : 
    4927           0 :                 if (_PyObject_HasAttrId(obj, &PyId_left)) {
    4928             :                         int res;
    4929           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_left);
    4930           0 :                         if (tmp == NULL) goto failed;
    4931           0 :                         res = obj2ast_expr(tmp, &left, arena);
    4932           0 :                         if (res != 0) goto failed;
    4933           0 :                         Py_XDECREF(tmp);
    4934           0 :                         tmp = NULL;
    4935             :                 } else {
    4936           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
    4937           0 :                         return 1;
    4938             :                 }
    4939           0 :                 if (_PyObject_HasAttrId(obj, &PyId_op)) {
    4940             :                         int res;
    4941           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_op);
    4942           0 :                         if (tmp == NULL) goto failed;
    4943           0 :                         res = obj2ast_operator(tmp, &op, arena);
    4944           0 :                         if (res != 0) goto failed;
    4945           0 :                         Py_XDECREF(tmp);
    4946           0 :                         tmp = NULL;
    4947             :                 } else {
    4948           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
    4949           0 :                         return 1;
    4950             :                 }
    4951           0 :                 if (_PyObject_HasAttrId(obj, &PyId_right)) {
    4952             :                         int res;
    4953           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_right);
    4954           0 :                         if (tmp == NULL) goto failed;
    4955           0 :                         res = obj2ast_expr(tmp, &right, arena);
    4956           0 :                         if (res != 0) goto failed;
    4957           0 :                         Py_XDECREF(tmp);
    4958           0 :                         tmp = NULL;
    4959             :                 } else {
    4960           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
    4961           0 :                         return 1;
    4962             :                 }
    4963           0 :                 *out = BinOp(left, op, right, lineno, col_offset, arena);
    4964           0 :                 if (*out == NULL) goto failed;
    4965           0 :                 return 0;
    4966             :         }
    4967           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type);
    4968           0 :         if (isinstance == -1) {
    4969           0 :                 return 1;
    4970             :         }
    4971           0 :         if (isinstance) {
    4972             :                 unaryop_ty op;
    4973             :                 expr_ty operand;
    4974             : 
    4975           0 :                 if (_PyObject_HasAttrId(obj, &PyId_op)) {
    4976             :                         int res;
    4977           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_op);
    4978           0 :                         if (tmp == NULL) goto failed;
    4979           0 :                         res = obj2ast_unaryop(tmp, &op, arena);
    4980           0 :                         if (res != 0) goto failed;
    4981           0 :                         Py_XDECREF(tmp);
    4982           0 :                         tmp = NULL;
    4983             :                 } else {
    4984           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
    4985           0 :                         return 1;
    4986             :                 }
    4987           0 :                 if (_PyObject_HasAttrId(obj, &PyId_operand)) {
    4988             :                         int res;
    4989           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_operand);
    4990           0 :                         if (tmp == NULL) goto failed;
    4991           0 :                         res = obj2ast_expr(tmp, &operand, arena);
    4992           0 :                         if (res != 0) goto failed;
    4993           0 :                         Py_XDECREF(tmp);
    4994           0 :                         tmp = NULL;
    4995             :                 } else {
    4996           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
    4997           0 :                         return 1;
    4998             :                 }
    4999           0 :                 *out = UnaryOp(op, operand, lineno, col_offset, arena);
    5000           0 :                 if (*out == NULL) goto failed;
    5001           0 :                 return 0;
    5002             :         }
    5003           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type);
    5004           0 :         if (isinstance == -1) {
    5005           0 :                 return 1;
    5006             :         }
    5007           0 :         if (isinstance) {
    5008             :                 arguments_ty args;
    5009             :                 expr_ty body;
    5010             : 
    5011           0 :                 if (_PyObject_HasAttrId(obj, &PyId_args)) {
    5012             :                         int res;
    5013           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_args);
    5014           0 :                         if (tmp == NULL) goto failed;
    5015           0 :                         res = obj2ast_arguments(tmp, &args, arena);
    5016           0 :                         if (res != 0) goto failed;
    5017           0 :                         Py_XDECREF(tmp);
    5018           0 :                         tmp = NULL;
    5019             :                 } else {
    5020           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
    5021           0 :                         return 1;
    5022             :                 }
    5023           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    5024             :                         int res;
    5025           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    5026           0 :                         if (tmp == NULL) goto failed;
    5027           0 :                         res = obj2ast_expr(tmp, &body, arena);
    5028           0 :                         if (res != 0) goto failed;
    5029           0 :                         Py_XDECREF(tmp);
    5030           0 :                         tmp = NULL;
    5031             :                 } else {
    5032           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
    5033           0 :                         return 1;
    5034             :                 }
    5035           0 :                 *out = Lambda(args, body, lineno, col_offset, arena);
    5036           0 :                 if (*out == NULL) goto failed;
    5037           0 :                 return 0;
    5038             :         }
    5039           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type);
    5040           0 :         if (isinstance == -1) {
    5041           0 :                 return 1;
    5042             :         }
    5043           0 :         if (isinstance) {
    5044             :                 expr_ty test;
    5045             :                 expr_ty body;
    5046             :                 expr_ty orelse;
    5047             : 
    5048           0 :                 if (_PyObject_HasAttrId(obj, &PyId_test)) {
    5049             :                         int res;
    5050           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_test);
    5051           0 :                         if (tmp == NULL) goto failed;
    5052           0 :                         res = obj2ast_expr(tmp, &test, arena);
    5053           0 :                         if (res != 0) goto failed;
    5054           0 :                         Py_XDECREF(tmp);
    5055           0 :                         tmp = NULL;
    5056             :                 } else {
    5057           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
    5058           0 :                         return 1;
    5059             :                 }
    5060           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    5061             :                         int res;
    5062           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    5063           0 :                         if (tmp == NULL) goto failed;
    5064           0 :                         res = obj2ast_expr(tmp, &body, arena);
    5065           0 :                         if (res != 0) goto failed;
    5066           0 :                         Py_XDECREF(tmp);
    5067           0 :                         tmp = NULL;
    5068             :                 } else {
    5069           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
    5070           0 :                         return 1;
    5071             :                 }
    5072           0 :                 if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
    5073             :                         int res;
    5074           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
    5075           0 :                         if (tmp == NULL) goto failed;
    5076           0 :                         res = obj2ast_expr(tmp, &orelse, arena);
    5077           0 :                         if (res != 0) goto failed;
    5078           0 :                         Py_XDECREF(tmp);
    5079           0 :                         tmp = NULL;
    5080             :                 } else {
    5081           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
    5082           0 :                         return 1;
    5083             :                 }
    5084           0 :                 *out = IfExp(test, body, orelse, lineno, col_offset, arena);
    5085           0 :                 if (*out == NULL) goto failed;
    5086           0 :                 return 0;
    5087             :         }
    5088           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type);
    5089           0 :         if (isinstance == -1) {
    5090           0 :                 return 1;
    5091             :         }
    5092           0 :         if (isinstance) {
    5093             :                 asdl_seq* keys;
    5094             :                 asdl_seq* values;
    5095             : 
    5096           0 :                 if (_PyObject_HasAttrId(obj, &PyId_keys)) {
    5097             :                         int res;
    5098             :                         Py_ssize_t len;
    5099             :                         Py_ssize_t i;
    5100           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_keys);
    5101           0 :                         if (tmp == NULL) goto failed;
    5102           0 :                         if (!PyList_Check(tmp)) {
    5103           0 :                                 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5104           0 :                                 goto failed;
    5105             :                         }
    5106           0 :                         len = PyList_GET_SIZE(tmp);
    5107           0 :                         keys = asdl_seq_new(len, arena);
    5108           0 :                         if (keys == NULL) goto failed;
    5109           0 :                         for (i = 0; i < len; i++) {
    5110             :                                 expr_ty value;
    5111           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5112           0 :                                 if (res != 0) goto failed;
    5113           0 :                                 asdl_seq_SET(keys, i, value);
    5114             :                         }
    5115           0 :                         Py_XDECREF(tmp);
    5116           0 :                         tmp = NULL;
    5117             :                 } else {
    5118           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
    5119           0 :                         return 1;
    5120             :                 }
    5121           0 :                 if (_PyObject_HasAttrId(obj, &PyId_values)) {
    5122             :                         int res;
    5123             :                         Py_ssize_t len;
    5124             :                         Py_ssize_t i;
    5125           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_values);
    5126           0 :                         if (tmp == NULL) goto failed;
    5127           0 :                         if (!PyList_Check(tmp)) {
    5128           0 :                                 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5129           0 :                                 goto failed;
    5130             :                         }
    5131           0 :                         len = PyList_GET_SIZE(tmp);
    5132           0 :                         values = asdl_seq_new(len, arena);
    5133           0 :                         if (values == NULL) goto failed;
    5134           0 :                         for (i = 0; i < len; i++) {
    5135             :                                 expr_ty value;
    5136           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5137           0 :                                 if (res != 0) goto failed;
    5138           0 :                                 asdl_seq_SET(values, i, value);
    5139             :                         }
    5140           0 :                         Py_XDECREF(tmp);
    5141           0 :                         tmp = NULL;
    5142             :                 } else {
    5143           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
    5144           0 :                         return 1;
    5145             :                 }
    5146           0 :                 *out = Dict(keys, values, lineno, col_offset, arena);
    5147           0 :                 if (*out == NULL) goto failed;
    5148           0 :                 return 0;
    5149             :         }
    5150           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type);
    5151           0 :         if (isinstance == -1) {
    5152           0 :                 return 1;
    5153             :         }
    5154           0 :         if (isinstance) {
    5155             :                 asdl_seq* elts;
    5156             : 
    5157           0 :                 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
    5158             :                         int res;
    5159             :                         Py_ssize_t len;
    5160             :                         Py_ssize_t i;
    5161           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_elts);
    5162           0 :                         if (tmp == NULL) goto failed;
    5163           0 :                         if (!PyList_Check(tmp)) {
    5164           0 :                                 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5165           0 :                                 goto failed;
    5166             :                         }
    5167           0 :                         len = PyList_GET_SIZE(tmp);
    5168           0 :                         elts = asdl_seq_new(len, arena);
    5169           0 :                         if (elts == NULL) goto failed;
    5170           0 :                         for (i = 0; i < len; i++) {
    5171             :                                 expr_ty value;
    5172           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5173           0 :                                 if (res != 0) goto failed;
    5174           0 :                                 asdl_seq_SET(elts, i, value);
    5175             :                         }
    5176           0 :                         Py_XDECREF(tmp);
    5177           0 :                         tmp = NULL;
    5178             :                 } else {
    5179           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
    5180           0 :                         return 1;
    5181             :                 }
    5182           0 :                 *out = Set(elts, lineno, col_offset, arena);
    5183           0 :                 if (*out == NULL) goto failed;
    5184           0 :                 return 0;
    5185             :         }
    5186           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type);
    5187           0 :         if (isinstance == -1) {
    5188           0 :                 return 1;
    5189             :         }
    5190           0 :         if (isinstance) {
    5191             :                 expr_ty elt;
    5192             :                 asdl_seq* generators;
    5193             : 
    5194           0 :                 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
    5195             :                         int res;
    5196           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_elt);
    5197           0 :                         if (tmp == NULL) goto failed;
    5198           0 :                         res = obj2ast_expr(tmp, &elt, arena);
    5199           0 :                         if (res != 0) goto failed;
    5200           0 :                         Py_XDECREF(tmp);
    5201           0 :                         tmp = NULL;
    5202             :                 } else {
    5203           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
    5204           0 :                         return 1;
    5205             :                 }
    5206           0 :                 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
    5207             :                         int res;
    5208             :                         Py_ssize_t len;
    5209             :                         Py_ssize_t i;
    5210           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_generators);
    5211           0 :                         if (tmp == NULL) goto failed;
    5212           0 :                         if (!PyList_Check(tmp)) {
    5213           0 :                                 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5214             :                                 goto failed;
    5215             :                         }
    5216           0 :                         len = PyList_GET_SIZE(tmp);
    5217           0 :                         generators = asdl_seq_new(len, arena);
    5218           0 :                         if (generators == NULL) goto failed;
    5219           0 :                         for (i = 0; i < len; i++) {
    5220             :                                 comprehension_ty value;
    5221           0 :                                 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
    5222           0 :                                 if (res != 0) goto failed;
    5223           0 :                                 asdl_seq_SET(generators, i, value);
    5224             :                         }
    5225           0 :                         Py_XDECREF(tmp);
    5226           0 :                         tmp = NULL;
    5227             :                 } else {
    5228           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
    5229           0 :                         return 1;
    5230             :                 }
    5231           0 :                 *out = ListComp(elt, generators, lineno, col_offset, arena);
    5232           0 :                 if (*out == NULL) goto failed;
    5233           0 :                 return 0;
    5234             :         }
    5235           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type);
    5236           0 :         if (isinstance == -1) {
    5237           0 :                 return 1;
    5238             :         }
    5239           0 :         if (isinstance) {
    5240             :                 expr_ty elt;
    5241             :                 asdl_seq* generators;
    5242             : 
    5243           0 :                 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
    5244             :                         int res;
    5245           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_elt);
    5246           0 :                         if (tmp == NULL) goto failed;
    5247           0 :                         res = obj2ast_expr(tmp, &elt, arena);
    5248           0 :                         if (res != 0) goto failed;
    5249           0 :                         Py_XDECREF(tmp);
    5250           0 :                         tmp = NULL;
    5251             :                 } else {
    5252           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
    5253           0 :                         return 1;
    5254             :                 }
    5255           0 :                 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
    5256             :                         int res;
    5257             :                         Py_ssize_t len;
    5258             :                         Py_ssize_t i;
    5259           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_generators);
    5260           0 :                         if (tmp == NULL) goto failed;
    5261           0 :                         if (!PyList_Check(tmp)) {
    5262           0 :                                 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5263             :                                 goto failed;
    5264             :                         }
    5265           0 :                         len = PyList_GET_SIZE(tmp);
    5266           0 :                         generators = asdl_seq_new(len, arena);
    5267           0 :                         if (generators == NULL) goto failed;
    5268           0 :                         for (i = 0; i < len; i++) {
    5269             :                                 comprehension_ty value;
    5270           0 :                                 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
    5271           0 :                                 if (res != 0) goto failed;
    5272           0 :                                 asdl_seq_SET(generators, i, value);
    5273             :                         }
    5274           0 :                         Py_XDECREF(tmp);
    5275           0 :                         tmp = NULL;
    5276             :                 } else {
    5277           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
    5278           0 :                         return 1;
    5279             :                 }
    5280           0 :                 *out = SetComp(elt, generators, lineno, col_offset, arena);
    5281           0 :                 if (*out == NULL) goto failed;
    5282           0 :                 return 0;
    5283             :         }
    5284           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type);
    5285           0 :         if (isinstance == -1) {
    5286           0 :                 return 1;
    5287             :         }
    5288           0 :         if (isinstance) {
    5289             :                 expr_ty key;
    5290             :                 expr_ty value;
    5291             :                 asdl_seq* generators;
    5292             : 
    5293           0 :                 if (_PyObject_HasAttrId(obj, &PyId_key)) {
    5294             :                         int res;
    5295           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_key);
    5296           0 :                         if (tmp == NULL) goto failed;
    5297           0 :                         res = obj2ast_expr(tmp, &key, arena);
    5298           0 :                         if (res != 0) goto failed;
    5299           0 :                         Py_XDECREF(tmp);
    5300           0 :                         tmp = NULL;
    5301             :                 } else {
    5302           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
    5303           0 :                         return 1;
    5304             :                 }
    5305           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    5306             :                         int res;
    5307           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    5308           0 :                         if (tmp == NULL) goto failed;
    5309           0 :                         res = obj2ast_expr(tmp, &value, arena);
    5310           0 :                         if (res != 0) goto failed;
    5311           0 :                         Py_XDECREF(tmp);
    5312           0 :                         tmp = NULL;
    5313             :                 } else {
    5314           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
    5315           0 :                         return 1;
    5316             :                 }
    5317           0 :                 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
    5318             :                         int res;
    5319             :                         Py_ssize_t len;
    5320             :                         Py_ssize_t i;
    5321           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_generators);
    5322           0 :                         if (tmp == NULL) goto failed;
    5323           0 :                         if (!PyList_Check(tmp)) {
    5324           0 :                                 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5325             :                                 goto failed;
    5326             :                         }
    5327           0 :                         len = PyList_GET_SIZE(tmp);
    5328           0 :                         generators = asdl_seq_new(len, arena);
    5329           0 :                         if (generators == NULL) goto failed;
    5330           0 :                         for (i = 0; i < len; i++) {
    5331             :                                 comprehension_ty value;
    5332           0 :                                 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
    5333           0 :                                 if (res != 0) goto failed;
    5334           0 :                                 asdl_seq_SET(generators, i, value);
    5335             :                         }
    5336           0 :                         Py_XDECREF(tmp);
    5337           0 :                         tmp = NULL;
    5338             :                 } else {
    5339           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
    5340           0 :                         return 1;
    5341             :                 }
    5342           0 :                 *out = DictComp(key, value, generators, lineno, col_offset,
    5343             :                                 arena);
    5344           0 :                 if (*out == NULL) goto failed;
    5345           0 :                 return 0;
    5346             :         }
    5347           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type);
    5348           0 :         if (isinstance == -1) {
    5349           0 :                 return 1;
    5350             :         }
    5351           0 :         if (isinstance) {
    5352             :                 expr_ty elt;
    5353             :                 asdl_seq* generators;
    5354             : 
    5355           0 :                 if (_PyObject_HasAttrId(obj, &PyId_elt)) {
    5356             :                         int res;
    5357           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_elt);
    5358           0 :                         if (tmp == NULL) goto failed;
    5359           0 :                         res = obj2ast_expr(tmp, &elt, arena);
    5360           0 :                         if (res != 0) goto failed;
    5361           0 :                         Py_XDECREF(tmp);
    5362           0 :                         tmp = NULL;
    5363             :                 } else {
    5364           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
    5365           0 :                         return 1;
    5366             :                 }
    5367           0 :                 if (_PyObject_HasAttrId(obj, &PyId_generators)) {
    5368             :                         int res;
    5369             :                         Py_ssize_t len;
    5370             :                         Py_ssize_t i;
    5371           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_generators);
    5372           0 :                         if (tmp == NULL) goto failed;
    5373           0 :                         if (!PyList_Check(tmp)) {
    5374           0 :                                 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5375             :                                 goto failed;
    5376             :                         }
    5377           0 :                         len = PyList_GET_SIZE(tmp);
    5378           0 :                         generators = asdl_seq_new(len, arena);
    5379           0 :                         if (generators == NULL) goto failed;
    5380           0 :                         for (i = 0; i < len; i++) {
    5381             :                                 comprehension_ty value;
    5382           0 :                                 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
    5383           0 :                                 if (res != 0) goto failed;
    5384           0 :                                 asdl_seq_SET(generators, i, value);
    5385             :                         }
    5386           0 :                         Py_XDECREF(tmp);
    5387           0 :                         tmp = NULL;
    5388             :                 } else {
    5389           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
    5390           0 :                         return 1;
    5391             :                 }
    5392           0 :                 *out = GeneratorExp(elt, generators, lineno, col_offset, arena);
    5393           0 :                 if (*out == NULL) goto failed;
    5394           0 :                 return 0;
    5395             :         }
    5396           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type);
    5397           0 :         if (isinstance == -1) {
    5398           0 :                 return 1;
    5399             :         }
    5400           0 :         if (isinstance) {
    5401             :                 expr_ty value;
    5402             : 
    5403           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    5404             :                         int res;
    5405           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    5406           0 :                         if (tmp == NULL) goto failed;
    5407           0 :                         res = obj2ast_expr(tmp, &value, arena);
    5408           0 :                         if (res != 0) goto failed;
    5409           0 :                         Py_XDECREF(tmp);
    5410           0 :                         tmp = NULL;
    5411             :                 } else {
    5412           0 :                         value = NULL;
    5413             :                 }
    5414           0 :                 *out = Yield(value, lineno, col_offset, arena);
    5415           0 :                 if (*out == NULL) goto failed;
    5416           0 :                 return 0;
    5417             :         }
    5418           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type);
    5419           0 :         if (isinstance == -1) {
    5420           0 :                 return 1;
    5421             :         }
    5422           0 :         if (isinstance) {
    5423             :                 expr_ty value;
    5424             : 
    5425           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    5426             :                         int res;
    5427           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    5428           0 :                         if (tmp == NULL) goto failed;
    5429           0 :                         res = obj2ast_expr(tmp, &value, arena);
    5430           0 :                         if (res != 0) goto failed;
    5431           0 :                         Py_XDECREF(tmp);
    5432           0 :                         tmp = NULL;
    5433             :                 } else {
    5434           0 :                         value = NULL;
    5435             :                 }
    5436           0 :                 *out = YieldFrom(value, lineno, col_offset, arena);
    5437           0 :                 if (*out == NULL) goto failed;
    5438           0 :                 return 0;
    5439             :         }
    5440           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type);
    5441           0 :         if (isinstance == -1) {
    5442           0 :                 return 1;
    5443             :         }
    5444           0 :         if (isinstance) {
    5445             :                 expr_ty left;
    5446             :                 asdl_int_seq* ops;
    5447             :                 asdl_seq* comparators;
    5448             : 
    5449           0 :                 if (_PyObject_HasAttrId(obj, &PyId_left)) {
    5450             :                         int res;
    5451           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_left);
    5452           0 :                         if (tmp == NULL) goto failed;
    5453           0 :                         res = obj2ast_expr(tmp, &left, arena);
    5454           0 :                         if (res != 0) goto failed;
    5455           0 :                         Py_XDECREF(tmp);
    5456           0 :                         tmp = NULL;
    5457             :                 } else {
    5458           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
    5459           0 :                         return 1;
    5460             :                 }
    5461           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ops)) {
    5462             :                         int res;
    5463             :                         Py_ssize_t len;
    5464             :                         Py_ssize_t i;
    5465           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ops);
    5466           0 :                         if (tmp == NULL) goto failed;
    5467           0 :                         if (!PyList_Check(tmp)) {
    5468           0 :                                 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5469             :                                 goto failed;
    5470             :                         }
    5471           0 :                         len = PyList_GET_SIZE(tmp);
    5472           0 :                         ops = asdl_int_seq_new(len, arena);
    5473           0 :                         if (ops == NULL) goto failed;
    5474           0 :                         for (i = 0; i < len; i++) {
    5475             :                                 cmpop_ty value;
    5476           0 :                                 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena);
    5477           0 :                                 if (res != 0) goto failed;
    5478           0 :                                 asdl_seq_SET(ops, i, value);
    5479             :                         }
    5480           0 :                         Py_XDECREF(tmp);
    5481           0 :                         tmp = NULL;
    5482             :                 } else {
    5483           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
    5484           0 :                         return 1;
    5485             :                 }
    5486           0 :                 if (_PyObject_HasAttrId(obj, &PyId_comparators)) {
    5487             :                         int res;
    5488             :                         Py_ssize_t len;
    5489             :                         Py_ssize_t i;
    5490           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_comparators);
    5491           0 :                         if (tmp == NULL) goto failed;
    5492           0 :                         if (!PyList_Check(tmp)) {
    5493           0 :                                 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5494             :                                 goto failed;
    5495             :                         }
    5496           0 :                         len = PyList_GET_SIZE(tmp);
    5497           0 :                         comparators = asdl_seq_new(len, arena);
    5498           0 :                         if (comparators == NULL) goto failed;
    5499           0 :                         for (i = 0; i < len; i++) {
    5500             :                                 expr_ty value;
    5501           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5502           0 :                                 if (res != 0) goto failed;
    5503           0 :                                 asdl_seq_SET(comparators, i, value);
    5504             :                         }
    5505           0 :                         Py_XDECREF(tmp);
    5506           0 :                         tmp = NULL;
    5507             :                 } else {
    5508           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
    5509           0 :                         return 1;
    5510             :                 }
    5511           0 :                 *out = Compare(left, ops, comparators, lineno, col_offset,
    5512             :                                arena);
    5513           0 :                 if (*out == NULL) goto failed;
    5514           0 :                 return 0;
    5515             :         }
    5516           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type);
    5517           0 :         if (isinstance == -1) {
    5518           0 :                 return 1;
    5519             :         }
    5520           0 :         if (isinstance) {
    5521             :                 expr_ty func;
    5522             :                 asdl_seq* args;
    5523             :                 asdl_seq* keywords;
    5524             :                 expr_ty starargs;
    5525             :                 expr_ty kwargs;
    5526             : 
    5527           0 :                 if (_PyObject_HasAttrId(obj, &PyId_func)) {
    5528             :                         int res;
    5529           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_func);
    5530           0 :                         if (tmp == NULL) goto failed;
    5531           0 :                         res = obj2ast_expr(tmp, &func, arena);
    5532           0 :                         if (res != 0) goto failed;
    5533           0 :                         Py_XDECREF(tmp);
    5534           0 :                         tmp = NULL;
    5535             :                 } else {
    5536           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
    5537           0 :                         return 1;
    5538             :                 }
    5539           0 :                 if (_PyObject_HasAttrId(obj, &PyId_args)) {
    5540             :                         int res;
    5541             :                         Py_ssize_t len;
    5542             :                         Py_ssize_t i;
    5543           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_args);
    5544           0 :                         if (tmp == NULL) goto failed;
    5545           0 :                         if (!PyList_Check(tmp)) {
    5546           0 :                                 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5547             :                                 goto failed;
    5548             :                         }
    5549           0 :                         len = PyList_GET_SIZE(tmp);
    5550           0 :                         args = asdl_seq_new(len, arena);
    5551           0 :                         if (args == NULL) goto failed;
    5552           0 :                         for (i = 0; i < len; i++) {
    5553             :                                 expr_ty value;
    5554           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5555           0 :                                 if (res != 0) goto failed;
    5556           0 :                                 asdl_seq_SET(args, i, value);
    5557             :                         }
    5558           0 :                         Py_XDECREF(tmp);
    5559           0 :                         tmp = NULL;
    5560             :                 } else {
    5561           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
    5562           0 :                         return 1;
    5563             :                 }
    5564           0 :                 if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
    5565             :                         int res;
    5566             :                         Py_ssize_t len;
    5567             :                         Py_ssize_t i;
    5568           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
    5569           0 :                         if (tmp == NULL) goto failed;
    5570           0 :                         if (!PyList_Check(tmp)) {
    5571           0 :                                 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5572             :                                 goto failed;
    5573             :                         }
    5574           0 :                         len = PyList_GET_SIZE(tmp);
    5575           0 :                         keywords = asdl_seq_new(len, arena);
    5576           0 :                         if (keywords == NULL) goto failed;
    5577           0 :                         for (i = 0; i < len; i++) {
    5578             :                                 keyword_ty value;
    5579           0 :                                 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
    5580           0 :                                 if (res != 0) goto failed;
    5581           0 :                                 asdl_seq_SET(keywords, i, value);
    5582             :                         }
    5583           0 :                         Py_XDECREF(tmp);
    5584           0 :                         tmp = NULL;
    5585             :                 } else {
    5586           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
    5587           0 :                         return 1;
    5588             :                 }
    5589           0 :                 if (_PyObject_HasAttrId(obj, &PyId_starargs)) {
    5590             :                         int res;
    5591           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_starargs);
    5592           0 :                         if (tmp == NULL) goto failed;
    5593           0 :                         res = obj2ast_expr(tmp, &starargs, arena);
    5594           0 :                         if (res != 0) goto failed;
    5595           0 :                         Py_XDECREF(tmp);
    5596           0 :                         tmp = NULL;
    5597             :                 } else {
    5598           0 :                         starargs = NULL;
    5599             :                 }
    5600           0 :                 if (_PyObject_HasAttrId(obj, &PyId_kwargs)) {
    5601             :                         int res;
    5602           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_kwargs);
    5603           0 :                         if (tmp == NULL) goto failed;
    5604           0 :                         res = obj2ast_expr(tmp, &kwargs, arena);
    5605           0 :                         if (res != 0) goto failed;
    5606           0 :                         Py_XDECREF(tmp);
    5607           0 :                         tmp = NULL;
    5608             :                 } else {
    5609           0 :                         kwargs = NULL;
    5610             :                 }
    5611           0 :                 *out = Call(func, args, keywords, starargs, kwargs, lineno,
    5612             :                             col_offset, arena);
    5613           0 :                 if (*out == NULL) goto failed;
    5614           0 :                 return 0;
    5615             :         }
    5616           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type);
    5617           0 :         if (isinstance == -1) {
    5618           0 :                 return 1;
    5619             :         }
    5620           0 :         if (isinstance) {
    5621             :                 object n;
    5622             : 
    5623           0 :                 if (_PyObject_HasAttrId(obj, &PyId_n)) {
    5624             :                         int res;
    5625           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_n);
    5626           0 :                         if (tmp == NULL) goto failed;
    5627           0 :                         res = obj2ast_object(tmp, &n, arena);
    5628           0 :                         if (res != 0) goto failed;
    5629           0 :                         Py_XDECREF(tmp);
    5630           0 :                         tmp = NULL;
    5631             :                 } else {
    5632           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
    5633           0 :                         return 1;
    5634             :                 }
    5635           0 :                 *out = Num(n, lineno, col_offset, arena);
    5636           0 :                 if (*out == NULL) goto failed;
    5637           0 :                 return 0;
    5638             :         }
    5639           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type);
    5640           0 :         if (isinstance == -1) {
    5641           0 :                 return 1;
    5642             :         }
    5643           0 :         if (isinstance) {
    5644             :                 string s;
    5645             : 
    5646           0 :                 if (_PyObject_HasAttrId(obj, &PyId_s)) {
    5647             :                         int res;
    5648           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_s);
    5649           0 :                         if (tmp == NULL) goto failed;
    5650           0 :                         res = obj2ast_string(tmp, &s, arena);
    5651           0 :                         if (res != 0) goto failed;
    5652           0 :                         Py_XDECREF(tmp);
    5653           0 :                         tmp = NULL;
    5654             :                 } else {
    5655           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
    5656           0 :                         return 1;
    5657             :                 }
    5658           0 :                 *out = Str(s, lineno, col_offset, arena);
    5659           0 :                 if (*out == NULL) goto failed;
    5660           0 :                 return 0;
    5661             :         }
    5662           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
    5663           0 :         if (isinstance == -1) {
    5664           0 :                 return 1;
    5665             :         }
    5666           0 :         if (isinstance) {
    5667             :                 bytes s;
    5668             : 
    5669           0 :                 if (_PyObject_HasAttrId(obj, &PyId_s)) {
    5670             :                         int res;
    5671           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_s);
    5672           0 :                         if (tmp == NULL) goto failed;
    5673           0 :                         res = obj2ast_bytes(tmp, &s, arena);
    5674           0 :                         if (res != 0) goto failed;
    5675           0 :                         Py_XDECREF(tmp);
    5676           0 :                         tmp = NULL;
    5677             :                 } else {
    5678           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
    5679           0 :                         return 1;
    5680             :                 }
    5681           0 :                 *out = Bytes(s, lineno, col_offset, arena);
    5682           0 :                 if (*out == NULL) goto failed;
    5683           0 :                 return 0;
    5684             :         }
    5685           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type);
    5686           0 :         if (isinstance == -1) {
    5687           0 :                 return 1;
    5688             :         }
    5689           0 :         if (isinstance) {
    5690             : 
    5691           0 :                 *out = Ellipsis(lineno, col_offset, arena);
    5692           0 :                 if (*out == NULL) goto failed;
    5693           0 :                 return 0;
    5694             :         }
    5695           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type);
    5696           0 :         if (isinstance == -1) {
    5697           0 :                 return 1;
    5698             :         }
    5699           0 :         if (isinstance) {
    5700             :                 expr_ty value;
    5701             :                 identifier attr;
    5702             :                 expr_context_ty ctx;
    5703             : 
    5704           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    5705             :                         int res;
    5706           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    5707           0 :                         if (tmp == NULL) goto failed;
    5708           0 :                         res = obj2ast_expr(tmp, &value, arena);
    5709           0 :                         if (res != 0) goto failed;
    5710           0 :                         Py_XDECREF(tmp);
    5711           0 :                         tmp = NULL;
    5712             :                 } else {
    5713           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
    5714           0 :                         return 1;
    5715             :                 }
    5716           0 :                 if (_PyObject_HasAttrId(obj, &PyId_attr)) {
    5717             :                         int res;
    5718           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_attr);
    5719           0 :                         if (tmp == NULL) goto failed;
    5720           0 :                         res = obj2ast_identifier(tmp, &attr, arena);
    5721           0 :                         if (res != 0) goto failed;
    5722           0 :                         Py_XDECREF(tmp);
    5723           0 :                         tmp = NULL;
    5724             :                 } else {
    5725           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
    5726           0 :                         return 1;
    5727             :                 }
    5728           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
    5729             :                         int res;
    5730           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
    5731           0 :                         if (tmp == NULL) goto failed;
    5732           0 :                         res = obj2ast_expr_context(tmp, &ctx, arena);
    5733           0 :                         if (res != 0) goto failed;
    5734           0 :                         Py_XDECREF(tmp);
    5735           0 :                         tmp = NULL;
    5736             :                 } else {
    5737           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
    5738           0 :                         return 1;
    5739             :                 }
    5740           0 :                 *out = Attribute(value, attr, ctx, lineno, col_offset, arena);
    5741           0 :                 if (*out == NULL) goto failed;
    5742           0 :                 return 0;
    5743             :         }
    5744           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type);
    5745           0 :         if (isinstance == -1) {
    5746           0 :                 return 1;
    5747             :         }
    5748           0 :         if (isinstance) {
    5749             :                 expr_ty value;
    5750             :                 slice_ty slice;
    5751             :                 expr_context_ty ctx;
    5752             : 
    5753           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    5754             :                         int res;
    5755           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    5756           0 :                         if (tmp == NULL) goto failed;
    5757           0 :                         res = obj2ast_expr(tmp, &value, arena);
    5758           0 :                         if (res != 0) goto failed;
    5759           0 :                         Py_XDECREF(tmp);
    5760           0 :                         tmp = NULL;
    5761             :                 } else {
    5762           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
    5763           0 :                         return 1;
    5764             :                 }
    5765           0 :                 if (_PyObject_HasAttrId(obj, &PyId_slice)) {
    5766             :                         int res;
    5767           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_slice);
    5768           0 :                         if (tmp == NULL) goto failed;
    5769           0 :                         res = obj2ast_slice(tmp, &slice, arena);
    5770           0 :                         if (res != 0) goto failed;
    5771           0 :                         Py_XDECREF(tmp);
    5772           0 :                         tmp = NULL;
    5773             :                 } else {
    5774           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
    5775           0 :                         return 1;
    5776             :                 }
    5777           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
    5778             :                         int res;
    5779           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
    5780           0 :                         if (tmp == NULL) goto failed;
    5781           0 :                         res = obj2ast_expr_context(tmp, &ctx, arena);
    5782           0 :                         if (res != 0) goto failed;
    5783           0 :                         Py_XDECREF(tmp);
    5784           0 :                         tmp = NULL;
    5785             :                 } else {
    5786           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
    5787           0 :                         return 1;
    5788             :                 }
    5789           0 :                 *out = Subscript(value, slice, ctx, lineno, col_offset, arena);
    5790           0 :                 if (*out == NULL) goto failed;
    5791           0 :                 return 0;
    5792             :         }
    5793           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type);
    5794           0 :         if (isinstance == -1) {
    5795           0 :                 return 1;
    5796             :         }
    5797           0 :         if (isinstance) {
    5798             :                 expr_ty value;
    5799             :                 expr_context_ty ctx;
    5800             : 
    5801           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    5802             :                         int res;
    5803           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    5804           0 :                         if (tmp == NULL) goto failed;
    5805           0 :                         res = obj2ast_expr(tmp, &value, arena);
    5806           0 :                         if (res != 0) goto failed;
    5807           0 :                         Py_XDECREF(tmp);
    5808           0 :                         tmp = NULL;
    5809             :                 } else {
    5810           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
    5811           0 :                         return 1;
    5812             :                 }
    5813           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
    5814             :                         int res;
    5815           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
    5816           0 :                         if (tmp == NULL) goto failed;
    5817           0 :                         res = obj2ast_expr_context(tmp, &ctx, arena);
    5818           0 :                         if (res != 0) goto failed;
    5819           0 :                         Py_XDECREF(tmp);
    5820           0 :                         tmp = NULL;
    5821             :                 } else {
    5822           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
    5823           0 :                         return 1;
    5824             :                 }
    5825           0 :                 *out = Starred(value, ctx, lineno, col_offset, arena);
    5826           0 :                 if (*out == NULL) goto failed;
    5827           0 :                 return 0;
    5828             :         }
    5829           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type);
    5830           0 :         if (isinstance == -1) {
    5831           0 :                 return 1;
    5832             :         }
    5833           0 :         if (isinstance) {
    5834             :                 identifier id;
    5835             :                 expr_context_ty ctx;
    5836             : 
    5837           0 :                 if (_PyObject_HasAttrId(obj, &PyId_id)) {
    5838             :                         int res;
    5839           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_id);
    5840           0 :                         if (tmp == NULL) goto failed;
    5841           0 :                         res = obj2ast_identifier(tmp, &id, arena);
    5842           0 :                         if (res != 0) goto failed;
    5843           0 :                         Py_XDECREF(tmp);
    5844           0 :                         tmp = NULL;
    5845             :                 } else {
    5846           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
    5847           0 :                         return 1;
    5848             :                 }
    5849           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
    5850             :                         int res;
    5851           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
    5852           0 :                         if (tmp == NULL) goto failed;
    5853           0 :                         res = obj2ast_expr_context(tmp, &ctx, arena);
    5854           0 :                         if (res != 0) goto failed;
    5855           0 :                         Py_XDECREF(tmp);
    5856           0 :                         tmp = NULL;
    5857             :                 } else {
    5858           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
    5859           0 :                         return 1;
    5860             :                 }
    5861           0 :                 *out = Name(id, ctx, lineno, col_offset, arena);
    5862           0 :                 if (*out == NULL) goto failed;
    5863           0 :                 return 0;
    5864             :         }
    5865           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)List_type);
    5866           0 :         if (isinstance == -1) {
    5867           0 :                 return 1;
    5868             :         }
    5869           0 :         if (isinstance) {
    5870             :                 asdl_seq* elts;
    5871             :                 expr_context_ty ctx;
    5872             : 
    5873           0 :                 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
    5874             :                         int res;
    5875             :                         Py_ssize_t len;
    5876             :                         Py_ssize_t i;
    5877           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_elts);
    5878           0 :                         if (tmp == NULL) goto failed;
    5879           0 :                         if (!PyList_Check(tmp)) {
    5880           0 :                                 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5881             :                                 goto failed;
    5882             :                         }
    5883           0 :                         len = PyList_GET_SIZE(tmp);
    5884           0 :                         elts = asdl_seq_new(len, arena);
    5885           0 :                         if (elts == NULL) goto failed;
    5886           0 :                         for (i = 0; i < len; i++) {
    5887             :                                 expr_ty value;
    5888           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5889           0 :                                 if (res != 0) goto failed;
    5890           0 :                                 asdl_seq_SET(elts, i, value);
    5891             :                         }
    5892           0 :                         Py_XDECREF(tmp);
    5893           0 :                         tmp = NULL;
    5894             :                 } else {
    5895           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
    5896           0 :                         return 1;
    5897             :                 }
    5898           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
    5899             :                         int res;
    5900           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
    5901           0 :                         if (tmp == NULL) goto failed;
    5902           0 :                         res = obj2ast_expr_context(tmp, &ctx, arena);
    5903           0 :                         if (res != 0) goto failed;
    5904           0 :                         Py_XDECREF(tmp);
    5905           0 :                         tmp = NULL;
    5906             :                 } else {
    5907           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
    5908           0 :                         return 1;
    5909             :                 }
    5910           0 :                 *out = List(elts, ctx, lineno, col_offset, arena);
    5911           0 :                 if (*out == NULL) goto failed;
    5912           0 :                 return 0;
    5913             :         }
    5914           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type);
    5915           0 :         if (isinstance == -1) {
    5916           0 :                 return 1;
    5917             :         }
    5918           0 :         if (isinstance) {
    5919             :                 asdl_seq* elts;
    5920             :                 expr_context_ty ctx;
    5921             : 
    5922           0 :                 if (_PyObject_HasAttrId(obj, &PyId_elts)) {
    5923             :                         int res;
    5924             :                         Py_ssize_t len;
    5925             :                         Py_ssize_t i;
    5926           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_elts);
    5927           0 :                         if (tmp == NULL) goto failed;
    5928           0 :                         if (!PyList_Check(tmp)) {
    5929           0 :                                 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    5930             :                                 goto failed;
    5931             :                         }
    5932           0 :                         len = PyList_GET_SIZE(tmp);
    5933           0 :                         elts = asdl_seq_new(len, arena);
    5934           0 :                         if (elts == NULL) goto failed;
    5935           0 :                         for (i = 0; i < len; i++) {
    5936             :                                 expr_ty value;
    5937           0 :                                 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    5938           0 :                                 if (res != 0) goto failed;
    5939           0 :                                 asdl_seq_SET(elts, i, value);
    5940             :                         }
    5941           0 :                         Py_XDECREF(tmp);
    5942           0 :                         tmp = NULL;
    5943             :                 } else {
    5944           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
    5945           0 :                         return 1;
    5946             :                 }
    5947           0 :                 if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
    5948             :                         int res;
    5949           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
    5950           0 :                         if (tmp == NULL) goto failed;
    5951           0 :                         res = obj2ast_expr_context(tmp, &ctx, arena);
    5952           0 :                         if (res != 0) goto failed;
    5953           0 :                         Py_XDECREF(tmp);
    5954           0 :                         tmp = NULL;
    5955             :                 } else {
    5956           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
    5957           0 :                         return 1;
    5958             :                 }
    5959           0 :                 *out = Tuple(elts, ctx, lineno, col_offset, arena);
    5960           0 :                 if (*out == NULL) goto failed;
    5961           0 :                 return 0;
    5962             :         }
    5963             : 
    5964           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
    5965             :         failed:
    5966           0 :         Py_XDECREF(tmp);
    5967           0 :         return 1;
    5968             : }
    5969             : 
    5970             : int
    5971           0 : obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
    5972             : {
    5973             :         int isinstance;
    5974             : 
    5975           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type);
    5976           0 :         if (isinstance == -1) {
    5977           0 :                 return 1;
    5978             :         }
    5979           0 :         if (isinstance) {
    5980           0 :                 *out = Load;
    5981           0 :                 return 0;
    5982             :         }
    5983           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type);
    5984           0 :         if (isinstance == -1) {
    5985           0 :                 return 1;
    5986             :         }
    5987           0 :         if (isinstance) {
    5988           0 :                 *out = Store;
    5989           0 :                 return 0;
    5990             :         }
    5991           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type);
    5992           0 :         if (isinstance == -1) {
    5993           0 :                 return 1;
    5994             :         }
    5995           0 :         if (isinstance) {
    5996           0 :                 *out = Del;
    5997           0 :                 return 0;
    5998             :         }
    5999           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type);
    6000           0 :         if (isinstance == -1) {
    6001           0 :                 return 1;
    6002             :         }
    6003           0 :         if (isinstance) {
    6004           0 :                 *out = AugLoad;
    6005           0 :                 return 0;
    6006             :         }
    6007           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type);
    6008           0 :         if (isinstance == -1) {
    6009           0 :                 return 1;
    6010             :         }
    6011           0 :         if (isinstance) {
    6012           0 :                 *out = AugStore;
    6013           0 :                 return 0;
    6014             :         }
    6015           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type);
    6016           0 :         if (isinstance == -1) {
    6017           0 :                 return 1;
    6018             :         }
    6019           0 :         if (isinstance) {
    6020           0 :                 *out = Param;
    6021           0 :                 return 0;
    6022             :         }
    6023             : 
    6024           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
    6025           0 :         return 1;
    6026             : }
    6027             : 
    6028             : int
    6029           0 : obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
    6030             : {
    6031             :         int isinstance;
    6032             : 
    6033           0 :         PyObject *tmp = NULL;
    6034             : 
    6035           0 :         if (obj == Py_None) {
    6036           0 :                 *out = NULL;
    6037           0 :                 return 0;
    6038             :         }
    6039           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type);
    6040           0 :         if (isinstance == -1) {
    6041           0 :                 return 1;
    6042             :         }
    6043           0 :         if (isinstance) {
    6044             :                 expr_ty lower;
    6045             :                 expr_ty upper;
    6046             :                 expr_ty step;
    6047             : 
    6048           0 :                 if (_PyObject_HasAttrId(obj, &PyId_lower)) {
    6049             :                         int res;
    6050           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_lower);
    6051           0 :                         if (tmp == NULL) goto failed;
    6052           0 :                         res = obj2ast_expr(tmp, &lower, arena);
    6053           0 :                         if (res != 0) goto failed;
    6054           0 :                         Py_XDECREF(tmp);
    6055           0 :                         tmp = NULL;
    6056             :                 } else {
    6057           0 :                         lower = NULL;
    6058             :                 }
    6059           0 :                 if (_PyObject_HasAttrId(obj, &PyId_upper)) {
    6060             :                         int res;
    6061           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_upper);
    6062           0 :                         if (tmp == NULL) goto failed;
    6063           0 :                         res = obj2ast_expr(tmp, &upper, arena);
    6064           0 :                         if (res != 0) goto failed;
    6065           0 :                         Py_XDECREF(tmp);
    6066           0 :                         tmp = NULL;
    6067             :                 } else {
    6068           0 :                         upper = NULL;
    6069             :                 }
    6070           0 :                 if (_PyObject_HasAttrId(obj, &PyId_step)) {
    6071             :                         int res;
    6072           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_step);
    6073           0 :                         if (tmp == NULL) goto failed;
    6074           0 :                         res = obj2ast_expr(tmp, &step, arena);
    6075           0 :                         if (res != 0) goto failed;
    6076           0 :                         Py_XDECREF(tmp);
    6077           0 :                         tmp = NULL;
    6078             :                 } else {
    6079           0 :                         step = NULL;
    6080             :                 }
    6081           0 :                 *out = Slice(lower, upper, step, arena);
    6082           0 :                 if (*out == NULL) goto failed;
    6083           0 :                 return 0;
    6084             :         }
    6085           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type);
    6086           0 :         if (isinstance == -1) {
    6087           0 :                 return 1;
    6088             :         }
    6089           0 :         if (isinstance) {
    6090             :                 asdl_seq* dims;
    6091             : 
    6092           0 :                 if (_PyObject_HasAttrId(obj, &PyId_dims)) {
    6093             :                         int res;
    6094             :                         Py_ssize_t len;
    6095             :                         Py_ssize_t i;
    6096           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_dims);
    6097           0 :                         if (tmp == NULL) goto failed;
    6098           0 :                         if (!PyList_Check(tmp)) {
    6099           0 :                                 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6100           0 :                                 goto failed;
    6101             :                         }
    6102           0 :                         len = PyList_GET_SIZE(tmp);
    6103           0 :                         dims = asdl_seq_new(len, arena);
    6104           0 :                         if (dims == NULL) goto failed;
    6105           0 :                         for (i = 0; i < len; i++) {
    6106             :                                 slice_ty value;
    6107           0 :                                 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena);
    6108           0 :                                 if (res != 0) goto failed;
    6109           0 :                                 asdl_seq_SET(dims, i, value);
    6110             :                         }
    6111           0 :                         Py_XDECREF(tmp);
    6112           0 :                         tmp = NULL;
    6113             :                 } else {
    6114           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice");
    6115           0 :                         return 1;
    6116             :                 }
    6117           0 :                 *out = ExtSlice(dims, arena);
    6118           0 :                 if (*out == NULL) goto failed;
    6119           0 :                 return 0;
    6120             :         }
    6121           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type);
    6122           0 :         if (isinstance == -1) {
    6123           0 :                 return 1;
    6124             :         }
    6125           0 :         if (isinstance) {
    6126             :                 expr_ty value;
    6127             : 
    6128           0 :                 if (_PyObject_HasAttrId(obj, &PyId_value)) {
    6129             :                         int res;
    6130           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_value);
    6131           0 :                         if (tmp == NULL) goto failed;
    6132           0 :                         res = obj2ast_expr(tmp, &value, arena);
    6133           0 :                         if (res != 0) goto failed;
    6134           0 :                         Py_XDECREF(tmp);
    6135           0 :                         tmp = NULL;
    6136             :                 } else {
    6137           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index");
    6138           0 :                         return 1;
    6139             :                 }
    6140           0 :                 *out = Index(value, arena);
    6141           0 :                 if (*out == NULL) goto failed;
    6142           0 :                 return 0;
    6143             :         }
    6144             : 
    6145           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj);
    6146             :         failed:
    6147           0 :         Py_XDECREF(tmp);
    6148           0 :         return 1;
    6149             : }
    6150             : 
    6151             : int
    6152           0 : obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
    6153             : {
    6154             :         int isinstance;
    6155             : 
    6156           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)And_type);
    6157           0 :         if (isinstance == -1) {
    6158           0 :                 return 1;
    6159             :         }
    6160           0 :         if (isinstance) {
    6161           0 :                 *out = And;
    6162           0 :                 return 0;
    6163             :         }
    6164           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type);
    6165           0 :         if (isinstance == -1) {
    6166           0 :                 return 1;
    6167             :         }
    6168           0 :         if (isinstance) {
    6169           0 :                 *out = Or;
    6170           0 :                 return 0;
    6171             :         }
    6172             : 
    6173           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
    6174           0 :         return 1;
    6175             : }
    6176             : 
    6177             : int
    6178           0 : obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
    6179             : {
    6180             :         int isinstance;
    6181             : 
    6182           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type);
    6183           0 :         if (isinstance == -1) {
    6184           0 :                 return 1;
    6185             :         }
    6186           0 :         if (isinstance) {
    6187           0 :                 *out = Add;
    6188           0 :                 return 0;
    6189             :         }
    6190           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type);
    6191           0 :         if (isinstance == -1) {
    6192           0 :                 return 1;
    6193             :         }
    6194           0 :         if (isinstance) {
    6195           0 :                 *out = Sub;
    6196           0 :                 return 0;
    6197             :         }
    6198           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type);
    6199           0 :         if (isinstance == -1) {
    6200           0 :                 return 1;
    6201             :         }
    6202           0 :         if (isinstance) {
    6203           0 :                 *out = Mult;
    6204           0 :                 return 0;
    6205             :         }
    6206           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type);
    6207           0 :         if (isinstance == -1) {
    6208           0 :                 return 1;
    6209             :         }
    6210           0 :         if (isinstance) {
    6211           0 :                 *out = Div;
    6212           0 :                 return 0;
    6213             :         }
    6214           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type);
    6215           0 :         if (isinstance == -1) {
    6216           0 :                 return 1;
    6217             :         }
    6218           0 :         if (isinstance) {
    6219           0 :                 *out = Mod;
    6220           0 :                 return 0;
    6221             :         }
    6222           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type);
    6223           0 :         if (isinstance == -1) {
    6224           0 :                 return 1;
    6225             :         }
    6226           0 :         if (isinstance) {
    6227           0 :                 *out = Pow;
    6228           0 :                 return 0;
    6229             :         }
    6230           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type);
    6231           0 :         if (isinstance == -1) {
    6232           0 :                 return 1;
    6233             :         }
    6234           0 :         if (isinstance) {
    6235           0 :                 *out = LShift;
    6236           0 :                 return 0;
    6237             :         }
    6238           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type);
    6239           0 :         if (isinstance == -1) {
    6240           0 :                 return 1;
    6241             :         }
    6242           0 :         if (isinstance) {
    6243           0 :                 *out = RShift;
    6244           0 :                 return 0;
    6245             :         }
    6246           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type);
    6247           0 :         if (isinstance == -1) {
    6248           0 :                 return 1;
    6249             :         }
    6250           0 :         if (isinstance) {
    6251           0 :                 *out = BitOr;
    6252           0 :                 return 0;
    6253             :         }
    6254           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type);
    6255           0 :         if (isinstance == -1) {
    6256           0 :                 return 1;
    6257             :         }
    6258           0 :         if (isinstance) {
    6259           0 :                 *out = BitXor;
    6260           0 :                 return 0;
    6261             :         }
    6262           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type);
    6263           0 :         if (isinstance == -1) {
    6264           0 :                 return 1;
    6265             :         }
    6266           0 :         if (isinstance) {
    6267           0 :                 *out = BitAnd;
    6268           0 :                 return 0;
    6269             :         }
    6270           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type);
    6271           0 :         if (isinstance == -1) {
    6272           0 :                 return 1;
    6273             :         }
    6274           0 :         if (isinstance) {
    6275           0 :                 *out = FloorDiv;
    6276           0 :                 return 0;
    6277             :         }
    6278             : 
    6279           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
    6280           0 :         return 1;
    6281             : }
    6282             : 
    6283             : int
    6284           0 : obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
    6285             : {
    6286             :         int isinstance;
    6287             : 
    6288           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type);
    6289           0 :         if (isinstance == -1) {
    6290           0 :                 return 1;
    6291             :         }
    6292           0 :         if (isinstance) {
    6293           0 :                 *out = Invert;
    6294           0 :                 return 0;
    6295             :         }
    6296           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type);
    6297           0 :         if (isinstance == -1) {
    6298           0 :                 return 1;
    6299             :         }
    6300           0 :         if (isinstance) {
    6301           0 :                 *out = Not;
    6302           0 :                 return 0;
    6303             :         }
    6304           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type);
    6305           0 :         if (isinstance == -1) {
    6306           0 :                 return 1;
    6307             :         }
    6308           0 :         if (isinstance) {
    6309           0 :                 *out = UAdd;
    6310           0 :                 return 0;
    6311             :         }
    6312           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type);
    6313           0 :         if (isinstance == -1) {
    6314           0 :                 return 1;
    6315             :         }
    6316           0 :         if (isinstance) {
    6317           0 :                 *out = USub;
    6318           0 :                 return 0;
    6319             :         }
    6320             : 
    6321           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
    6322           0 :         return 1;
    6323             : }
    6324             : 
    6325             : int
    6326           0 : obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
    6327             : {
    6328             :         int isinstance;
    6329             : 
    6330           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type);
    6331           0 :         if (isinstance == -1) {
    6332           0 :                 return 1;
    6333             :         }
    6334           0 :         if (isinstance) {
    6335           0 :                 *out = Eq;
    6336           0 :                 return 0;
    6337             :         }
    6338           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type);
    6339           0 :         if (isinstance == -1) {
    6340           0 :                 return 1;
    6341             :         }
    6342           0 :         if (isinstance) {
    6343           0 :                 *out = NotEq;
    6344           0 :                 return 0;
    6345             :         }
    6346           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type);
    6347           0 :         if (isinstance == -1) {
    6348           0 :                 return 1;
    6349             :         }
    6350           0 :         if (isinstance) {
    6351           0 :                 *out = Lt;
    6352           0 :                 return 0;
    6353             :         }
    6354           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type);
    6355           0 :         if (isinstance == -1) {
    6356           0 :                 return 1;
    6357             :         }
    6358           0 :         if (isinstance) {
    6359           0 :                 *out = LtE;
    6360           0 :                 return 0;
    6361             :         }
    6362           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type);
    6363           0 :         if (isinstance == -1) {
    6364           0 :                 return 1;
    6365             :         }
    6366           0 :         if (isinstance) {
    6367           0 :                 *out = Gt;
    6368           0 :                 return 0;
    6369             :         }
    6370           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type);
    6371           0 :         if (isinstance == -1) {
    6372           0 :                 return 1;
    6373             :         }
    6374           0 :         if (isinstance) {
    6375           0 :                 *out = GtE;
    6376           0 :                 return 0;
    6377             :         }
    6378           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type);
    6379           0 :         if (isinstance == -1) {
    6380           0 :                 return 1;
    6381             :         }
    6382           0 :         if (isinstance) {
    6383           0 :                 *out = Is;
    6384           0 :                 return 0;
    6385             :         }
    6386           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type);
    6387           0 :         if (isinstance == -1) {
    6388           0 :                 return 1;
    6389             :         }
    6390           0 :         if (isinstance) {
    6391           0 :                 *out = IsNot;
    6392           0 :                 return 0;
    6393             :         }
    6394           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)In_type);
    6395           0 :         if (isinstance == -1) {
    6396           0 :                 return 1;
    6397             :         }
    6398           0 :         if (isinstance) {
    6399           0 :                 *out = In;
    6400           0 :                 return 0;
    6401             :         }
    6402           0 :         isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type);
    6403           0 :         if (isinstance == -1) {
    6404           0 :                 return 1;
    6405             :         }
    6406           0 :         if (isinstance) {
    6407           0 :                 *out = NotIn;
    6408           0 :                 return 0;
    6409             :         }
    6410             : 
    6411           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
    6412           0 :         return 1;
    6413             : }
    6414             : 
    6415             : int
    6416           0 : obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
    6417             : {
    6418           0 :         PyObject* tmp = NULL;
    6419             :         expr_ty target;
    6420             :         expr_ty iter;
    6421             :         asdl_seq* ifs;
    6422             : 
    6423           0 :         if (_PyObject_HasAttrId(obj, &PyId_target)) {
    6424             :                 int res;
    6425           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_target);
    6426           0 :                 if (tmp == NULL) goto failed;
    6427           0 :                 res = obj2ast_expr(tmp, &target, arena);
    6428           0 :                 if (res != 0) goto failed;
    6429           0 :                 Py_XDECREF(tmp);
    6430           0 :                 tmp = NULL;
    6431             :         } else {
    6432           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
    6433           0 :                 return 1;
    6434             :         }
    6435           0 :         if (_PyObject_HasAttrId(obj, &PyId_iter)) {
    6436             :                 int res;
    6437           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_iter);
    6438           0 :                 if (tmp == NULL) goto failed;
    6439           0 :                 res = obj2ast_expr(tmp, &iter, arena);
    6440           0 :                 if (res != 0) goto failed;
    6441           0 :                 Py_XDECREF(tmp);
    6442           0 :                 tmp = NULL;
    6443             :         } else {
    6444           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
    6445           0 :                 return 1;
    6446             :         }
    6447           0 :         if (_PyObject_HasAttrId(obj, &PyId_ifs)) {
    6448             :                 int res;
    6449             :                 Py_ssize_t len;
    6450             :                 Py_ssize_t i;
    6451           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_ifs);
    6452           0 :                 if (tmp == NULL) goto failed;
    6453           0 :                 if (!PyList_Check(tmp)) {
    6454           0 :                         PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6455           0 :                         goto failed;
    6456             :                 }
    6457           0 :                 len = PyList_GET_SIZE(tmp);
    6458           0 :                 ifs = asdl_seq_new(len, arena);
    6459           0 :                 if (ifs == NULL) goto failed;
    6460           0 :                 for (i = 0; i < len; i++) {
    6461             :                         expr_ty value;
    6462           0 :                         res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    6463           0 :                         if (res != 0) goto failed;
    6464           0 :                         asdl_seq_SET(ifs, i, value);
    6465             :                 }
    6466           0 :                 Py_XDECREF(tmp);
    6467           0 :                 tmp = NULL;
    6468             :         } else {
    6469           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
    6470           0 :                 return 1;
    6471             :         }
    6472           0 :         *out = comprehension(target, iter, ifs, arena);
    6473           0 :         return 0;
    6474             : failed:
    6475           0 :         Py_XDECREF(tmp);
    6476           0 :         return 1;
    6477             : }
    6478             : 
    6479             : int
    6480           0 : obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
    6481             : {
    6482             :         int isinstance;
    6483             : 
    6484           0 :         PyObject *tmp = NULL;
    6485             :         int lineno;
    6486             :         int col_offset;
    6487             : 
    6488           0 :         if (obj == Py_None) {
    6489           0 :                 *out = NULL;
    6490           0 :                 return 0;
    6491             :         }
    6492           0 :         if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
    6493             :                 int res;
    6494           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
    6495           0 :                 if (tmp == NULL) goto failed;
    6496           0 :                 res = obj2ast_int(tmp, &lineno, arena);
    6497           0 :                 if (res != 0) goto failed;
    6498           0 :                 Py_XDECREF(tmp);
    6499           0 :                 tmp = NULL;
    6500             :         } else {
    6501           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
    6502           0 :                 return 1;
    6503             :         }
    6504           0 :         if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
    6505             :                 int res;
    6506           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
    6507           0 :                 if (tmp == NULL) goto failed;
    6508           0 :                 res = obj2ast_int(tmp, &col_offset, arena);
    6509           0 :                 if (res != 0) goto failed;
    6510           0 :                 Py_XDECREF(tmp);
    6511           0 :                 tmp = NULL;
    6512             :         } else {
    6513           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
    6514           0 :                 return 1;
    6515             :         }
    6516           0 :         isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);
    6517           0 :         if (isinstance == -1) {
    6518           0 :                 return 1;
    6519             :         }
    6520           0 :         if (isinstance) {
    6521             :                 expr_ty type;
    6522             :                 identifier name;
    6523             :                 asdl_seq* body;
    6524             : 
    6525           0 :                 if (_PyObject_HasAttrId(obj, &PyId_type)) {
    6526             :                         int res;
    6527           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_type);
    6528           0 :                         if (tmp == NULL) goto failed;
    6529           0 :                         res = obj2ast_expr(tmp, &type, arena);
    6530           0 :                         if (res != 0) goto failed;
    6531           0 :                         Py_XDECREF(tmp);
    6532           0 :                         tmp = NULL;
    6533             :                 } else {
    6534           0 :                         type = NULL;
    6535             :                 }
    6536           0 :                 if (_PyObject_HasAttrId(obj, &PyId_name)) {
    6537             :                         int res;
    6538           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_name);
    6539           0 :                         if (tmp == NULL) goto failed;
    6540           0 :                         res = obj2ast_identifier(tmp, &name, arena);
    6541           0 :                         if (res != 0) goto failed;
    6542           0 :                         Py_XDECREF(tmp);
    6543           0 :                         tmp = NULL;
    6544             :                 } else {
    6545           0 :                         name = NULL;
    6546             :                 }
    6547           0 :                 if (_PyObject_HasAttrId(obj, &PyId_body)) {
    6548             :                         int res;
    6549             :                         Py_ssize_t len;
    6550             :                         Py_ssize_t i;
    6551           0 :                         tmp = _PyObject_GetAttrId(obj, &PyId_body);
    6552           0 :                         if (tmp == NULL) goto failed;
    6553           0 :                         if (!PyList_Check(tmp)) {
    6554           0 :                                 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6555             :                                 goto failed;
    6556             :                         }
    6557           0 :                         len = PyList_GET_SIZE(tmp);
    6558           0 :                         body = asdl_seq_new(len, arena);
    6559           0 :                         if (body == NULL) goto failed;
    6560           0 :                         for (i = 0; i < len; i++) {
    6561             :                                 stmt_ty value;
    6562           0 :                                 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
    6563           0 :                                 if (res != 0) goto failed;
    6564           0 :                                 asdl_seq_SET(body, i, value);
    6565             :                         }
    6566           0 :                         Py_XDECREF(tmp);
    6567           0 :                         tmp = NULL;
    6568             :                 } else {
    6569           0 :                         PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
    6570           0 :                         return 1;
    6571             :                 }
    6572           0 :                 *out = ExceptHandler(type, name, body, lineno, col_offset,
    6573             :                                      arena);
    6574           0 :                 if (*out == NULL) goto failed;
    6575           0 :                 return 0;
    6576             :         }
    6577             : 
    6578           0 :         PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
    6579             :         failed:
    6580           0 :         Py_XDECREF(tmp);
    6581           0 :         return 1;
    6582             : }
    6583             : 
    6584             : int
    6585           0 : obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
    6586             : {
    6587           0 :         PyObject* tmp = NULL;
    6588             :         asdl_seq* args;
    6589             :         identifier vararg;
    6590             :         expr_ty varargannotation;
    6591             :         asdl_seq* kwonlyargs;
    6592             :         identifier kwarg;
    6593             :         expr_ty kwargannotation;
    6594             :         asdl_seq* defaults;
    6595             :         asdl_seq* kw_defaults;
    6596             : 
    6597           0 :         if (_PyObject_HasAttrId(obj, &PyId_args)) {
    6598             :                 int res;
    6599             :                 Py_ssize_t len;
    6600             :                 Py_ssize_t i;
    6601           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_args);
    6602           0 :                 if (tmp == NULL) goto failed;
    6603           0 :                 if (!PyList_Check(tmp)) {
    6604           0 :                         PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6605           0 :                         goto failed;
    6606             :                 }
    6607           0 :                 len = PyList_GET_SIZE(tmp);
    6608           0 :                 args = asdl_seq_new(len, arena);
    6609           0 :                 if (args == NULL) goto failed;
    6610           0 :                 for (i = 0; i < len; i++) {
    6611             :                         arg_ty value;
    6612           0 :                         res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
    6613           0 :                         if (res != 0) goto failed;
    6614           0 :                         asdl_seq_SET(args, i, value);
    6615             :                 }
    6616           0 :                 Py_XDECREF(tmp);
    6617           0 :                 tmp = NULL;
    6618             :         } else {
    6619           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
    6620           0 :                 return 1;
    6621             :         }
    6622           0 :         if (_PyObject_HasAttrId(obj, &PyId_vararg)) {
    6623             :                 int res;
    6624           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_vararg);
    6625           0 :                 if (tmp == NULL) goto failed;
    6626           0 :                 res = obj2ast_identifier(tmp, &vararg, arena);
    6627           0 :                 if (res != 0) goto failed;
    6628           0 :                 Py_XDECREF(tmp);
    6629           0 :                 tmp = NULL;
    6630             :         } else {
    6631           0 :                 vararg = NULL;
    6632             :         }
    6633           0 :         if (_PyObject_HasAttrId(obj, &PyId_varargannotation)) {
    6634             :                 int res;
    6635           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_varargannotation);
    6636           0 :                 if (tmp == NULL) goto failed;
    6637           0 :                 res = obj2ast_expr(tmp, &varargannotation, arena);
    6638           0 :                 if (res != 0) goto failed;
    6639           0 :                 Py_XDECREF(tmp);
    6640           0 :                 tmp = NULL;
    6641             :         } else {
    6642           0 :                 varargannotation = NULL;
    6643             :         }
    6644           0 :         if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) {
    6645             :                 int res;
    6646             :                 Py_ssize_t len;
    6647             :                 Py_ssize_t i;
    6648           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs);
    6649           0 :                 if (tmp == NULL) goto failed;
    6650           0 :                 if (!PyList_Check(tmp)) {
    6651           0 :                         PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6652           0 :                         goto failed;
    6653             :                 }
    6654           0 :                 len = PyList_GET_SIZE(tmp);
    6655           0 :                 kwonlyargs = asdl_seq_new(len, arena);
    6656           0 :                 if (kwonlyargs == NULL) goto failed;
    6657           0 :                 for (i = 0; i < len; i++) {
    6658             :                         arg_ty value;
    6659           0 :                         res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
    6660           0 :                         if (res != 0) goto failed;
    6661           0 :                         asdl_seq_SET(kwonlyargs, i, value);
    6662             :                 }
    6663           0 :                 Py_XDECREF(tmp);
    6664           0 :                 tmp = NULL;
    6665             :         } else {
    6666           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
    6667           0 :                 return 1;
    6668             :         }
    6669           0 :         if (_PyObject_HasAttrId(obj, &PyId_kwarg)) {
    6670             :                 int res;
    6671           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg);
    6672           0 :                 if (tmp == NULL) goto failed;
    6673           0 :                 res = obj2ast_identifier(tmp, &kwarg, arena);
    6674           0 :                 if (res != 0) goto failed;
    6675           0 :                 Py_XDECREF(tmp);
    6676           0 :                 tmp = NULL;
    6677             :         } else {
    6678           0 :                 kwarg = NULL;
    6679             :         }
    6680           0 :         if (_PyObject_HasAttrId(obj, &PyId_kwargannotation)) {
    6681             :                 int res;
    6682           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_kwargannotation);
    6683           0 :                 if (tmp == NULL) goto failed;
    6684           0 :                 res = obj2ast_expr(tmp, &kwargannotation, arena);
    6685           0 :                 if (res != 0) goto failed;
    6686           0 :                 Py_XDECREF(tmp);
    6687           0 :                 tmp = NULL;
    6688             :         } else {
    6689           0 :                 kwargannotation = NULL;
    6690             :         }
    6691           0 :         if (_PyObject_HasAttrId(obj, &PyId_defaults)) {
    6692             :                 int res;
    6693             :                 Py_ssize_t len;
    6694             :                 Py_ssize_t i;
    6695           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_defaults);
    6696           0 :                 if (tmp == NULL) goto failed;
    6697           0 :                 if (!PyList_Check(tmp)) {
    6698           0 :                         PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6699           0 :                         goto failed;
    6700             :                 }
    6701           0 :                 len = PyList_GET_SIZE(tmp);
    6702           0 :                 defaults = asdl_seq_new(len, arena);
    6703           0 :                 if (defaults == NULL) goto failed;
    6704           0 :                 for (i = 0; i < len; i++) {
    6705             :                         expr_ty value;
    6706           0 :                         res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    6707           0 :                         if (res != 0) goto failed;
    6708           0 :                         asdl_seq_SET(defaults, i, value);
    6709             :                 }
    6710           0 :                 Py_XDECREF(tmp);
    6711           0 :                 tmp = NULL;
    6712             :         } else {
    6713           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
    6714           0 :                 return 1;
    6715             :         }
    6716           0 :         if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) {
    6717             :                 int res;
    6718             :                 Py_ssize_t len;
    6719             :                 Py_ssize_t i;
    6720           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults);
    6721           0 :                 if (tmp == NULL) goto failed;
    6722           0 :                 if (!PyList_Check(tmp)) {
    6723           0 :                         PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name);
    6724           0 :                         goto failed;
    6725             :                 }
    6726           0 :                 len = PyList_GET_SIZE(tmp);
    6727           0 :                 kw_defaults = asdl_seq_new(len, arena);
    6728           0 :                 if (kw_defaults == NULL) goto failed;
    6729           0 :                 for (i = 0; i < len; i++) {
    6730             :                         expr_ty value;
    6731           0 :                         res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
    6732           0 :                         if (res != 0) goto failed;
    6733           0 :                         asdl_seq_SET(kw_defaults, i, value);
    6734             :                 }
    6735           0 :                 Py_XDECREF(tmp);
    6736           0 :                 tmp = NULL;
    6737             :         } else {
    6738           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
    6739           0 :                 return 1;
    6740             :         }
    6741           0 :         *out = arguments(args, vararg, varargannotation, kwonlyargs, kwarg,
    6742             :                          kwargannotation, defaults, kw_defaults, arena);
    6743           0 :         return 0;
    6744             : failed:
    6745           0 :         Py_XDECREF(tmp);
    6746           0 :         return 1;
    6747             : }
    6748             : 
    6749             : int
    6750           0 : obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
    6751             : {
    6752           0 :         PyObject* tmp = NULL;
    6753             :         identifier arg;
    6754             :         expr_ty annotation;
    6755             : 
    6756           0 :         if (_PyObject_HasAttrId(obj, &PyId_arg)) {
    6757             :                 int res;
    6758           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_arg);
    6759           0 :                 if (tmp == NULL) goto failed;
    6760           0 :                 res = obj2ast_identifier(tmp, &arg, arena);
    6761           0 :                 if (res != 0) goto failed;
    6762           0 :                 Py_XDECREF(tmp);
    6763           0 :                 tmp = NULL;
    6764             :         } else {
    6765           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
    6766           0 :                 return 1;
    6767             :         }
    6768           0 :         if (_PyObject_HasAttrId(obj, &PyId_annotation)) {
    6769             :                 int res;
    6770           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_annotation);
    6771           0 :                 if (tmp == NULL) goto failed;
    6772           0 :                 res = obj2ast_expr(tmp, &annotation, arena);
    6773           0 :                 if (res != 0) goto failed;
    6774           0 :                 Py_XDECREF(tmp);
    6775           0 :                 tmp = NULL;
    6776             :         } else {
    6777           0 :                 annotation = NULL;
    6778             :         }
    6779           0 :         *out = arg(arg, annotation, arena);
    6780           0 :         return 0;
    6781             : failed:
    6782           0 :         Py_XDECREF(tmp);
    6783           0 :         return 1;
    6784             : }
    6785             : 
    6786             : int
    6787           0 : obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)
    6788             : {
    6789           0 :         PyObject* tmp = NULL;
    6790             :         identifier arg;
    6791             :         expr_ty value;
    6792             : 
    6793           0 :         if (_PyObject_HasAttrId(obj, &PyId_arg)) {
    6794             :                 int res;
    6795           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_arg);
    6796           0 :                 if (tmp == NULL) goto failed;
    6797           0 :                 res = obj2ast_identifier(tmp, &arg, arena);
    6798           0 :                 if (res != 0) goto failed;
    6799           0 :                 Py_XDECREF(tmp);
    6800           0 :                 tmp = NULL;
    6801             :         } else {
    6802           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword");
    6803           0 :                 return 1;
    6804             :         }
    6805           0 :         if (_PyObject_HasAttrId(obj, &PyId_value)) {
    6806             :                 int res;
    6807           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_value);
    6808           0 :                 if (tmp == NULL) goto failed;
    6809           0 :                 res = obj2ast_expr(tmp, &value, arena);
    6810           0 :                 if (res != 0) goto failed;
    6811           0 :                 Py_XDECREF(tmp);
    6812           0 :                 tmp = NULL;
    6813             :         } else {
    6814           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
    6815           0 :                 return 1;
    6816             :         }
    6817           0 :         *out = keyword(arg, value, arena);
    6818           0 :         return 0;
    6819             : failed:
    6820           0 :         Py_XDECREF(tmp);
    6821           0 :         return 1;
    6822             : }
    6823             : 
    6824             : int
    6825           0 : obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
    6826             : {
    6827           0 :         PyObject* tmp = NULL;
    6828             :         identifier name;
    6829             :         identifier asname;
    6830             : 
    6831           0 :         if (_PyObject_HasAttrId(obj, &PyId_name)) {
    6832             :                 int res;
    6833           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_name);
    6834           0 :                 if (tmp == NULL) goto failed;
    6835           0 :                 res = obj2ast_identifier(tmp, &name, arena);
    6836           0 :                 if (res != 0) goto failed;
    6837           0 :                 Py_XDECREF(tmp);
    6838           0 :                 tmp = NULL;
    6839             :         } else {
    6840           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
    6841           0 :                 return 1;
    6842             :         }
    6843           0 :         if (_PyObject_HasAttrId(obj, &PyId_asname)) {
    6844             :                 int res;
    6845           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_asname);
    6846           0 :                 if (tmp == NULL) goto failed;
    6847           0 :                 res = obj2ast_identifier(tmp, &asname, arena);
    6848           0 :                 if (res != 0) goto failed;
    6849           0 :                 Py_XDECREF(tmp);
    6850           0 :                 tmp = NULL;
    6851             :         } else {
    6852           0 :                 asname = NULL;
    6853             :         }
    6854           0 :         *out = alias(name, asname, arena);
    6855           0 :         return 0;
    6856             : failed:
    6857           0 :         Py_XDECREF(tmp);
    6858           0 :         return 1;
    6859             : }
    6860             : 
    6861             : int
    6862           0 : obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
    6863             : {
    6864           0 :         PyObject* tmp = NULL;
    6865             :         expr_ty context_expr;
    6866             :         expr_ty optional_vars;
    6867             : 
    6868           0 :         if (_PyObject_HasAttrId(obj, &PyId_context_expr)) {
    6869             :                 int res;
    6870           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr);
    6871           0 :                 if (tmp == NULL) goto failed;
    6872           0 :                 res = obj2ast_expr(tmp, &context_expr, arena);
    6873           0 :                 if (res != 0) goto failed;
    6874           0 :                 Py_XDECREF(tmp);
    6875           0 :                 tmp = NULL;
    6876             :         } else {
    6877           0 :                 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
    6878           0 :                 return 1;
    6879             :         }
    6880           0 :         if (_PyObject_HasAttrId(obj, &PyId_optional_vars)) {
    6881             :                 int res;
    6882           0 :                 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars);
    6883           0 :                 if (tmp == NULL) goto failed;
    6884           0 :                 res = obj2ast_expr(tmp, &optional_vars, arena);
    6885           0 :                 if (res != 0) goto failed;
    6886           0 :                 Py_XDECREF(tmp);
    6887           0 :                 tmp = NULL;
    6888             :         } else {
    6889           0 :                 optional_vars = NULL;
    6890             :         }
    6891           0 :         *out = withitem(context_expr, optional_vars, arena);
    6892           0 :         return 0;
    6893             : failed:
    6894           0 :         Py_XDECREF(tmp);
    6895           0 :         return 1;
    6896             : }
    6897             : 
    6898             : 
    6899             : static struct PyModuleDef _astmodule = {
    6900             :   PyModuleDef_HEAD_INIT, "_ast"
    6901             : };
    6902             : PyMODINIT_FUNC
    6903           0 : PyInit__ast(void)
    6904             : {
    6905             :         PyObject *m, *d;
    6906           0 :         if (!init_types()) return NULL;
    6907           0 :         m = PyModule_Create(&_astmodule);
    6908           0 :         if (!m) return NULL;
    6909           0 :         d = PyModule_GetDict(m);
    6910           0 :         if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return
    6911             :             NULL;
    6912           0 :         if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
    6913           0 :                 return NULL;
    6914           0 :         if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return
    6915             :             NULL;
    6916           0 :         if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
    6917           0 :             return NULL;
    6918           0 :         if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type)
    6919           0 :             < 0) return NULL;
    6920           0 :         if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) <
    6921           0 :             0) return NULL;
    6922           0 :         if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return
    6923             :             NULL;
    6924           0 :         if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return
    6925             :             NULL;
    6926           0 :         if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type)
    6927           0 :             < 0) return NULL;
    6928           0 :         if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0)
    6929           0 :             return NULL;
    6930           0 :         if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0)
    6931           0 :             return NULL;
    6932           0 :         if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0)
    6933           0 :             return NULL;
    6934           0 :         if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0)
    6935           0 :             return NULL;
    6936           0 :         if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) <
    6937           0 :             0) return NULL;
    6938           0 :         if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return
    6939             :             NULL;
    6940           0 :         if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return
    6941             :             NULL;
    6942           0 :         if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL;
    6943           0 :         if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return
    6944             :             NULL;
    6945           0 :         if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return
    6946             :             NULL;
    6947           0 :         if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return
    6948             :             NULL;
    6949           0 :         if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0)
    6950           0 :             return NULL;
    6951           0 :         if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0)
    6952           0 :             return NULL;
    6953           0 :         if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) <
    6954           0 :             0) return NULL;
    6955           0 :         if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0)
    6956           0 :             return NULL;
    6957           0 :         if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0)
    6958           0 :             return NULL;
    6959           0 :         if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return
    6960             :             NULL;
    6961           0 :         if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return
    6962             :             NULL;
    6963           0 :         if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return
    6964             :             NULL;
    6965           0 :         if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0)
    6966           0 :             return NULL;
    6967           0 :         if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return
    6968             :             NULL;
    6969           0 :         if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0)
    6970           0 :             return NULL;
    6971           0 :         if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return
    6972             :             NULL;
    6973           0 :         if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0)
    6974           0 :             return NULL;
    6975           0 :         if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0)
    6976           0 :             return NULL;
    6977           0 :         if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return
    6978             :             NULL;
    6979           0 :         if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return
    6980             :             NULL;
    6981           0 :         if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return
    6982             :             NULL;
    6983           0 :         if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0)
    6984           0 :             return NULL;
    6985           0 :         if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0)
    6986           0 :             return NULL;
    6987           0 :         if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0)
    6988           0 :             return NULL;
    6989           0 :         if (PyDict_SetItemString(d, "GeneratorExp",
    6990           0 :             (PyObject*)GeneratorExp_type) < 0) return NULL;
    6991           0 :         if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return
    6992             :             NULL;
    6993           0 :         if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) <
    6994           0 :             0) return NULL;
    6995           0 :         if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0)
    6996           0 :             return NULL;
    6997           0 :         if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return
    6998             :             NULL;
    6999           0 :         if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return
    7000             :             NULL;
    7001           0 :         if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return
    7002             :             NULL;
    7003           0 :         if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return
    7004             :             NULL;
    7005           0 :         if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0)
    7006           0 :             return NULL;
    7007           0 :         if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) <
    7008           0 :             0) return NULL;
    7009           0 :         if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) <
    7010           0 :             0) return NULL;
    7011           0 :         if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0)
    7012           0 :             return NULL;
    7013           0 :         if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return
    7014             :             NULL;
    7015           0 :         if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return
    7016             :             NULL;
    7017           0 :         if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return
    7018             :             NULL;
    7019           0 :         if (PyDict_SetItemString(d, "expr_context",
    7020           0 :             (PyObject*)expr_context_type) < 0) return NULL;
    7021           0 :         if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return
    7022             :             NULL;
    7023           0 :         if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return
    7024             :             NULL;
    7025           0 :         if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return
    7026             :             NULL;
    7027           0 :         if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0)
    7028           0 :             return NULL;
    7029           0 :         if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0)
    7030           0 :             return NULL;
    7031           0 :         if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return
    7032             :             NULL;
    7033           0 :         if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return
    7034             :             NULL;
    7035           0 :         if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return
    7036             :             NULL;
    7037           0 :         if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0)
    7038           0 :             return NULL;
    7039           0 :         if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return
    7040             :             NULL;
    7041           0 :         if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0)
    7042           0 :             return NULL;
    7043           0 :         if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return
    7044             :             NULL;
    7045           0 :         if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL;
    7046           0 :         if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0)
    7047           0 :             return NULL;
    7048           0 :         if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return
    7049             :             NULL;
    7050           0 :         if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return
    7051             :             NULL;
    7052           0 :         if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return
    7053             :             NULL;
    7054           0 :         if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return
    7055             :             NULL;
    7056           0 :         if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return
    7057             :             NULL;
    7058           0 :         if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return
    7059             :             NULL;
    7060           0 :         if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0)
    7061           0 :             return NULL;
    7062           0 :         if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0)
    7063           0 :             return NULL;
    7064           0 :         if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return
    7065             :             NULL;
    7066           0 :         if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0)
    7067           0 :             return NULL;
    7068           0 :         if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0)
    7069           0 :             return NULL;
    7070           0 :         if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0)
    7071           0 :             return NULL;
    7072           0 :         if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0)
    7073           0 :             return NULL;
    7074           0 :         if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0)
    7075           0 :             return NULL;
    7076           0 :         if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return
    7077             :             NULL;
    7078           0 :         if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return
    7079             :             NULL;
    7080           0 :         if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return
    7081             :             NULL;
    7082           0 :         if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return
    7083             :             NULL;
    7084           0 :         if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL;
    7085           0 :         if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return
    7086             :             NULL;
    7087           0 :         if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL;
    7088           0 :         if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return
    7089             :             NULL;
    7090           0 :         if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL;
    7091           0 :         if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return
    7092             :             NULL;
    7093           0 :         if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL;
    7094           0 :         if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return
    7095             :             NULL;
    7096           0 :         if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL;
    7097           0 :         if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return
    7098             :             NULL;
    7099           0 :         if (PyDict_SetItemString(d, "comprehension",
    7100           0 :             (PyObject*)comprehension_type) < 0) return NULL;
    7101           0 :         if (PyDict_SetItemString(d, "excepthandler",
    7102           0 :             (PyObject*)excepthandler_type) < 0) return NULL;
    7103           0 :         if (PyDict_SetItemString(d, "ExceptHandler",
    7104           0 :             (PyObject*)ExceptHandler_type) < 0) return NULL;
    7105           0 :         if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) <
    7106           0 :             0) return NULL;
    7107           0 :         if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return
    7108             :             NULL;
    7109           0 :         if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0)
    7110           0 :             return NULL;
    7111           0 :         if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return
    7112             :             NULL;
    7113           0 :         if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0)
    7114           0 :             return NULL;
    7115           0 :         return m;
    7116             : }
    7117             : 
    7118             : 
    7119           0 : PyObject* PyAST_mod2obj(mod_ty t)
    7120             : {
    7121           0 :     init_types();
    7122           0 :     return ast2obj_mod(t);
    7123             : }
    7124             : 
    7125             : /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
    7126           0 : mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
    7127             : {
    7128             :     mod_ty res;
    7129           0 :     PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
    7130             :                             (PyObject*)Interactive_type};
    7131           0 :     char *req_name[] = {"Module", "Expression", "Interactive"};
    7132             :     int isinstance;
    7133             :     assert(0 <= mode && mode <= 2);
    7134             : 
    7135           0 :     init_types();
    7136             : 
    7137           0 :     isinstance = PyObject_IsInstance(ast, req_type[mode]);
    7138           0 :     if (isinstance == -1)
    7139           0 :         return NULL;
    7140           0 :     if (!isinstance) {
    7141           0 :         PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
    7142           0 :                      req_name[mode], Py_TYPE(ast)->tp_name);
    7143           0 :         return NULL;
    7144             :     }
    7145           0 :     if (obj2ast_mod(ast, &res, arena) != 0)
    7146           0 :         return NULL;
    7147             :     else
    7148           0 :         return res;
    7149             : }
    7150             : 
    7151           1 : int PyAST_Check(PyObject* obj)
    7152             : {
    7153           1 :     init_types();
    7154           1 :     return PyObject_IsInstance(obj, (PyObject*)&AST_type);
    7155             : }
    7156             : 
    7157             : 

Generated by: LCOV version 1.10