Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 84851:1b464f8453a4
(Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Replace 8 spaces with 4.
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Sat, 27 Jul 2013 00:01:35 +0200 |
| parents | cf8f42eadbd0 f2d557484906 |
| children | 9d26379db328 |
comparison
equal
deleted
inserted
replaced
| 84849:d543829eda7d | 84851:1b464f8453a4 |
|---|---|
| 9 static PyTypeObject *mod_type; | 9 static PyTypeObject *mod_type; |
| 10 static PyObject* ast2obj_mod(void*); | 10 static PyObject* ast2obj_mod(void*); |
| 11 static PyTypeObject *Module_type; | 11 static PyTypeObject *Module_type; |
| 12 _Py_IDENTIFIER(body); | 12 _Py_IDENTIFIER(body); |
| 13 static char *Module_fields[]={ | 13 static char *Module_fields[]={ |
| 14 "body", | 14 "body", |
| 15 }; | 15 }; |
| 16 static PyTypeObject *Interactive_type; | 16 static PyTypeObject *Interactive_type; |
| 17 static char *Interactive_fields[]={ | 17 static char *Interactive_fields[]={ |
| 18 "body", | 18 "body", |
| 19 }; | 19 }; |
| 20 static PyTypeObject *Expression_type; | 20 static PyTypeObject *Expression_type; |
| 21 static char *Expression_fields[]={ | 21 static char *Expression_fields[]={ |
| 22 "body", | 22 "body", |
| 23 }; | 23 }; |
| 24 static PyTypeObject *Suite_type; | 24 static PyTypeObject *Suite_type; |
| 25 static char *Suite_fields[]={ | 25 static char *Suite_fields[]={ |
| 26 "body", | 26 "body", |
| 27 }; | 27 }; |
| 28 static PyTypeObject *stmt_type; | 28 static PyTypeObject *stmt_type; |
| 29 _Py_IDENTIFIER(lineno); | 29 _Py_IDENTIFIER(lineno); |
| 30 _Py_IDENTIFIER(col_offset); | 30 _Py_IDENTIFIER(col_offset); |
| 31 static char *stmt_attributes[] = { | 31 static char *stmt_attributes[] = { |
| 32 "lineno", | 32 "lineno", |
| 33 "col_offset", | 33 "col_offset", |
| 34 }; | 34 }; |
| 35 static PyObject* ast2obj_stmt(void*); | 35 static PyObject* ast2obj_stmt(void*); |
| 36 static PyTypeObject *FunctionDef_type; | 36 static PyTypeObject *FunctionDef_type; |
| 37 _Py_IDENTIFIER(name); | 37 _Py_IDENTIFIER(name); |
| 38 _Py_IDENTIFIER(args); | 38 _Py_IDENTIFIER(args); |
| 39 _Py_IDENTIFIER(decorator_list); | 39 _Py_IDENTIFIER(decorator_list); |
| 40 _Py_IDENTIFIER(returns); | 40 _Py_IDENTIFIER(returns); |
| 41 static char *FunctionDef_fields[]={ | 41 static char *FunctionDef_fields[]={ |
| 42 "name", | 42 "name", |
| 43 "args", | 43 "args", |
| 44 "body", | 44 "body", |
| 45 "decorator_list", | 45 "decorator_list", |
| 46 "returns", | 46 "returns", |
| 47 }; | 47 }; |
| 48 static PyTypeObject *ClassDef_type; | 48 static PyTypeObject *ClassDef_type; |
| 49 _Py_IDENTIFIER(bases); | 49 _Py_IDENTIFIER(bases); |
| 50 _Py_IDENTIFIER(keywords); | 50 _Py_IDENTIFIER(keywords); |
| 51 _Py_IDENTIFIER(starargs); | 51 _Py_IDENTIFIER(starargs); |
| 52 _Py_IDENTIFIER(kwargs); | 52 _Py_IDENTIFIER(kwargs); |
| 53 static char *ClassDef_fields[]={ | 53 static char *ClassDef_fields[]={ |
| 54 "name", | 54 "name", |
| 55 "bases", | 55 "bases", |
| 56 "keywords", | 56 "keywords", |
| 57 "starargs", | 57 "starargs", |
| 58 "kwargs", | 58 "kwargs", |
| 59 "body", | 59 "body", |
| 60 "decorator_list", | 60 "decorator_list", |
| 61 }; | 61 }; |
| 62 static PyTypeObject *Return_type; | 62 static PyTypeObject *Return_type; |
| 63 _Py_IDENTIFIER(value); | 63 _Py_IDENTIFIER(value); |
| 64 static char *Return_fields[]={ | 64 static char *Return_fields[]={ |
| 65 "value", | 65 "value", |
| 66 }; | 66 }; |
| 67 static PyTypeObject *Delete_type; | 67 static PyTypeObject *Delete_type; |
| 68 _Py_IDENTIFIER(targets); | 68 _Py_IDENTIFIER(targets); |
| 69 static char *Delete_fields[]={ | 69 static char *Delete_fields[]={ |
| 70 "targets", | 70 "targets", |
| 71 }; | 71 }; |
| 72 static PyTypeObject *Assign_type; | 72 static PyTypeObject *Assign_type; |
| 73 static char *Assign_fields[]={ | 73 static char *Assign_fields[]={ |
| 74 "targets", | 74 "targets", |
| 75 "value", | 75 "value", |
| 76 }; | 76 }; |
| 77 static PyTypeObject *AugAssign_type; | 77 static PyTypeObject *AugAssign_type; |
| 78 _Py_IDENTIFIER(target); | 78 _Py_IDENTIFIER(target); |
| 79 _Py_IDENTIFIER(op); | 79 _Py_IDENTIFIER(op); |
| 80 static char *AugAssign_fields[]={ | 80 static char *AugAssign_fields[]={ |
| 81 "target", | 81 "target", |
| 82 "op", | 82 "op", |
| 83 "value", | 83 "value", |
| 84 }; | 84 }; |
| 85 static PyTypeObject *For_type; | 85 static PyTypeObject *For_type; |
| 86 _Py_IDENTIFIER(iter); | 86 _Py_IDENTIFIER(iter); |
| 87 _Py_IDENTIFIER(orelse); | 87 _Py_IDENTIFIER(orelse); |
| 88 static char *For_fields[]={ | 88 static char *For_fields[]={ |
| 89 "target", | 89 "target", |
| 90 "iter", | 90 "iter", |
| 91 "body", | 91 "body", |
| 92 "orelse", | 92 "orelse", |
| 93 }; | 93 }; |
| 94 static PyTypeObject *While_type; | 94 static PyTypeObject *While_type; |
| 95 _Py_IDENTIFIER(test); | 95 _Py_IDENTIFIER(test); |
| 96 static char *While_fields[]={ | 96 static char *While_fields[]={ |
| 97 "test", | 97 "test", |
| 98 "body", | 98 "body", |
| 99 "orelse", | 99 "orelse", |
| 100 }; | 100 }; |
| 101 static PyTypeObject *If_type; | 101 static PyTypeObject *If_type; |
| 102 static char *If_fields[]={ | 102 static char *If_fields[]={ |
| 103 "test", | 103 "test", |
| 104 "body", | 104 "body", |
| 105 "orelse", | 105 "orelse", |
| 106 }; | 106 }; |
| 107 static PyTypeObject *With_type; | 107 static PyTypeObject *With_type; |
| 108 _Py_IDENTIFIER(items); | 108 _Py_IDENTIFIER(items); |
| 109 static char *With_fields[]={ | 109 static char *With_fields[]={ |
| 110 "items", | 110 "items", |
| 111 "body", | 111 "body", |
| 112 }; | 112 }; |
| 113 static PyTypeObject *Raise_type; | 113 static PyTypeObject *Raise_type; |
| 114 _Py_IDENTIFIER(exc); | 114 _Py_IDENTIFIER(exc); |
| 115 _Py_IDENTIFIER(cause); | 115 _Py_IDENTIFIER(cause); |
| 116 static char *Raise_fields[]={ | 116 static char *Raise_fields[]={ |
| 117 "exc", | 117 "exc", |
| 118 "cause", | 118 "cause", |
| 119 }; | 119 }; |
| 120 static PyTypeObject *Try_type; | 120 static PyTypeObject *Try_type; |
| 121 _Py_IDENTIFIER(handlers); | 121 _Py_IDENTIFIER(handlers); |
| 122 _Py_IDENTIFIER(finalbody); | 122 _Py_IDENTIFIER(finalbody); |
| 123 static char *Try_fields[]={ | 123 static char *Try_fields[]={ |
| 124 "body", | 124 "body", |
| 125 "handlers", | 125 "handlers", |
| 126 "orelse", | 126 "orelse", |
| 127 "finalbody", | 127 "finalbody", |
| 128 }; | 128 }; |
| 129 static PyTypeObject *Assert_type; | 129 static PyTypeObject *Assert_type; |
| 130 _Py_IDENTIFIER(msg); | 130 _Py_IDENTIFIER(msg); |
| 131 static char *Assert_fields[]={ | 131 static char *Assert_fields[]={ |
| 132 "test", | 132 "test", |
| 133 "msg", | 133 "msg", |
| 134 }; | 134 }; |
| 135 static PyTypeObject *Import_type; | 135 static PyTypeObject *Import_type; |
| 136 _Py_IDENTIFIER(names); | 136 _Py_IDENTIFIER(names); |
| 137 static char *Import_fields[]={ | 137 static char *Import_fields[]={ |
| 138 "names", | 138 "names", |
| 139 }; | 139 }; |
| 140 static PyTypeObject *ImportFrom_type; | 140 static PyTypeObject *ImportFrom_type; |
| 141 _Py_IDENTIFIER(module); | 141 _Py_IDENTIFIER(module); |
| 142 _Py_IDENTIFIER(level); | 142 _Py_IDENTIFIER(level); |
| 143 static char *ImportFrom_fields[]={ | 143 static char *ImportFrom_fields[]={ |
| 144 "module", | 144 "module", |
| 145 "names", | 145 "names", |
| 146 "level", | 146 "level", |
| 147 }; | 147 }; |
| 148 static PyTypeObject *Global_type; | 148 static PyTypeObject *Global_type; |
| 149 static char *Global_fields[]={ | 149 static char *Global_fields[]={ |
| 150 "names", | 150 "names", |
| 151 }; | 151 }; |
| 152 static PyTypeObject *Nonlocal_type; | 152 static PyTypeObject *Nonlocal_type; |
| 153 static char *Nonlocal_fields[]={ | 153 static char *Nonlocal_fields[]={ |
| 154 "names", | 154 "names", |
| 155 }; | 155 }; |
| 156 static PyTypeObject *Expr_type; | 156 static PyTypeObject *Expr_type; |
| 157 static char *Expr_fields[]={ | 157 static char *Expr_fields[]={ |
| 158 "value", | 158 "value", |
| 159 }; | 159 }; |
| 160 static PyTypeObject *Pass_type; | 160 static PyTypeObject *Pass_type; |
| 161 static PyTypeObject *Break_type; | 161 static PyTypeObject *Break_type; |
| 162 static PyTypeObject *Continue_type; | 162 static PyTypeObject *Continue_type; |
| 163 static PyTypeObject *expr_type; | 163 static PyTypeObject *expr_type; |
| 164 static char *expr_attributes[] = { | 164 static char *expr_attributes[] = { |
| 165 "lineno", | 165 "lineno", |
| 166 "col_offset", | 166 "col_offset", |
| 167 }; | 167 }; |
| 168 static PyObject* ast2obj_expr(void*); | 168 static PyObject* ast2obj_expr(void*); |
| 169 static PyTypeObject *BoolOp_type; | 169 static PyTypeObject *BoolOp_type; |
| 170 _Py_IDENTIFIER(values); | 170 _Py_IDENTIFIER(values); |
| 171 static char *BoolOp_fields[]={ | 171 static char *BoolOp_fields[]={ |
| 172 "op", | 172 "op", |
| 173 "values", | 173 "values", |
| 174 }; | 174 }; |
| 175 static PyTypeObject *BinOp_type; | 175 static PyTypeObject *BinOp_type; |
| 176 _Py_IDENTIFIER(left); | 176 _Py_IDENTIFIER(left); |
| 177 _Py_IDENTIFIER(right); | 177 _Py_IDENTIFIER(right); |
| 178 static char *BinOp_fields[]={ | 178 static char *BinOp_fields[]={ |
| 179 "left", | 179 "left", |
| 180 "op", | 180 "op", |
| 181 "right", | 181 "right", |
| 182 }; | 182 }; |
| 183 static PyTypeObject *UnaryOp_type; | 183 static PyTypeObject *UnaryOp_type; |
| 184 _Py_IDENTIFIER(operand); | 184 _Py_IDENTIFIER(operand); |
| 185 static char *UnaryOp_fields[]={ | 185 static char *UnaryOp_fields[]={ |
| 186 "op", | 186 "op", |
| 187 "operand", | 187 "operand", |
| 188 }; | 188 }; |
| 189 static PyTypeObject *Lambda_type; | 189 static PyTypeObject *Lambda_type; |
| 190 static char *Lambda_fields[]={ | 190 static char *Lambda_fields[]={ |
| 191 "args", | 191 "args", |
| 192 "body", | 192 "body", |
| 193 }; | 193 }; |
| 194 static PyTypeObject *IfExp_type; | 194 static PyTypeObject *IfExp_type; |
| 195 static char *IfExp_fields[]={ | 195 static char *IfExp_fields[]={ |
| 196 "test", | 196 "test", |
| 197 "body", | 197 "body", |
| 198 "orelse", | 198 "orelse", |
| 199 }; | 199 }; |
| 200 static PyTypeObject *Dict_type; | 200 static PyTypeObject *Dict_type; |
| 201 _Py_IDENTIFIER(keys); | 201 _Py_IDENTIFIER(keys); |
| 202 static char *Dict_fields[]={ | 202 static char *Dict_fields[]={ |
| 203 "keys", | 203 "keys", |
| 204 "values", | 204 "values", |
| 205 }; | 205 }; |
| 206 static PyTypeObject *Set_type; | 206 static PyTypeObject *Set_type; |
| 207 _Py_IDENTIFIER(elts); | 207 _Py_IDENTIFIER(elts); |
| 208 static char *Set_fields[]={ | 208 static char *Set_fields[]={ |
| 209 "elts", | 209 "elts", |
| 210 }; | 210 }; |
| 211 static PyTypeObject *ListComp_type; | 211 static PyTypeObject *ListComp_type; |
| 212 _Py_IDENTIFIER(elt); | 212 _Py_IDENTIFIER(elt); |
| 213 _Py_IDENTIFIER(generators); | 213 _Py_IDENTIFIER(generators); |
| 214 static char *ListComp_fields[]={ | 214 static char *ListComp_fields[]={ |
| 215 "elt", | 215 "elt", |
| 216 "generators", | 216 "generators", |
| 217 }; | 217 }; |
| 218 static PyTypeObject *SetComp_type; | 218 static PyTypeObject *SetComp_type; |
| 219 static char *SetComp_fields[]={ | 219 static char *SetComp_fields[]={ |
| 220 "elt", | 220 "elt", |
| 221 "generators", | 221 "generators", |
| 222 }; | 222 }; |
| 223 static PyTypeObject *DictComp_type; | 223 static PyTypeObject *DictComp_type; |
| 224 _Py_IDENTIFIER(key); | 224 _Py_IDENTIFIER(key); |
| 225 static char *DictComp_fields[]={ | 225 static char *DictComp_fields[]={ |
| 226 "key", | 226 "key", |
| 227 "value", | 227 "value", |
| 228 "generators", | 228 "generators", |
| 229 }; | 229 }; |
| 230 static PyTypeObject *GeneratorExp_type; | 230 static PyTypeObject *GeneratorExp_type; |
| 231 static char *GeneratorExp_fields[]={ | 231 static char *GeneratorExp_fields[]={ |
| 232 "elt", | 232 "elt", |
| 233 "generators", | 233 "generators", |
| 234 }; | 234 }; |
| 235 static PyTypeObject *Yield_type; | 235 static PyTypeObject *Yield_type; |
| 236 static char *Yield_fields[]={ | 236 static char *Yield_fields[]={ |
| 237 "value", | 237 "value", |
| 238 }; | 238 }; |
| 239 static PyTypeObject *YieldFrom_type; | 239 static PyTypeObject *YieldFrom_type; |
| 240 static char *YieldFrom_fields[]={ | 240 static char *YieldFrom_fields[]={ |
| 241 "value", | 241 "value", |
| 242 }; | 242 }; |
| 243 static PyTypeObject *Compare_type; | 243 static PyTypeObject *Compare_type; |
| 244 _Py_IDENTIFIER(ops); | 244 _Py_IDENTIFIER(ops); |
| 245 _Py_IDENTIFIER(comparators); | 245 _Py_IDENTIFIER(comparators); |
| 246 static char *Compare_fields[]={ | 246 static char *Compare_fields[]={ |
| 247 "left", | 247 "left", |
| 248 "ops", | 248 "ops", |
| 249 "comparators", | 249 "comparators", |
| 250 }; | 250 }; |
| 251 static PyTypeObject *Call_type; | 251 static PyTypeObject *Call_type; |
| 252 _Py_IDENTIFIER(func); | 252 _Py_IDENTIFIER(func); |
| 253 static char *Call_fields[]={ | 253 static char *Call_fields[]={ |
| 254 "func", | 254 "func", |
| 255 "args", | 255 "args", |
| 256 "keywords", | 256 "keywords", |
| 257 "starargs", | 257 "starargs", |
| 258 "kwargs", | 258 "kwargs", |
| 259 }; | 259 }; |
| 260 static PyTypeObject *Num_type; | 260 static PyTypeObject *Num_type; |
| 261 _Py_IDENTIFIER(n); | 261 _Py_IDENTIFIER(n); |
| 262 static char *Num_fields[]={ | 262 static char *Num_fields[]={ |
| 263 "n", | 263 "n", |
| 264 }; | 264 }; |
| 265 static PyTypeObject *Str_type; | 265 static PyTypeObject *Str_type; |
| 266 _Py_IDENTIFIER(s); | 266 _Py_IDENTIFIER(s); |
| 267 static char *Str_fields[]={ | 267 static char *Str_fields[]={ |
| 268 "s", | 268 "s", |
| 269 }; | 269 }; |
| 270 static PyTypeObject *Bytes_type; | 270 static PyTypeObject *Bytes_type; |
| 271 static char *Bytes_fields[]={ | 271 static char *Bytes_fields[]={ |
| 272 "s", | 272 "s", |
| 273 }; | 273 }; |
| 274 static PyTypeObject *NameConstant_type; | 274 static PyTypeObject *NameConstant_type; |
| 275 static char *NameConstant_fields[]={ | 275 static char *NameConstant_fields[]={ |
| 276 "value", | 276 "value", |
| 277 }; | 277 }; |
| 278 static PyTypeObject *Ellipsis_type; | 278 static PyTypeObject *Ellipsis_type; |
| 279 static PyTypeObject *Attribute_type; | 279 static PyTypeObject *Attribute_type; |
| 280 _Py_IDENTIFIER(attr); | 280 _Py_IDENTIFIER(attr); |
| 281 _Py_IDENTIFIER(ctx); | 281 _Py_IDENTIFIER(ctx); |
| 282 static char *Attribute_fields[]={ | 282 static char *Attribute_fields[]={ |
| 283 "value", | 283 "value", |
| 284 "attr", | 284 "attr", |
| 285 "ctx", | 285 "ctx", |
| 286 }; | 286 }; |
| 287 static PyTypeObject *Subscript_type; | 287 static PyTypeObject *Subscript_type; |
| 288 _Py_IDENTIFIER(slice); | 288 _Py_IDENTIFIER(slice); |
| 289 static char *Subscript_fields[]={ | 289 static char *Subscript_fields[]={ |
| 290 "value", | 290 "value", |
| 291 "slice", | 291 "slice", |
| 292 "ctx", | 292 "ctx", |
| 293 }; | 293 }; |
| 294 static PyTypeObject *Starred_type; | 294 static PyTypeObject *Starred_type; |
| 295 static char *Starred_fields[]={ | 295 static char *Starred_fields[]={ |
| 296 "value", | 296 "value", |
| 297 "ctx", | 297 "ctx", |
| 298 }; | 298 }; |
| 299 static PyTypeObject *Name_type; | 299 static PyTypeObject *Name_type; |
| 300 _Py_IDENTIFIER(id); | 300 _Py_IDENTIFIER(id); |
| 301 static char *Name_fields[]={ | 301 static char *Name_fields[]={ |
| 302 "id", | 302 "id", |
| 303 "ctx", | 303 "ctx", |
| 304 }; | 304 }; |
| 305 static PyTypeObject *List_type; | 305 static PyTypeObject *List_type; |
| 306 static char *List_fields[]={ | 306 static char *List_fields[]={ |
| 307 "elts", | 307 "elts", |
| 308 "ctx", | 308 "ctx", |
| 309 }; | 309 }; |
| 310 static PyTypeObject *Tuple_type; | 310 static PyTypeObject *Tuple_type; |
| 311 static char *Tuple_fields[]={ | 311 static char *Tuple_fields[]={ |
| 312 "elts", | 312 "elts", |
| 313 "ctx", | 313 "ctx", |
| 314 }; | 314 }; |
| 315 static PyTypeObject *expr_context_type; | 315 static PyTypeObject *expr_context_type; |
| 316 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, | 316 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, |
| 317 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; | 317 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; |
| 318 static PyObject* ast2obj_expr_context(expr_context_ty); | 318 static PyObject* ast2obj_expr_context(expr_context_ty); |
| 327 static PyTypeObject *Slice_type; | 327 static PyTypeObject *Slice_type; |
| 328 _Py_IDENTIFIER(lower); | 328 _Py_IDENTIFIER(lower); |
| 329 _Py_IDENTIFIER(upper); | 329 _Py_IDENTIFIER(upper); |
| 330 _Py_IDENTIFIER(step); | 330 _Py_IDENTIFIER(step); |
| 331 static char *Slice_fields[]={ | 331 static char *Slice_fields[]={ |
| 332 "lower", | 332 "lower", |
| 333 "upper", | 333 "upper", |
| 334 "step", | 334 "step", |
| 335 }; | 335 }; |
| 336 static PyTypeObject *ExtSlice_type; | 336 static PyTypeObject *ExtSlice_type; |
| 337 _Py_IDENTIFIER(dims); | 337 _Py_IDENTIFIER(dims); |
| 338 static char *ExtSlice_fields[]={ | 338 static char *ExtSlice_fields[]={ |
| 339 "dims", | 339 "dims", |
| 340 }; | 340 }; |
| 341 static PyTypeObject *Index_type; | 341 static PyTypeObject *Index_type; |
| 342 static char *Index_fields[]={ | 342 static char *Index_fields[]={ |
| 343 "value", | 343 "value", |
| 344 }; | 344 }; |
| 345 static PyTypeObject *boolop_type; | 345 static PyTypeObject *boolop_type; |
| 346 static PyObject *And_singleton, *Or_singleton; | 346 static PyObject *And_singleton, *Or_singleton; |
| 347 static PyObject* ast2obj_boolop(boolop_ty); | 347 static PyObject* ast2obj_boolop(boolop_ty); |
| 348 static PyTypeObject *And_type; | 348 static PyTypeObject *And_type; |
| 390 static PyTypeObject *NotIn_type; | 390 static PyTypeObject *NotIn_type; |
| 391 static PyTypeObject *comprehension_type; | 391 static PyTypeObject *comprehension_type; |
| 392 static PyObject* ast2obj_comprehension(void*); | 392 static PyObject* ast2obj_comprehension(void*); |
| 393 _Py_IDENTIFIER(ifs); | 393 _Py_IDENTIFIER(ifs); |
| 394 static char *comprehension_fields[]={ | 394 static char *comprehension_fields[]={ |
| 395 "target", | 395 "target", |
| 396 "iter", | 396 "iter", |
| 397 "ifs", | 397 "ifs", |
| 398 }; | 398 }; |
| 399 static PyTypeObject *excepthandler_type; | 399 static PyTypeObject *excepthandler_type; |
| 400 static char *excepthandler_attributes[] = { | 400 static char *excepthandler_attributes[] = { |
| 401 "lineno", | 401 "lineno", |
| 402 "col_offset", | 402 "col_offset", |
| 403 }; | 403 }; |
| 404 static PyObject* ast2obj_excepthandler(void*); | 404 static PyObject* ast2obj_excepthandler(void*); |
| 405 static PyTypeObject *ExceptHandler_type; | 405 static PyTypeObject *ExceptHandler_type; |
| 406 _Py_IDENTIFIER(type); | 406 _Py_IDENTIFIER(type); |
| 407 static char *ExceptHandler_fields[]={ | 407 static char *ExceptHandler_fields[]={ |
| 408 "type", | 408 "type", |
| 409 "name", | 409 "name", |
| 410 "body", | 410 "body", |
| 411 }; | 411 }; |
| 412 static PyTypeObject *arguments_type; | 412 static PyTypeObject *arguments_type; |
| 413 static PyObject* ast2obj_arguments(void*); | 413 static PyObject* ast2obj_arguments(void*); |
| 414 _Py_IDENTIFIER(vararg); | 414 _Py_IDENTIFIER(vararg); |
| 415 _Py_IDENTIFIER(kwonlyargs); | 415 _Py_IDENTIFIER(kwonlyargs); |
| 416 _Py_IDENTIFIER(kw_defaults); | 416 _Py_IDENTIFIER(kw_defaults); |
| 417 _Py_IDENTIFIER(kwarg); | 417 _Py_IDENTIFIER(kwarg); |
| 418 _Py_IDENTIFIER(defaults); | 418 _Py_IDENTIFIER(defaults); |
| 419 static char *arguments_fields[]={ | 419 static char *arguments_fields[]={ |
| 420 "args", | 420 "args", |
| 421 "vararg", | 421 "vararg", |
| 422 "kwonlyargs", | 422 "kwonlyargs", |
| 423 "kw_defaults", | 423 "kw_defaults", |
| 424 "kwarg", | 424 "kwarg", |
| 425 "defaults", | 425 "defaults", |
| 426 }; | 426 }; |
| 427 static PyTypeObject *arg_type; | 427 static PyTypeObject *arg_type; |
| 428 static PyObject* ast2obj_arg(void*); | 428 static PyObject* ast2obj_arg(void*); |
| 429 static char *arg_attributes[] = { | 429 static char *arg_attributes[] = { |
| 430 "lineno", | 430 "lineno", |
| 431 "col_offset", | 431 "col_offset", |
| 432 }; | 432 }; |
| 433 _Py_IDENTIFIER(arg); | 433 _Py_IDENTIFIER(arg); |
| 434 _Py_IDENTIFIER(annotation); | 434 _Py_IDENTIFIER(annotation); |
| 435 static char *arg_fields[]={ | 435 static char *arg_fields[]={ |
| 436 "arg", | 436 "arg", |
| 437 "annotation", | 437 "annotation", |
| 438 }; | 438 }; |
| 439 static PyTypeObject *keyword_type; | 439 static PyTypeObject *keyword_type; |
| 440 static PyObject* ast2obj_keyword(void*); | 440 static PyObject* ast2obj_keyword(void*); |
| 441 static char *keyword_fields[]={ | 441 static char *keyword_fields[]={ |
| 442 "arg", | 442 "arg", |
| 443 "value", | 443 "value", |
| 444 }; | 444 }; |
| 445 static PyTypeObject *alias_type; | 445 static PyTypeObject *alias_type; |
| 446 static PyObject* ast2obj_alias(void*); | 446 static PyObject* ast2obj_alias(void*); |
| 447 _Py_IDENTIFIER(asname); | 447 _Py_IDENTIFIER(asname); |
| 448 static char *alias_fields[]={ | 448 static char *alias_fields[]={ |
| 449 "name", | 449 "name", |
| 450 "asname", | 450 "asname", |
| 451 }; | 451 }; |
| 452 static PyTypeObject *withitem_type; | 452 static PyTypeObject *withitem_type; |
| 453 static PyObject* ast2obj_withitem(void*); | 453 static PyObject* ast2obj_withitem(void*); |
| 454 _Py_IDENTIFIER(context_expr); | 454 _Py_IDENTIFIER(context_expr); |
| 455 _Py_IDENTIFIER(optional_vars); | 455 _Py_IDENTIFIER(optional_vars); |
| 456 static char *withitem_fields[]={ | 456 static char *withitem_fields[]={ |
| 457 "context_expr", | 457 "context_expr", |
| 458 "optional_vars", | 458 "optional_vars", |
| 459 }; | 459 }; |
| 460 | 460 |
| 461 | 461 |
| 462 typedef struct { | 462 typedef struct { |
| 463 PyObject_HEAD | 463 PyObject_HEAD |
| 784 } | 784 } |
| 785 | 785 |
| 786 | 786 |
| 787 static int init_types(void) | 787 static int init_types(void) |
| 788 { | 788 { |
| 789 static int initialized; | 789 static int initialized; |
| 790 if (initialized) return 1; | 790 if (initialized) return 1; |
| 791 if (add_ast_fields() < 0) return 0; | 791 if (add_ast_fields() < 0) return 0; |
| 792 mod_type = make_type("mod", &AST_type, NULL, 0); | 792 mod_type = make_type("mod", &AST_type, NULL, 0); |
| 793 if (!mod_type) return 0; | 793 if (!mod_type) return 0; |
| 794 if (!add_attributes(mod_type, NULL, 0)) return 0; | 794 if (!add_attributes(mod_type, NULL, 0)) return 0; |
| 795 Module_type = make_type("Module", mod_type, Module_fields, 1); | 795 Module_type = make_type("Module", mod_type, Module_fields, 1); |
| 796 if (!Module_type) return 0; | 796 if (!Module_type) return 0; |
| 797 Interactive_type = make_type("Interactive", mod_type, | 797 Interactive_type = make_type("Interactive", mod_type, Interactive_fields, |
| 798 Interactive_fields, 1); | 798 1); |
| 799 if (!Interactive_type) return 0; | 799 if (!Interactive_type) return 0; |
| 800 Expression_type = make_type("Expression", mod_type, Expression_fields, | 800 Expression_type = make_type("Expression", mod_type, Expression_fields, 1); |
| 801 1); | 801 if (!Expression_type) return 0; |
| 802 if (!Expression_type) return 0; | 802 Suite_type = make_type("Suite", mod_type, Suite_fields, 1); |
| 803 Suite_type = make_type("Suite", mod_type, Suite_fields, 1); | 803 if (!Suite_type) return 0; |
| 804 if (!Suite_type) return 0; | 804 stmt_type = make_type("stmt", &AST_type, NULL, 0); |
| 805 stmt_type = make_type("stmt", &AST_type, NULL, 0); | 805 if (!stmt_type) return 0; |
| 806 if (!stmt_type) return 0; | 806 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0; |
| 807 if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0; | 807 FunctionDef_type = make_type("FunctionDef", stmt_type, FunctionDef_fields, |
| 808 FunctionDef_type = make_type("FunctionDef", stmt_type, | 808 5); |
| 809 FunctionDef_fields, 5); | 809 if (!FunctionDef_type) return 0; |
| 810 if (!FunctionDef_type) return 0; | 810 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7); |
| 811 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 7); | 811 if (!ClassDef_type) return 0; |
| 812 if (!ClassDef_type) return 0; | 812 Return_type = make_type("Return", stmt_type, Return_fields, 1); |
| 813 Return_type = make_type("Return", stmt_type, Return_fields, 1); | 813 if (!Return_type) return 0; |
| 814 if (!Return_type) return 0; | 814 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1); |
| 815 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1); | 815 if (!Delete_type) return 0; |
| 816 if (!Delete_type) return 0; | 816 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2); |
| 817 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2); | 817 if (!Assign_type) return 0; |
| 818 if (!Assign_type) return 0; | 818 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3); |
| 819 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3); | 819 if (!AugAssign_type) return 0; |
| 820 if (!AugAssign_type) return 0; | 820 For_type = make_type("For", stmt_type, For_fields, 4); |
| 821 For_type = make_type("For", stmt_type, For_fields, 4); | 821 if (!For_type) return 0; |
| 822 if (!For_type) return 0; | 822 While_type = make_type("While", stmt_type, While_fields, 3); |
| 823 While_type = make_type("While", stmt_type, While_fields, 3); | 823 if (!While_type) return 0; |
| 824 if (!While_type) return 0; | 824 If_type = make_type("If", stmt_type, If_fields, 3); |
| 825 If_type = make_type("If", stmt_type, If_fields, 3); | 825 if (!If_type) return 0; |
| 826 if (!If_type) return 0; | 826 With_type = make_type("With", stmt_type, With_fields, 2); |
| 827 With_type = make_type("With", stmt_type, With_fields, 2); | 827 if (!With_type) return 0; |
| 828 if (!With_type) return 0; | 828 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2); |
| 829 Raise_type = make_type("Raise", stmt_type, Raise_fields, 2); | 829 if (!Raise_type) return 0; |
| 830 if (!Raise_type) return 0; | 830 Try_type = make_type("Try", stmt_type, Try_fields, 4); |
| 831 Try_type = make_type("Try", stmt_type, Try_fields, 4); | 831 if (!Try_type) return 0; |
| 832 if (!Try_type) return 0; | 832 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2); |
| 833 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2); | 833 if (!Assert_type) return 0; |
| 834 if (!Assert_type) return 0; | 834 Import_type = make_type("Import", stmt_type, Import_fields, 1); |
| 835 Import_type = make_type("Import", stmt_type, Import_fields, 1); | 835 if (!Import_type) return 0; |
| 836 if (!Import_type) return 0; | 836 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, 3); |
| 837 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, | 837 if (!ImportFrom_type) return 0; |
| 838 3); | 838 Global_type = make_type("Global", stmt_type, Global_fields, 1); |
| 839 if (!ImportFrom_type) return 0; | 839 if (!Global_type) return 0; |
| 840 Global_type = make_type("Global", stmt_type, Global_fields, 1); | 840 Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1); |
| 841 if (!Global_type) return 0; | 841 if (!Nonlocal_type) return 0; |
| 842 Nonlocal_type = make_type("Nonlocal", stmt_type, Nonlocal_fields, 1); | 842 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); |
| 843 if (!Nonlocal_type) return 0; | 843 if (!Expr_type) return 0; |
| 844 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); | 844 Pass_type = make_type("Pass", stmt_type, NULL, 0); |
| 845 if (!Expr_type) return 0; | 845 if (!Pass_type) return 0; |
| 846 Pass_type = make_type("Pass", stmt_type, NULL, 0); | 846 Break_type = make_type("Break", stmt_type, NULL, 0); |
| 847 if (!Pass_type) return 0; | 847 if (!Break_type) return 0; |
| 848 Break_type = make_type("Break", stmt_type, NULL, 0); | 848 Continue_type = make_type("Continue", stmt_type, NULL, 0); |
| 849 if (!Break_type) return 0; | 849 if (!Continue_type) return 0; |
| 850 Continue_type = make_type("Continue", stmt_type, NULL, 0); | 850 expr_type = make_type("expr", &AST_type, NULL, 0); |
| 851 if (!Continue_type) return 0; | 851 if (!expr_type) return 0; |
| 852 expr_type = make_type("expr", &AST_type, NULL, 0); | 852 if (!add_attributes(expr_type, expr_attributes, 2)) return 0; |
| 853 if (!expr_type) return 0; | 853 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2); |
| 854 if (!add_attributes(expr_type, expr_attributes, 2)) return 0; | 854 if (!BoolOp_type) return 0; |
| 855 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2); | 855 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3); |
| 856 if (!BoolOp_type) return 0; | 856 if (!BinOp_type) return 0; |
| 857 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3); | 857 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2); |
| 858 if (!BinOp_type) return 0; | 858 if (!UnaryOp_type) return 0; |
| 859 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2); | 859 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2); |
| 860 if (!UnaryOp_type) return 0; | 860 if (!Lambda_type) return 0; |
| 861 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2); | 861 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3); |
| 862 if (!Lambda_type) return 0; | 862 if (!IfExp_type) return 0; |
| 863 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3); | 863 Dict_type = make_type("Dict", expr_type, Dict_fields, 2); |
| 864 if (!IfExp_type) return 0; | 864 if (!Dict_type) return 0; |
| 865 Dict_type = make_type("Dict", expr_type, Dict_fields, 2); | 865 Set_type = make_type("Set", expr_type, Set_fields, 1); |
| 866 if (!Dict_type) return 0; | 866 if (!Set_type) return 0; |
| 867 Set_type = make_type("Set", expr_type, Set_fields, 1); | 867 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); |
| 868 if (!Set_type) return 0; | 868 if (!ListComp_type) return 0; |
| 869 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); | 869 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2); |
| 870 if (!ListComp_type) return 0; | 870 if (!SetComp_type) return 0; |
| 871 SetComp_type = make_type("SetComp", expr_type, SetComp_fields, 2); | 871 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3); |
| 872 if (!SetComp_type) return 0; | 872 if (!DictComp_type) return 0; |
| 873 DictComp_type = make_type("DictComp", expr_type, DictComp_fields, 3); | 873 GeneratorExp_type = make_type("GeneratorExp", expr_type, |
| 874 if (!DictComp_type) return 0; | 874 GeneratorExp_fields, 2); |
| 875 GeneratorExp_type = make_type("GeneratorExp", expr_type, | 875 if (!GeneratorExp_type) return 0; |
| 876 GeneratorExp_fields, 2); | 876 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); |
| 877 if (!GeneratorExp_type) return 0; | 877 if (!Yield_type) return 0; |
| 878 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); | 878 YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1); |
| 879 if (!Yield_type) return 0; | 879 if (!YieldFrom_type) return 0; |
| 880 YieldFrom_type = make_type("YieldFrom", expr_type, YieldFrom_fields, 1); | 880 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); |
| 881 if (!YieldFrom_type) return 0; | 881 if (!Compare_type) return 0; |
| 882 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); | 882 Call_type = make_type("Call", expr_type, Call_fields, 5); |
| 883 if (!Compare_type) return 0; | 883 if (!Call_type) return 0; |
| 884 Call_type = make_type("Call", expr_type, Call_fields, 5); | 884 Num_type = make_type("Num", expr_type, Num_fields, 1); |
| 885 if (!Call_type) return 0; | 885 if (!Num_type) return 0; |
| 886 Num_type = make_type("Num", expr_type, Num_fields, 1); | 886 Str_type = make_type("Str", expr_type, Str_fields, 1); |
| 887 if (!Num_type) return 0; | 887 if (!Str_type) return 0; |
| 888 Str_type = make_type("Str", expr_type, Str_fields, 1); | 888 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1); |
| 889 if (!Str_type) return 0; | 889 if (!Bytes_type) return 0; |
| 890 Bytes_type = make_type("Bytes", expr_type, Bytes_fields, 1); | 890 NameConstant_type = make_type("NameConstant", expr_type, |
| 891 if (!Bytes_type) return 0; | 891 NameConstant_fields, 1); |
| 892 NameConstant_type = make_type("NameConstant", expr_type, | 892 if (!NameConstant_type) return 0; |
| 893 NameConstant_fields, 1); | 893 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); |
| 894 if (!NameConstant_type) return 0; | 894 if (!Ellipsis_type) return 0; |
| 895 Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); | 895 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); |
| 896 if (!Ellipsis_type) return 0; | 896 if (!Attribute_type) return 0; |
| 897 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); | 897 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); |
| 898 if (!Attribute_type) return 0; | 898 if (!Subscript_type) return 0; |
| 899 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); | 899 Starred_type = make_type("Starred", expr_type, Starred_fields, 2); |
| 900 if (!Subscript_type) return 0; | 900 if (!Starred_type) return 0; |
| 901 Starred_type = make_type("Starred", expr_type, Starred_fields, 2); | 901 Name_type = make_type("Name", expr_type, Name_fields, 2); |
| 902 if (!Starred_type) return 0; | 902 if (!Name_type) return 0; |
| 903 Name_type = make_type("Name", expr_type, Name_fields, 2); | 903 List_type = make_type("List", expr_type, List_fields, 2); |
| 904 if (!Name_type) return 0; | 904 if (!List_type) return 0; |
| 905 List_type = make_type("List", expr_type, List_fields, 2); | 905 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); |
| 906 if (!List_type) return 0; | 906 if (!Tuple_type) return 0; |
| 907 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); | 907 expr_context_type = make_type("expr_context", &AST_type, NULL, 0); |
| 908 if (!Tuple_type) return 0; | 908 if (!expr_context_type) return 0; |
| 909 expr_context_type = make_type("expr_context", &AST_type, NULL, 0); | 909 if (!add_attributes(expr_context_type, NULL, 0)) return 0; |
| 910 if (!expr_context_type) return 0; | 910 Load_type = make_type("Load", expr_context_type, NULL, 0); |
| 911 if (!add_attributes(expr_context_type, NULL, 0)) return 0; | 911 if (!Load_type) return 0; |
| 912 Load_type = make_type("Load", expr_context_type, NULL, 0); | 912 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL); |
| 913 if (!Load_type) return 0; | 913 if (!Load_singleton) return 0; |
| 914 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL); | 914 Store_type = make_type("Store", expr_context_type, NULL, 0); |
| 915 if (!Load_singleton) return 0; | 915 if (!Store_type) return 0; |
| 916 Store_type = make_type("Store", expr_context_type, NULL, 0); | 916 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL); |
| 917 if (!Store_type) return 0; | 917 if (!Store_singleton) return 0; |
| 918 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL); | 918 Del_type = make_type("Del", expr_context_type, NULL, 0); |
| 919 if (!Store_singleton) return 0; | 919 if (!Del_type) return 0; |
| 920 Del_type = make_type("Del", expr_context_type, NULL, 0); | 920 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL); |
| 921 if (!Del_type) return 0; | 921 if (!Del_singleton) return 0; |
| 922 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL); | 922 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0); |
| 923 if (!Del_singleton) return 0; | 923 if (!AugLoad_type) return 0; |
| 924 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0); | 924 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL); |
| 925 if (!AugLoad_type) return 0; | 925 if (!AugLoad_singleton) return 0; |
| 926 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL); | 926 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0); |
| 927 if (!AugLoad_singleton) return 0; | 927 if (!AugStore_type) return 0; |
| 928 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0); | 928 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL); |
| 929 if (!AugStore_type) return 0; | 929 if (!AugStore_singleton) return 0; |
| 930 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL); | 930 Param_type = make_type("Param", expr_context_type, NULL, 0); |
| 931 if (!AugStore_singleton) return 0; | 931 if (!Param_type) return 0; |
| 932 Param_type = make_type("Param", expr_context_type, NULL, 0); | 932 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL); |
| 933 if (!Param_type) return 0; | 933 if (!Param_singleton) return 0; |
| 934 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL); | 934 slice_type = make_type("slice", &AST_type, NULL, 0); |
| 935 if (!Param_singleton) return 0; | 935 if (!slice_type) return 0; |
| 936 slice_type = make_type("slice", &AST_type, NULL, 0); | 936 if (!add_attributes(slice_type, NULL, 0)) return 0; |
| 937 if (!slice_type) return 0; | 937 Slice_type = make_type("Slice", slice_type, Slice_fields, 3); |
| 938 if (!add_attributes(slice_type, NULL, 0)) return 0; | 938 if (!Slice_type) return 0; |
| 939 Slice_type = make_type("Slice", slice_type, Slice_fields, 3); | 939 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); |
| 940 if (!Slice_type) return 0; | 940 if (!ExtSlice_type) return 0; |
| 941 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); | 941 Index_type = make_type("Index", slice_type, Index_fields, 1); |
| 942 if (!ExtSlice_type) return 0; | 942 if (!Index_type) return 0; |
| 943 Index_type = make_type("Index", slice_type, Index_fields, 1); | 943 boolop_type = make_type("boolop", &AST_type, NULL, 0); |
| 944 if (!Index_type) return 0; | 944 if (!boolop_type) return 0; |
| 945 boolop_type = make_type("boolop", &AST_type, NULL, 0); | 945 if (!add_attributes(boolop_type, NULL, 0)) return 0; |
| 946 if (!boolop_type) return 0; | 946 And_type = make_type("And", boolop_type, NULL, 0); |
| 947 if (!add_attributes(boolop_type, NULL, 0)) return 0; | 947 if (!And_type) return 0; |
| 948 And_type = make_type("And", boolop_type, NULL, 0); | 948 And_singleton = PyType_GenericNew(And_type, NULL, NULL); |
| 949 if (!And_type) return 0; | 949 if (!And_singleton) return 0; |
| 950 And_singleton = PyType_GenericNew(And_type, NULL, NULL); | 950 Or_type = make_type("Or", boolop_type, NULL, 0); |
| 951 if (!And_singleton) return 0; | 951 if (!Or_type) return 0; |
| 952 Or_type = make_type("Or", boolop_type, NULL, 0); | 952 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL); |
| 953 if (!Or_type) return 0; | 953 if (!Or_singleton) return 0; |
| 954 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL); | 954 operator_type = make_type("operator", &AST_type, NULL, 0); |
| 955 if (!Or_singleton) return 0; | 955 if (!operator_type) return 0; |
| 956 operator_type = make_type("operator", &AST_type, NULL, 0); | 956 if (!add_attributes(operator_type, NULL, 0)) return 0; |
| 957 if (!operator_type) return 0; | 957 Add_type = make_type("Add", operator_type, NULL, 0); |
| 958 if (!add_attributes(operator_type, NULL, 0)) return 0; | 958 if (!Add_type) return 0; |
| 959 Add_type = make_type("Add", operator_type, NULL, 0); | 959 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL); |
| 960 if (!Add_type) return 0; | 960 if (!Add_singleton) return 0; |
| 961 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL); | 961 Sub_type = make_type("Sub", operator_type, NULL, 0); |
| 962 if (!Add_singleton) return 0; | 962 if (!Sub_type) return 0; |
| 963 Sub_type = make_type("Sub", operator_type, NULL, 0); | 963 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL); |
| 964 if (!Sub_type) return 0; | 964 if (!Sub_singleton) return 0; |
| 965 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL); | 965 Mult_type = make_type("Mult", operator_type, NULL, 0); |
| 966 if (!Sub_singleton) return 0; | 966 if (!Mult_type) return 0; |
| 967 Mult_type = make_type("Mult", operator_type, NULL, 0); | 967 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); |
| 968 if (!Mult_type) return 0; | 968 if (!Mult_singleton) return 0; |
| 969 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); | 969 Div_type = make_type("Div", operator_type, NULL, 0); |
| 970 if (!Mult_singleton) return 0; | 970 if (!Div_type) return 0; |
| 971 Div_type = make_type("Div", operator_type, NULL, 0); | 971 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); |
| 972 if (!Div_type) return 0; | 972 if (!Div_singleton) return 0; |
| 973 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); | 973 Mod_type = make_type("Mod", operator_type, NULL, 0); |
| 974 if (!Div_singleton) return 0; | 974 if (!Mod_type) return 0; |
| 975 Mod_type = make_type("Mod", operator_type, NULL, 0); | 975 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL); |
| 976 if (!Mod_type) return 0; | 976 if (!Mod_singleton) return 0; |
| 977 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL); | 977 Pow_type = make_type("Pow", operator_type, NULL, 0); |
| 978 if (!Mod_singleton) return 0; | 978 if (!Pow_type) return 0; |
| 979 Pow_type = make_type("Pow", operator_type, NULL, 0); | 979 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL); |
| 980 if (!Pow_type) return 0; | 980 if (!Pow_singleton) return 0; |
| 981 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL); | 981 LShift_type = make_type("LShift", operator_type, NULL, 0); |
| 982 if (!Pow_singleton) return 0; | 982 if (!LShift_type) return 0; |
| 983 LShift_type = make_type("LShift", operator_type, NULL, 0); | 983 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL); |
| 984 if (!LShift_type) return 0; | 984 if (!LShift_singleton) return 0; |
| 985 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL); | 985 RShift_type = make_type("RShift", operator_type, NULL, 0); |
| 986 if (!LShift_singleton) return 0; | 986 if (!RShift_type) return 0; |
| 987 RShift_type = make_type("RShift", operator_type, NULL, 0); | 987 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL); |
| 988 if (!RShift_type) return 0; | 988 if (!RShift_singleton) return 0; |
| 989 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL); | 989 BitOr_type = make_type("BitOr", operator_type, NULL, 0); |
| 990 if (!RShift_singleton) return 0; | 990 if (!BitOr_type) return 0; |
| 991 BitOr_type = make_type("BitOr", operator_type, NULL, 0); | 991 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL); |
| 992 if (!BitOr_type) return 0; | 992 if (!BitOr_singleton) return 0; |
| 993 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL); | 993 BitXor_type = make_type("BitXor", operator_type, NULL, 0); |
| 994 if (!BitOr_singleton) return 0; | 994 if (!BitXor_type) return 0; |
| 995 BitXor_type = make_type("BitXor", operator_type, NULL, 0); | 995 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL); |
| 996 if (!BitXor_type) return 0; | 996 if (!BitXor_singleton) return 0; |
| 997 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL); | 997 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0); |
| 998 if (!BitXor_singleton) return 0; | 998 if (!BitAnd_type) return 0; |
| 999 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0); | 999 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL); |
| 1000 if (!BitAnd_type) return 0; | 1000 if (!BitAnd_singleton) return 0; |
| 1001 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL); | 1001 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0); |
| 1002 if (!BitAnd_singleton) return 0; | 1002 if (!FloorDiv_type) return 0; |
| 1003 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0); | 1003 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL); |
| 1004 if (!FloorDiv_type) return 0; | 1004 if (!FloorDiv_singleton) return 0; |
| 1005 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL); | 1005 unaryop_type = make_type("unaryop", &AST_type, NULL, 0); |
| 1006 if (!FloorDiv_singleton) return 0; | 1006 if (!unaryop_type) return 0; |
| 1007 unaryop_type = make_type("unaryop", &AST_type, NULL, 0); | 1007 if (!add_attributes(unaryop_type, NULL, 0)) return 0; |
| 1008 if (!unaryop_type) return 0; | 1008 Invert_type = make_type("Invert", unaryop_type, NULL, 0); |
| 1009 if (!add_attributes(unaryop_type, NULL, 0)) return 0; | 1009 if (!Invert_type) return 0; |
| 1010 Invert_type = make_type("Invert", unaryop_type, NULL, 0); | 1010 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL); |
| 1011 if (!Invert_type) return 0; | 1011 if (!Invert_singleton) return 0; |
| 1012 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL); | 1012 Not_type = make_type("Not", unaryop_type, NULL, 0); |
| 1013 if (!Invert_singleton) return 0; | 1013 if (!Not_type) return 0; |
| 1014 Not_type = make_type("Not", unaryop_type, NULL, 0); | 1014 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL); |
| 1015 if (!Not_type) return 0; | 1015 if (!Not_singleton) return 0; |
| 1016 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL); | 1016 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0); |
| 1017 if (!Not_singleton) return 0; | 1017 if (!UAdd_type) return 0; |
| 1018 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0); | 1018 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL); |
| 1019 if (!UAdd_type) return 0; | 1019 if (!UAdd_singleton) return 0; |
| 1020 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL); | 1020 USub_type = make_type("USub", unaryop_type, NULL, 0); |
| 1021 if (!UAdd_singleton) return 0; | 1021 if (!USub_type) return 0; |
| 1022 USub_type = make_type("USub", unaryop_type, NULL, 0); | 1022 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL); |
| 1023 if (!USub_type) return 0; | 1023 if (!USub_singleton) return 0; |
| 1024 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL); | 1024 cmpop_type = make_type("cmpop", &AST_type, NULL, 0); |
| 1025 if (!USub_singleton) return 0; | 1025 if (!cmpop_type) return 0; |
| 1026 cmpop_type = make_type("cmpop", &AST_type, NULL, 0); | 1026 if (!add_attributes(cmpop_type, NULL, 0)) return 0; |
| 1027 if (!cmpop_type) return 0; | 1027 Eq_type = make_type("Eq", cmpop_type, NULL, 0); |
| 1028 if (!add_attributes(cmpop_type, NULL, 0)) return 0; | 1028 if (!Eq_type) return 0; |
| 1029 Eq_type = make_type("Eq", cmpop_type, NULL, 0); | 1029 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL); |
| 1030 if (!Eq_type) return 0; | 1030 if (!Eq_singleton) return 0; |
| 1031 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL); | 1031 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0); |
| 1032 if (!Eq_singleton) return 0; | 1032 if (!NotEq_type) return 0; |
| 1033 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0); | 1033 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL); |
| 1034 if (!NotEq_type) return 0; | 1034 if (!NotEq_singleton) return 0; |
| 1035 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL); | 1035 Lt_type = make_type("Lt", cmpop_type, NULL, 0); |
| 1036 if (!NotEq_singleton) return 0; | 1036 if (!Lt_type) return 0; |
| 1037 Lt_type = make_type("Lt", cmpop_type, NULL, 0); | 1037 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL); |
| 1038 if (!Lt_type) return 0; | 1038 if (!Lt_singleton) return 0; |
| 1039 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL); | 1039 LtE_type = make_type("LtE", cmpop_type, NULL, 0); |
| 1040 if (!Lt_singleton) return 0; | 1040 if (!LtE_type) return 0; |
| 1041 LtE_type = make_type("LtE", cmpop_type, NULL, 0); | 1041 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL); |
| 1042 if (!LtE_type) return 0; | 1042 if (!LtE_singleton) return 0; |
| 1043 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL); | 1043 Gt_type = make_type("Gt", cmpop_type, NULL, 0); |
| 1044 if (!LtE_singleton) return 0; | 1044 if (!Gt_type) return 0; |
| 1045 Gt_type = make_type("Gt", cmpop_type, NULL, 0); | 1045 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL); |
| 1046 if (!Gt_type) return 0; | 1046 if (!Gt_singleton) return 0; |
| 1047 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL); | 1047 GtE_type = make_type("GtE", cmpop_type, NULL, 0); |
| 1048 if (!Gt_singleton) return 0; | 1048 if (!GtE_type) return 0; |
| 1049 GtE_type = make_type("GtE", cmpop_type, NULL, 0); | 1049 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL); |
| 1050 if (!GtE_type) return 0; | 1050 if (!GtE_singleton) return 0; |
| 1051 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL); | 1051 Is_type = make_type("Is", cmpop_type, NULL, 0); |
| 1052 if (!GtE_singleton) return 0; | 1052 if (!Is_type) return 0; |
| 1053 Is_type = make_type("Is", cmpop_type, NULL, 0); | 1053 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL); |
| 1054 if (!Is_type) return 0; | 1054 if (!Is_singleton) return 0; |
| 1055 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL); | 1055 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0); |
| 1056 if (!Is_singleton) return 0; | 1056 if (!IsNot_type) return 0; |
| 1057 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0); | 1057 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL); |
| 1058 if (!IsNot_type) return 0; | 1058 if (!IsNot_singleton) return 0; |
| 1059 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL); | 1059 In_type = make_type("In", cmpop_type, NULL, 0); |
| 1060 if (!IsNot_singleton) return 0; | 1060 if (!In_type) return 0; |
| 1061 In_type = make_type("In", cmpop_type, NULL, 0); | 1061 In_singleton = PyType_GenericNew(In_type, NULL, NULL); |
| 1062 if (!In_type) return 0; | 1062 if (!In_singleton) return 0; |
| 1063 In_singleton = PyType_GenericNew(In_type, NULL, NULL); | 1063 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0); |
| 1064 if (!In_singleton) return 0; | 1064 if (!NotIn_type) return 0; |
| 1065 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0); | 1065 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL); |
| 1066 if (!NotIn_type) return 0; | 1066 if (!NotIn_singleton) return 0; |
| 1067 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL); | 1067 comprehension_type = make_type("comprehension", &AST_type, |
| 1068 if (!NotIn_singleton) return 0; | 1068 comprehension_fields, 3); |
| 1069 comprehension_type = make_type("comprehension", &AST_type, | 1069 if (!comprehension_type) return 0; |
| 1070 comprehension_fields, 3); | 1070 if (!add_attributes(comprehension_type, NULL, 0)) return 0; |
| 1071 if (!comprehension_type) return 0; | 1071 excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0); |
| 1072 if (!add_attributes(comprehension_type, NULL, 0)) return 0; | 1072 if (!excepthandler_type) return 0; |
| 1073 excepthandler_type = make_type("excepthandler", &AST_type, NULL, 0); | 1073 if (!add_attributes(excepthandler_type, excepthandler_attributes, 2)) |
| 1074 if (!excepthandler_type) return 0; | 1074 return 0; |
| 1075 if (!add_attributes(excepthandler_type, excepthandler_attributes, 2)) | 1075 ExceptHandler_type = make_type("ExceptHandler", excepthandler_type, |
| 1076 return 0; | 1076 ExceptHandler_fields, 3); |
| 1077 ExceptHandler_type = make_type("ExceptHandler", excepthandler_type, | 1077 if (!ExceptHandler_type) return 0; |
| 1078 ExceptHandler_fields, 3); | 1078 arguments_type = make_type("arguments", &AST_type, arguments_fields, 6); |
| 1079 if (!ExceptHandler_type) return 0; | 1079 if (!arguments_type) return 0; |
| 1080 arguments_type = make_type("arguments", &AST_type, arguments_fields, 6); | 1080 if (!add_attributes(arguments_type, NULL, 0)) return 0; |
| 1081 if (!arguments_type) return 0; | 1081 arg_type = make_type("arg", &AST_type, arg_fields, 2); |
| 1082 if (!add_attributes(arguments_type, NULL, 0)) return 0; | 1082 if (!arg_type) return 0; |
| 1083 arg_type = make_type("arg", &AST_type, arg_fields, 2); | 1083 if (!add_attributes(arg_type, arg_attributes, 2)) return 0; |
| 1084 if (!arg_type) return 0; | 1084 keyword_type = make_type("keyword", &AST_type, keyword_fields, 2); |
| 1085 if (!add_attributes(arg_type, arg_attributes, 2)) return 0; | 1085 if (!keyword_type) return 0; |
| 1086 keyword_type = make_type("keyword", &AST_type, keyword_fields, 2); | 1086 if (!add_attributes(keyword_type, NULL, 0)) return 0; |
| 1087 if (!keyword_type) return 0; | 1087 alias_type = make_type("alias", &AST_type, alias_fields, 2); |
| 1088 if (!add_attributes(keyword_type, NULL, 0)) return 0; | 1088 if (!alias_type) return 0; |
| 1089 alias_type = make_type("alias", &AST_type, alias_fields, 2); | 1089 if (!add_attributes(alias_type, NULL, 0)) return 0; |
| 1090 if (!alias_type) return 0; | 1090 withitem_type = make_type("withitem", &AST_type, withitem_fields, 2); |
| 1091 if (!add_attributes(alias_type, NULL, 0)) return 0; | 1091 if (!withitem_type) return 0; |
| 1092 withitem_type = make_type("withitem", &AST_type, withitem_fields, 2); | 1092 if (!add_attributes(withitem_type, NULL, 0)) return 0; |
| 1093 if (!withitem_type) return 0; | 1093 initialized = 1; |
| 1094 if (!add_attributes(withitem_type, NULL, 0)) return 0; | 1094 return 1; |
| 1095 initialized = 1; | |
| 1096 return 1; | |
| 1097 } | 1095 } |
| 1098 | 1096 |
| 1099 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena); | 1097 static int obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena); |
| 1100 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena); | 1098 static int obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena); |
| 1101 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena); | 1099 static int obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena); |
| 1117 static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena); | 1115 static int obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena); |
| 1118 | 1116 |
| 1119 mod_ty | 1117 mod_ty |
| 1120 Module(asdl_seq * body, PyArena *arena) | 1118 Module(asdl_seq * body, PyArena *arena) |
| 1121 { | 1119 { |
| 1122 mod_ty p; | 1120 mod_ty p; |
| 1123 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 1121 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1124 if (!p) | 1122 if (!p) |
| 1125 return NULL; | 1123 return NULL; |
| 1126 p->kind = Module_kind; | 1124 p->kind = Module_kind; |
| 1127 p->v.Module.body = body; | 1125 p->v.Module.body = body; |
| 1128 return p; | 1126 return p; |
| 1129 } | 1127 } |
| 1130 | 1128 |
| 1131 mod_ty | 1129 mod_ty |
| 1132 Interactive(asdl_seq * body, PyArena *arena) | 1130 Interactive(asdl_seq * body, PyArena *arena) |
| 1133 { | 1131 { |
| 1134 mod_ty p; | 1132 mod_ty p; |
| 1135 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 1133 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1136 if (!p) | 1134 if (!p) |
| 1137 return NULL; | 1135 return NULL; |
| 1138 p->kind = Interactive_kind; | 1136 p->kind = Interactive_kind; |
| 1139 p->v.Interactive.body = body; | 1137 p->v.Interactive.body = body; |
| 1140 return p; | 1138 return p; |
| 1141 } | 1139 } |
| 1142 | 1140 |
| 1143 mod_ty | 1141 mod_ty |
| 1144 Expression(expr_ty body, PyArena *arena) | 1142 Expression(expr_ty body, PyArena *arena) |
| 1145 { | 1143 { |
| 1146 mod_ty p; | 1144 mod_ty p; |
| 1147 if (!body) { | 1145 if (!body) { |
| 1148 PyErr_SetString(PyExc_ValueError, | 1146 PyErr_SetString(PyExc_ValueError, |
| 1149 "field body is required for Expression"); | 1147 "field body is required for Expression"); |
| 1150 return NULL; | 1148 return NULL; |
| 1151 } | 1149 } |
| 1152 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 1150 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1153 if (!p) | 1151 if (!p) |
| 1154 return NULL; | 1152 return NULL; |
| 1155 p->kind = Expression_kind; | 1153 p->kind = Expression_kind; |
| 1156 p->v.Expression.body = body; | 1154 p->v.Expression.body = body; |
| 1157 return p; | 1155 return p; |
| 1158 } | 1156 } |
| 1159 | 1157 |
| 1160 mod_ty | 1158 mod_ty |
| 1161 Suite(asdl_seq * body, PyArena *arena) | 1159 Suite(asdl_seq * body, PyArena *arena) |
| 1162 { | 1160 { |
| 1163 mod_ty p; | 1161 mod_ty p; |
| 1164 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); | 1162 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1165 if (!p) | 1163 if (!p) |
| 1166 return NULL; | 1164 return NULL; |
| 1167 p->kind = Suite_kind; | 1165 p->kind = Suite_kind; |
| 1168 p->v.Suite.body = body; | 1166 p->v.Suite.body = body; |
| 1169 return p; | 1167 return p; |
| 1170 } | 1168 } |
| 1171 | 1169 |
| 1172 stmt_ty | 1170 stmt_ty |
| 1173 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq * | 1171 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq * |
| 1174 decorator_list, expr_ty returns, int lineno, int col_offset, | 1172 decorator_list, expr_ty returns, int lineno, int col_offset, |
| 1175 PyArena *arena) | 1173 PyArena *arena) |
| 1176 { | 1174 { |
| 1177 stmt_ty p; | 1175 stmt_ty p; |
| 1178 if (!name) { | 1176 if (!name) { |
| 1179 PyErr_SetString(PyExc_ValueError, | 1177 PyErr_SetString(PyExc_ValueError, |
| 1180 "field name is required for FunctionDef"); | 1178 "field name is required for FunctionDef"); |
| 1181 return NULL; | 1179 return NULL; |
| 1182 } | 1180 } |
| 1183 if (!args) { | 1181 if (!args) { |
| 1184 PyErr_SetString(PyExc_ValueError, | 1182 PyErr_SetString(PyExc_ValueError, |
| 1185 "field args is required for FunctionDef"); | 1183 "field args is required for FunctionDef"); |
| 1186 return NULL; | 1184 return NULL; |
| 1187 } | 1185 } |
| 1188 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1186 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1189 if (!p) | 1187 if (!p) |
| 1190 return NULL; | 1188 return NULL; |
| 1191 p->kind = FunctionDef_kind; | 1189 p->kind = FunctionDef_kind; |
| 1192 p->v.FunctionDef.name = name; | 1190 p->v.FunctionDef.name = name; |
| 1193 p->v.FunctionDef.args = args; | 1191 p->v.FunctionDef.args = args; |
| 1194 p->v.FunctionDef.body = body; | 1192 p->v.FunctionDef.body = body; |
| 1195 p->v.FunctionDef.decorator_list = decorator_list; | 1193 p->v.FunctionDef.decorator_list = decorator_list; |
| 1196 p->v.FunctionDef.returns = returns; | 1194 p->v.FunctionDef.returns = returns; |
| 1197 p->lineno = lineno; | 1195 p->lineno = lineno; |
| 1198 p->col_offset = col_offset; | 1196 p->col_offset = col_offset; |
| 1199 return p; | 1197 return p; |
| 1200 } | 1198 } |
| 1201 | 1199 |
| 1202 stmt_ty | 1200 stmt_ty |
| 1203 ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty | 1201 ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, expr_ty |
| 1204 starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list, | 1202 starargs, expr_ty kwargs, asdl_seq * body, asdl_seq * decorator_list, |
| 1205 int lineno, int col_offset, PyArena *arena) | 1203 int lineno, int col_offset, PyArena *arena) |
| 1206 { | 1204 { |
| 1207 stmt_ty p; | 1205 stmt_ty p; |
| 1208 if (!name) { | 1206 if (!name) { |
| 1209 PyErr_SetString(PyExc_ValueError, | 1207 PyErr_SetString(PyExc_ValueError, |
| 1210 "field name is required for ClassDef"); | 1208 "field name is required for ClassDef"); |
| 1211 return NULL; | 1209 return NULL; |
| 1212 } | 1210 } |
| 1213 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1211 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1214 if (!p) | 1212 if (!p) |
| 1215 return NULL; | 1213 return NULL; |
| 1216 p->kind = ClassDef_kind; | 1214 p->kind = ClassDef_kind; |
| 1217 p->v.ClassDef.name = name; | 1215 p->v.ClassDef.name = name; |
| 1218 p->v.ClassDef.bases = bases; | 1216 p->v.ClassDef.bases = bases; |
| 1219 p->v.ClassDef.keywords = keywords; | 1217 p->v.ClassDef.keywords = keywords; |
| 1220 p->v.ClassDef.starargs = starargs; | 1218 p->v.ClassDef.starargs = starargs; |
| 1221 p->v.ClassDef.kwargs = kwargs; | 1219 p->v.ClassDef.kwargs = kwargs; |
| 1222 p->v.ClassDef.body = body; | 1220 p->v.ClassDef.body = body; |
| 1223 p->v.ClassDef.decorator_list = decorator_list; | 1221 p->v.ClassDef.decorator_list = decorator_list; |
| 1224 p->lineno = lineno; | 1222 p->lineno = lineno; |
| 1225 p->col_offset = col_offset; | 1223 p->col_offset = col_offset; |
| 1226 return p; | 1224 return p; |
| 1227 } | 1225 } |
| 1228 | 1226 |
| 1229 stmt_ty | 1227 stmt_ty |
| 1230 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) | 1228 Return(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 1231 { | 1229 { |
| 1232 stmt_ty p; | 1230 stmt_ty p; |
| 1233 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1231 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1234 if (!p) | 1232 if (!p) |
| 1235 return NULL; | 1233 return NULL; |
| 1236 p->kind = Return_kind; | 1234 p->kind = Return_kind; |
| 1237 p->v.Return.value = value; | 1235 p->v.Return.value = value; |
| 1238 p->lineno = lineno; | 1236 p->lineno = lineno; |
| 1239 p->col_offset = col_offset; | 1237 p->col_offset = col_offset; |
| 1240 return p; | 1238 return p; |
| 1241 } | 1239 } |
| 1242 | 1240 |
| 1243 stmt_ty | 1241 stmt_ty |
| 1244 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) | 1242 Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena) |
| 1245 { | 1243 { |
| 1246 stmt_ty p; | 1244 stmt_ty p; |
| 1247 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1245 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1248 if (!p) | 1246 if (!p) |
| 1249 return NULL; | 1247 return NULL; |
| 1250 p->kind = Delete_kind; | 1248 p->kind = Delete_kind; |
| 1251 p->v.Delete.targets = targets; | 1249 p->v.Delete.targets = targets; |
| 1252 p->lineno = lineno; | 1250 p->lineno = lineno; |
| 1253 p->col_offset = col_offset; | 1251 p->col_offset = col_offset; |
| 1254 return p; | 1252 return p; |
| 1255 } | 1253 } |
| 1256 | 1254 |
| 1257 stmt_ty | 1255 stmt_ty |
| 1258 Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena | 1256 Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset, PyArena |
| 1259 *arena) | 1257 *arena) |
| 1260 { | 1258 { |
| 1261 stmt_ty p; | 1259 stmt_ty p; |
| 1262 if (!value) { | 1260 if (!value) { |
| 1263 PyErr_SetString(PyExc_ValueError, | 1261 PyErr_SetString(PyExc_ValueError, |
| 1264 "field value is required for Assign"); | 1262 "field value is required for Assign"); |
| 1265 return NULL; | 1263 return NULL; |
| 1266 } | 1264 } |
| 1267 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1265 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1268 if (!p) | 1266 if (!p) |
| 1269 return NULL; | 1267 return NULL; |
| 1270 p->kind = Assign_kind; | 1268 p->kind = Assign_kind; |
| 1271 p->v.Assign.targets = targets; | 1269 p->v.Assign.targets = targets; |
| 1272 p->v.Assign.value = value; | 1270 p->v.Assign.value = value; |
| 1273 p->lineno = lineno; | 1271 p->lineno = lineno; |
| 1274 p->col_offset = col_offset; | 1272 p->col_offset = col_offset; |
| 1275 return p; | 1273 return p; |
| 1276 } | 1274 } |
| 1277 | 1275 |
| 1278 stmt_ty | 1276 stmt_ty |
| 1279 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int | 1277 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int |
| 1280 col_offset, PyArena *arena) | 1278 col_offset, PyArena *arena) |
| 1281 { | 1279 { |
| 1282 stmt_ty p; | 1280 stmt_ty p; |
| 1283 if (!target) { | 1281 if (!target) { |
| 1284 PyErr_SetString(PyExc_ValueError, | 1282 PyErr_SetString(PyExc_ValueError, |
| 1285 "field target is required for AugAssign"); | 1283 "field target is required for AugAssign"); |
| 1286 return NULL; | 1284 return NULL; |
| 1287 } | 1285 } |
| 1288 if (!op) { | 1286 if (!op) { |
| 1289 PyErr_SetString(PyExc_ValueError, | 1287 PyErr_SetString(PyExc_ValueError, |
| 1290 "field op is required for AugAssign"); | 1288 "field op is required for AugAssign"); |
| 1291 return NULL; | 1289 return NULL; |
| 1292 } | 1290 } |
| 1293 if (!value) { | 1291 if (!value) { |
| 1294 PyErr_SetString(PyExc_ValueError, | 1292 PyErr_SetString(PyExc_ValueError, |
| 1295 "field value is required for AugAssign"); | 1293 "field value is required for AugAssign"); |
| 1296 return NULL; | 1294 return NULL; |
| 1297 } | 1295 } |
| 1298 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1296 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1299 if (!p) | 1297 if (!p) |
| 1300 return NULL; | 1298 return NULL; |
| 1301 p->kind = AugAssign_kind; | 1299 p->kind = AugAssign_kind; |
| 1302 p->v.AugAssign.target = target; | 1300 p->v.AugAssign.target = target; |
| 1303 p->v.AugAssign.op = op; | 1301 p->v.AugAssign.op = op; |
| 1304 p->v.AugAssign.value = value; | 1302 p->v.AugAssign.value = value; |
| 1305 p->lineno = lineno; | 1303 p->lineno = lineno; |
| 1306 p->col_offset = col_offset; | 1304 p->col_offset = col_offset; |
| 1307 return p; | 1305 return p; |
| 1308 } | 1306 } |
| 1309 | 1307 |
| 1310 stmt_ty | 1308 stmt_ty |
| 1311 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int | 1309 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int |
| 1312 lineno, int col_offset, PyArena *arena) | 1310 lineno, int col_offset, PyArena *arena) |
| 1313 { | 1311 { |
| 1314 stmt_ty p; | 1312 stmt_ty p; |
| 1315 if (!target) { | 1313 if (!target) { |
| 1316 PyErr_SetString(PyExc_ValueError, | 1314 PyErr_SetString(PyExc_ValueError, |
| 1317 "field target is required for For"); | 1315 "field target is required for For"); |
| 1318 return NULL; | 1316 return NULL; |
| 1319 } | 1317 } |
| 1320 if (!iter) { | 1318 if (!iter) { |
| 1321 PyErr_SetString(PyExc_ValueError, | 1319 PyErr_SetString(PyExc_ValueError, |
| 1322 "field iter is required for For"); | 1320 "field iter is required for For"); |
| 1323 return NULL; | 1321 return NULL; |
| 1324 } | 1322 } |
| 1325 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1323 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1326 if (!p) | 1324 if (!p) |
| 1327 return NULL; | 1325 return NULL; |
| 1328 p->kind = For_kind; | 1326 p->kind = For_kind; |
| 1329 p->v.For.target = target; | 1327 p->v.For.target = target; |
| 1330 p->v.For.iter = iter; | 1328 p->v.For.iter = iter; |
| 1331 p->v.For.body = body; | 1329 p->v.For.body = body; |
| 1332 p->v.For.orelse = orelse; | 1330 p->v.For.orelse = orelse; |
| 1333 p->lineno = lineno; | 1331 p->lineno = lineno; |
| 1334 p->col_offset = col_offset; | 1332 p->col_offset = col_offset; |
| 1335 return p; | 1333 return p; |
| 1336 } | 1334 } |
| 1337 | 1335 |
| 1338 stmt_ty | 1336 stmt_ty |
| 1339 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int | 1337 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int |
| 1340 col_offset, PyArena *arena) | 1338 col_offset, PyArena *arena) |
| 1341 { | 1339 { |
| 1342 stmt_ty p; | 1340 stmt_ty p; |
| 1343 if (!test) { | 1341 if (!test) { |
| 1344 PyErr_SetString(PyExc_ValueError, | 1342 PyErr_SetString(PyExc_ValueError, |
| 1345 "field test is required for While"); | 1343 "field test is required for While"); |
| 1346 return NULL; | 1344 return NULL; |
| 1347 } | 1345 } |
| 1348 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1346 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1349 if (!p) | 1347 if (!p) |
| 1350 return NULL; | 1348 return NULL; |
| 1351 p->kind = While_kind; | 1349 p->kind = While_kind; |
| 1352 p->v.While.test = test; | 1350 p->v.While.test = test; |
| 1353 p->v.While.body = body; | 1351 p->v.While.body = body; |
| 1354 p->v.While.orelse = orelse; | 1352 p->v.While.orelse = orelse; |
| 1355 p->lineno = lineno; | 1353 p->lineno = lineno; |
| 1356 p->col_offset = col_offset; | 1354 p->col_offset = col_offset; |
| 1357 return p; | 1355 return p; |
| 1358 } | 1356 } |
| 1359 | 1357 |
| 1360 stmt_ty | 1358 stmt_ty |
| 1361 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int | 1359 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int |
| 1362 col_offset, PyArena *arena) | 1360 col_offset, PyArena *arena) |
| 1363 { | 1361 { |
| 1364 stmt_ty p; | 1362 stmt_ty p; |
| 1365 if (!test) { | 1363 if (!test) { |
| 1366 PyErr_SetString(PyExc_ValueError, | 1364 PyErr_SetString(PyExc_ValueError, |
| 1367 "field test is required for If"); | 1365 "field test is required for If"); |
| 1368 return NULL; | 1366 return NULL; |
| 1369 } | 1367 } |
| 1370 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1368 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1371 if (!p) | 1369 if (!p) |
| 1372 return NULL; | 1370 return NULL; |
| 1373 p->kind = If_kind; | 1371 p->kind = If_kind; |
| 1374 p->v.If.test = test; | 1372 p->v.If.test = test; |
| 1375 p->v.If.body = body; | 1373 p->v.If.body = body; |
| 1376 p->v.If.orelse = orelse; | 1374 p->v.If.orelse = orelse; |
| 1377 p->lineno = lineno; | 1375 p->lineno = lineno; |
| 1378 p->col_offset = col_offset; | 1376 p->col_offset = col_offset; |
| 1379 return p; | 1377 return p; |
| 1380 } | 1378 } |
| 1381 | 1379 |
| 1382 stmt_ty | 1380 stmt_ty |
| 1383 With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena | 1381 With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, PyArena |
| 1384 *arena) | 1382 *arena) |
| 1385 { | 1383 { |
| 1386 stmt_ty p; | 1384 stmt_ty p; |
| 1387 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1385 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1388 if (!p) | 1386 if (!p) |
| 1389 return NULL; | 1387 return NULL; |
| 1390 p->kind = With_kind; | 1388 p->kind = With_kind; |
| 1391 p->v.With.items = items; | 1389 p->v.With.items = items; |
| 1392 p->v.With.body = body; | 1390 p->v.With.body = body; |
| 1393 p->lineno = lineno; | 1391 p->lineno = lineno; |
| 1394 p->col_offset = col_offset; | 1392 p->col_offset = col_offset; |
| 1395 return p; | 1393 return p; |
| 1396 } | 1394 } |
| 1397 | 1395 |
| 1398 stmt_ty | 1396 stmt_ty |
| 1399 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena) | 1397 Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, PyArena *arena) |
| 1400 { | 1398 { |
| 1401 stmt_ty p; | 1399 stmt_ty p; |
| 1402 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1400 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1403 if (!p) | 1401 if (!p) |
| 1404 return NULL; | 1402 return NULL; |
| 1405 p->kind = Raise_kind; | 1403 p->kind = Raise_kind; |
| 1406 p->v.Raise.exc = exc; | 1404 p->v.Raise.exc = exc; |
| 1407 p->v.Raise.cause = cause; | 1405 p->v.Raise.cause = cause; |
| 1408 p->lineno = lineno; | 1406 p->lineno = lineno; |
| 1409 p->col_offset = col_offset; | 1407 p->col_offset = col_offset; |
| 1410 return p; | 1408 return p; |
| 1411 } | 1409 } |
| 1412 | 1410 |
| 1413 stmt_ty | 1411 stmt_ty |
| 1414 Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq * | 1412 Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq * |
| 1415 finalbody, int lineno, int col_offset, PyArena *arena) | 1413 finalbody, int lineno, int col_offset, PyArena *arena) |
| 1416 { | 1414 { |
| 1417 stmt_ty p; | 1415 stmt_ty p; |
| 1418 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1416 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1419 if (!p) | 1417 if (!p) |
| 1420 return NULL; | 1418 return NULL; |
| 1421 p->kind = Try_kind; | 1419 p->kind = Try_kind; |
| 1422 p->v.Try.body = body; | 1420 p->v.Try.body = body; |
| 1423 p->v.Try.handlers = handlers; | 1421 p->v.Try.handlers = handlers; |
| 1424 p->v.Try.orelse = orelse; | 1422 p->v.Try.orelse = orelse; |
| 1425 p->v.Try.finalbody = finalbody; | 1423 p->v.Try.finalbody = finalbody; |
| 1426 p->lineno = lineno; | 1424 p->lineno = lineno; |
| 1427 p->col_offset = col_offset; | 1425 p->col_offset = col_offset; |
| 1428 return p; | 1426 return p; |
| 1429 } | 1427 } |
| 1430 | 1428 |
| 1431 stmt_ty | 1429 stmt_ty |
| 1432 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) | 1430 Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena *arena) |
| 1433 { | 1431 { |
| 1434 stmt_ty p; | 1432 stmt_ty p; |
| 1435 if (!test) { | 1433 if (!test) { |
| 1436 PyErr_SetString(PyExc_ValueError, | 1434 PyErr_SetString(PyExc_ValueError, |
| 1437 "field test is required for Assert"); | 1435 "field test is required for Assert"); |
| 1438 return NULL; | 1436 return NULL; |
| 1439 } | 1437 } |
| 1440 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1438 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1441 if (!p) | 1439 if (!p) |
| 1442 return NULL; | 1440 return NULL; |
| 1443 p->kind = Assert_kind; | 1441 p->kind = Assert_kind; |
| 1444 p->v.Assert.test = test; | 1442 p->v.Assert.test = test; |
| 1445 p->v.Assert.msg = msg; | 1443 p->v.Assert.msg = msg; |
| 1446 p->lineno = lineno; | 1444 p->lineno = lineno; |
| 1447 p->col_offset = col_offset; | 1445 p->col_offset = col_offset; |
| 1448 return p; | 1446 return p; |
| 1449 } | 1447 } |
| 1450 | 1448 |
| 1451 stmt_ty | 1449 stmt_ty |
| 1452 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) | 1450 Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 1453 { | 1451 { |
| 1454 stmt_ty p; | 1452 stmt_ty p; |
| 1455 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1453 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1456 if (!p) | 1454 if (!p) |
| 1457 return NULL; | 1455 return NULL; |
| 1458 p->kind = Import_kind; | 1456 p->kind = Import_kind; |
| 1459 p->v.Import.names = names; | 1457 p->v.Import.names = names; |
| 1460 p->lineno = lineno; | 1458 p->lineno = lineno; |
| 1461 p->col_offset = col_offset; | 1459 p->col_offset = col_offset; |
| 1462 return p; | 1460 return p; |
| 1463 } | 1461 } |
| 1464 | 1462 |
| 1465 stmt_ty | 1463 stmt_ty |
| 1466 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int | 1464 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int |
| 1467 col_offset, PyArena *arena) | 1465 col_offset, PyArena *arena) |
| 1468 { | 1466 { |
| 1469 stmt_ty p; | 1467 stmt_ty p; |
| 1470 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1468 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1471 if (!p) | 1469 if (!p) |
| 1472 return NULL; | 1470 return NULL; |
| 1473 p->kind = ImportFrom_kind; | 1471 p->kind = ImportFrom_kind; |
| 1474 p->v.ImportFrom.module = module; | 1472 p->v.ImportFrom.module = module; |
| 1475 p->v.ImportFrom.names = names; | 1473 p->v.ImportFrom.names = names; |
| 1476 p->v.ImportFrom.level = level; | 1474 p->v.ImportFrom.level = level; |
| 1477 p->lineno = lineno; | 1475 p->lineno = lineno; |
| 1478 p->col_offset = col_offset; | 1476 p->col_offset = col_offset; |
| 1479 return p; | 1477 return p; |
| 1480 } | 1478 } |
| 1481 | 1479 |
| 1482 stmt_ty | 1480 stmt_ty |
| 1483 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) | 1481 Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 1484 { | 1482 { |
| 1485 stmt_ty p; | 1483 stmt_ty p; |
| 1486 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1484 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1487 if (!p) | 1485 if (!p) |
| 1488 return NULL; | 1486 return NULL; |
| 1489 p->kind = Global_kind; | 1487 p->kind = Global_kind; |
| 1490 p->v.Global.names = names; | 1488 p->v.Global.names = names; |
| 1491 p->lineno = lineno; | 1489 p->lineno = lineno; |
| 1492 p->col_offset = col_offset; | 1490 p->col_offset = col_offset; |
| 1493 return p; | 1491 return p; |
| 1494 } | 1492 } |
| 1495 | 1493 |
| 1496 stmt_ty | 1494 stmt_ty |
| 1497 Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena) | 1495 Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena *arena) |
| 1498 { | 1496 { |
| 1499 stmt_ty p; | 1497 stmt_ty p; |
| 1500 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1498 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1501 if (!p) | 1499 if (!p) |
| 1502 return NULL; | 1500 return NULL; |
| 1503 p->kind = Nonlocal_kind; | 1501 p->kind = Nonlocal_kind; |
| 1504 p->v.Nonlocal.names = names; | 1502 p->v.Nonlocal.names = names; |
| 1505 p->lineno = lineno; | 1503 p->lineno = lineno; |
| 1506 p->col_offset = col_offset; | 1504 p->col_offset = col_offset; |
| 1507 return p; | 1505 return p; |
| 1508 } | 1506 } |
| 1509 | 1507 |
| 1510 stmt_ty | 1508 stmt_ty |
| 1511 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) | 1509 Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 1512 { | 1510 { |
| 1513 stmt_ty p; | 1511 stmt_ty p; |
| 1514 if (!value) { | 1512 if (!value) { |
| 1515 PyErr_SetString(PyExc_ValueError, | 1513 PyErr_SetString(PyExc_ValueError, |
| 1516 "field value is required for Expr"); | 1514 "field value is required for Expr"); |
| 1517 return NULL; | 1515 return NULL; |
| 1518 } | 1516 } |
| 1519 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1517 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1520 if (!p) | 1518 if (!p) |
| 1521 return NULL; | 1519 return NULL; |
| 1522 p->kind = Expr_kind; | 1520 p->kind = Expr_kind; |
| 1523 p->v.Expr.value = value; | 1521 p->v.Expr.value = value; |
| 1524 p->lineno = lineno; | 1522 p->lineno = lineno; |
| 1525 p->col_offset = col_offset; | 1523 p->col_offset = col_offset; |
| 1526 return p; | 1524 return p; |
| 1527 } | 1525 } |
| 1528 | 1526 |
| 1529 stmt_ty | 1527 stmt_ty |
| 1530 Pass(int lineno, int col_offset, PyArena *arena) | 1528 Pass(int lineno, int col_offset, PyArena *arena) |
| 1531 { | 1529 { |
| 1532 stmt_ty p; | 1530 stmt_ty p; |
| 1533 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1531 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1534 if (!p) | 1532 if (!p) |
| 1535 return NULL; | 1533 return NULL; |
| 1536 p->kind = Pass_kind; | 1534 p->kind = Pass_kind; |
| 1537 p->lineno = lineno; | 1535 p->lineno = lineno; |
| 1538 p->col_offset = col_offset; | 1536 p->col_offset = col_offset; |
| 1539 return p; | 1537 return p; |
| 1540 } | 1538 } |
| 1541 | 1539 |
| 1542 stmt_ty | 1540 stmt_ty |
| 1543 Break(int lineno, int col_offset, PyArena *arena) | 1541 Break(int lineno, int col_offset, PyArena *arena) |
| 1544 { | 1542 { |
| 1545 stmt_ty p; | 1543 stmt_ty p; |
| 1546 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1544 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1547 if (!p) | 1545 if (!p) |
| 1548 return NULL; | 1546 return NULL; |
| 1549 p->kind = Break_kind; | 1547 p->kind = Break_kind; |
| 1550 p->lineno = lineno; | 1548 p->lineno = lineno; |
| 1551 p->col_offset = col_offset; | 1549 p->col_offset = col_offset; |
| 1552 return p; | 1550 return p; |
| 1553 } | 1551 } |
| 1554 | 1552 |
| 1555 stmt_ty | 1553 stmt_ty |
| 1556 Continue(int lineno, int col_offset, PyArena *arena) | 1554 Continue(int lineno, int col_offset, PyArena *arena) |
| 1557 { | 1555 { |
| 1558 stmt_ty p; | 1556 stmt_ty p; |
| 1559 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); | 1557 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1560 if (!p) | 1558 if (!p) |
| 1561 return NULL; | 1559 return NULL; |
| 1562 p->kind = Continue_kind; | 1560 p->kind = Continue_kind; |
| 1563 p->lineno = lineno; | 1561 p->lineno = lineno; |
| 1564 p->col_offset = col_offset; | 1562 p->col_offset = col_offset; |
| 1565 return p; | 1563 return p; |
| 1566 } | 1564 } |
| 1567 | 1565 |
| 1568 expr_ty | 1566 expr_ty |
| 1569 BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena | 1567 BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, PyArena |
| 1570 *arena) | 1568 *arena) |
| 1571 { | 1569 { |
| 1572 expr_ty p; | 1570 expr_ty p; |
| 1573 if (!op) { | 1571 if (!op) { |
| 1574 PyErr_SetString(PyExc_ValueError, | 1572 PyErr_SetString(PyExc_ValueError, |
| 1575 "field op is required for BoolOp"); | 1573 "field op is required for BoolOp"); |
| 1576 return NULL; | 1574 return NULL; |
| 1577 } | 1575 } |
| 1578 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1576 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1579 if (!p) | 1577 if (!p) |
| 1580 return NULL; | 1578 return NULL; |
| 1581 p->kind = BoolOp_kind; | 1579 p->kind = BoolOp_kind; |
| 1582 p->v.BoolOp.op = op; | 1580 p->v.BoolOp.op = op; |
| 1583 p->v.BoolOp.values = values; | 1581 p->v.BoolOp.values = values; |
| 1584 p->lineno = lineno; | 1582 p->lineno = lineno; |
| 1585 p->col_offset = col_offset; | 1583 p->col_offset = col_offset; |
| 1586 return p; | 1584 return p; |
| 1587 } | 1585 } |
| 1588 | 1586 |
| 1589 expr_ty | 1587 expr_ty |
| 1590 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset, | 1588 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset, |
| 1591 PyArena *arena) | 1589 PyArena *arena) |
| 1592 { | 1590 { |
| 1593 expr_ty p; | 1591 expr_ty p; |
| 1594 if (!left) { | 1592 if (!left) { |
| 1595 PyErr_SetString(PyExc_ValueError, | 1593 PyErr_SetString(PyExc_ValueError, |
| 1596 "field left is required for BinOp"); | 1594 "field left is required for BinOp"); |
| 1597 return NULL; | 1595 return NULL; |
| 1598 } | 1596 } |
| 1599 if (!op) { | 1597 if (!op) { |
| 1600 PyErr_SetString(PyExc_ValueError, | 1598 PyErr_SetString(PyExc_ValueError, |
| 1601 "field op is required for BinOp"); | 1599 "field op is required for BinOp"); |
| 1602 return NULL; | 1600 return NULL; |
| 1603 } | 1601 } |
| 1604 if (!right) { | 1602 if (!right) { |
| 1605 PyErr_SetString(PyExc_ValueError, | 1603 PyErr_SetString(PyExc_ValueError, |
| 1606 "field right is required for BinOp"); | 1604 "field right is required for BinOp"); |
| 1607 return NULL; | 1605 return NULL; |
| 1608 } | 1606 } |
| 1609 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1607 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1610 if (!p) | 1608 if (!p) |
| 1611 return NULL; | 1609 return NULL; |
| 1612 p->kind = BinOp_kind; | 1610 p->kind = BinOp_kind; |
| 1613 p->v.BinOp.left = left; | 1611 p->v.BinOp.left = left; |
| 1614 p->v.BinOp.op = op; | 1612 p->v.BinOp.op = op; |
| 1615 p->v.BinOp.right = right; | 1613 p->v.BinOp.right = right; |
| 1616 p->lineno = lineno; | 1614 p->lineno = lineno; |
| 1617 p->col_offset = col_offset; | 1615 p->col_offset = col_offset; |
| 1618 return p; | 1616 return p; |
| 1619 } | 1617 } |
| 1620 | 1618 |
| 1621 expr_ty | 1619 expr_ty |
| 1622 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena | 1620 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, PyArena |
| 1623 *arena) | 1621 *arena) |
| 1624 { | 1622 { |
| 1625 expr_ty p; | 1623 expr_ty p; |
| 1626 if (!op) { | 1624 if (!op) { |
| 1627 PyErr_SetString(PyExc_ValueError, | 1625 PyErr_SetString(PyExc_ValueError, |
| 1628 "field op is required for UnaryOp"); | 1626 "field op is required for UnaryOp"); |
| 1629 return NULL; | 1627 return NULL; |
| 1630 } | 1628 } |
| 1631 if (!operand) { | 1629 if (!operand) { |
| 1632 PyErr_SetString(PyExc_ValueError, | 1630 PyErr_SetString(PyExc_ValueError, |
| 1633 "field operand is required for UnaryOp"); | 1631 "field operand is required for UnaryOp"); |
| 1634 return NULL; | 1632 return NULL; |
| 1635 } | 1633 } |
| 1636 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1634 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1637 if (!p) | 1635 if (!p) |
| 1638 return NULL; | 1636 return NULL; |
| 1639 p->kind = UnaryOp_kind; | 1637 p->kind = UnaryOp_kind; |
| 1640 p->v.UnaryOp.op = op; | 1638 p->v.UnaryOp.op = op; |
| 1641 p->v.UnaryOp.operand = operand; | 1639 p->v.UnaryOp.operand = operand; |
| 1642 p->lineno = lineno; | 1640 p->lineno = lineno; |
| 1643 p->col_offset = col_offset; | 1641 p->col_offset = col_offset; |
| 1644 return p; | 1642 return p; |
| 1645 } | 1643 } |
| 1646 | 1644 |
| 1647 expr_ty | 1645 expr_ty |
| 1648 Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena | 1646 Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena |
| 1649 *arena) | 1647 *arena) |
| 1650 { | 1648 { |
| 1651 expr_ty p; | 1649 expr_ty p; |
| 1652 if (!args) { | 1650 if (!args) { |
| 1653 PyErr_SetString(PyExc_ValueError, | 1651 PyErr_SetString(PyExc_ValueError, |
| 1654 "field args is required for Lambda"); | 1652 "field args is required for Lambda"); |
| 1655 return NULL; | 1653 return NULL; |
| 1656 } | 1654 } |
| 1657 if (!body) { | 1655 if (!body) { |
| 1658 PyErr_SetString(PyExc_ValueError, | 1656 PyErr_SetString(PyExc_ValueError, |
| 1659 "field body is required for Lambda"); | 1657 "field body is required for Lambda"); |
| 1660 return NULL; | 1658 return NULL; |
| 1661 } | 1659 } |
| 1662 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1660 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1663 if (!p) | 1661 if (!p) |
| 1664 return NULL; | 1662 return NULL; |
| 1665 p->kind = Lambda_kind; | 1663 p->kind = Lambda_kind; |
| 1666 p->v.Lambda.args = args; | 1664 p->v.Lambda.args = args; |
| 1667 p->v.Lambda.body = body; | 1665 p->v.Lambda.body = body; |
| 1668 p->lineno = lineno; | 1666 p->lineno = lineno; |
| 1669 p->col_offset = col_offset; | 1667 p->col_offset = col_offset; |
| 1670 return p; | 1668 return p; |
| 1671 } | 1669 } |
| 1672 | 1670 |
| 1673 expr_ty | 1671 expr_ty |
| 1674 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset, | 1672 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset, |
| 1675 PyArena *arena) | 1673 PyArena *arena) |
| 1676 { | 1674 { |
| 1677 expr_ty p; | 1675 expr_ty p; |
| 1678 if (!test) { | 1676 if (!test) { |
| 1679 PyErr_SetString(PyExc_ValueError, | 1677 PyErr_SetString(PyExc_ValueError, |
| 1680 "field test is required for IfExp"); | 1678 "field test is required for IfExp"); |
| 1681 return NULL; | 1679 return NULL; |
| 1682 } | 1680 } |
| 1683 if (!body) { | 1681 if (!body) { |
| 1684 PyErr_SetString(PyExc_ValueError, | 1682 PyErr_SetString(PyExc_ValueError, |
| 1685 "field body is required for IfExp"); | 1683 "field body is required for IfExp"); |
| 1686 return NULL; | 1684 return NULL; |
| 1687 } | 1685 } |
| 1688 if (!orelse) { | 1686 if (!orelse) { |
| 1689 PyErr_SetString(PyExc_ValueError, | 1687 PyErr_SetString(PyExc_ValueError, |
| 1690 "field orelse is required for IfExp"); | 1688 "field orelse is required for IfExp"); |
| 1691 return NULL; | 1689 return NULL; |
| 1692 } | 1690 } |
| 1693 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1691 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1694 if (!p) | 1692 if (!p) |
| 1695 return NULL; | 1693 return NULL; |
| 1696 p->kind = IfExp_kind; | 1694 p->kind = IfExp_kind; |
| 1697 p->v.IfExp.test = test; | 1695 p->v.IfExp.test = test; |
| 1698 p->v.IfExp.body = body; | 1696 p->v.IfExp.body = body; |
| 1699 p->v.IfExp.orelse = orelse; | 1697 p->v.IfExp.orelse = orelse; |
| 1700 p->lineno = lineno; | 1698 p->lineno = lineno; |
| 1701 p->col_offset = col_offset; | 1699 p->col_offset = col_offset; |
| 1702 return p; | 1700 return p; |
| 1703 } | 1701 } |
| 1704 | 1702 |
| 1705 expr_ty | 1703 expr_ty |
| 1706 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena | 1704 Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena |
| 1707 *arena) | 1705 *arena) |
| 1708 { | 1706 { |
| 1709 expr_ty p; | 1707 expr_ty p; |
| 1710 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1708 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1711 if (!p) | 1709 if (!p) |
| 1712 return NULL; | 1710 return NULL; |
| 1713 p->kind = Dict_kind; | 1711 p->kind = Dict_kind; |
| 1714 p->v.Dict.keys = keys; | 1712 p->v.Dict.keys = keys; |
| 1715 p->v.Dict.values = values; | 1713 p->v.Dict.values = values; |
| 1716 p->lineno = lineno; | 1714 p->lineno = lineno; |
| 1717 p->col_offset = col_offset; | 1715 p->col_offset = col_offset; |
| 1718 return p; | 1716 return p; |
| 1719 } | 1717 } |
| 1720 | 1718 |
| 1721 expr_ty | 1719 expr_ty |
| 1722 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) | 1720 Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) |
| 1723 { | 1721 { |
| 1724 expr_ty p; | 1722 expr_ty p; |
| 1725 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1723 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1726 if (!p) | 1724 if (!p) |
| 1727 return NULL; | 1725 return NULL; |
| 1728 p->kind = Set_kind; | 1726 p->kind = Set_kind; |
| 1729 p->v.Set.elts = elts; | 1727 p->v.Set.elts = elts; |
| 1730 p->lineno = lineno; | 1728 p->lineno = lineno; |
| 1731 p->col_offset = col_offset; | 1729 p->col_offset = col_offset; |
| 1732 return p; | 1730 return p; |
| 1733 } | 1731 } |
| 1734 | 1732 |
| 1735 expr_ty | 1733 expr_ty |
| 1736 ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, | 1734 ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, |
| 1737 PyArena *arena) | 1735 PyArena *arena) |
| 1738 { | 1736 { |
| 1739 expr_ty p; | 1737 expr_ty p; |
| 1740 if (!elt) { | 1738 if (!elt) { |
| 1741 PyErr_SetString(PyExc_ValueError, | 1739 PyErr_SetString(PyExc_ValueError, |
| 1742 "field elt is required for ListComp"); | 1740 "field elt is required for ListComp"); |
| 1743 return NULL; | 1741 return NULL; |
| 1744 } | 1742 } |
| 1745 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1743 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1746 if (!p) | 1744 if (!p) |
| 1747 return NULL; | 1745 return NULL; |
| 1748 p->kind = ListComp_kind; | 1746 p->kind = ListComp_kind; |
| 1749 p->v.ListComp.elt = elt; | 1747 p->v.ListComp.elt = elt; |
| 1750 p->v.ListComp.generators = generators; | 1748 p->v.ListComp.generators = generators; |
| 1751 p->lineno = lineno; | 1749 p->lineno = lineno; |
| 1752 p->col_offset = col_offset; | 1750 p->col_offset = col_offset; |
| 1753 return p; | 1751 return p; |
| 1754 } | 1752 } |
| 1755 | 1753 |
| 1756 expr_ty | 1754 expr_ty |
| 1757 SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena | 1755 SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena |
| 1758 *arena) | 1756 *arena) |
| 1759 { | 1757 { |
| 1760 expr_ty p; | 1758 expr_ty p; |
| 1761 if (!elt) { | 1759 if (!elt) { |
| 1762 PyErr_SetString(PyExc_ValueError, | 1760 PyErr_SetString(PyExc_ValueError, |
| 1763 "field elt is required for SetComp"); | 1761 "field elt is required for SetComp"); |
| 1764 return NULL; | 1762 return NULL; |
| 1765 } | 1763 } |
| 1766 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1764 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1767 if (!p) | 1765 if (!p) |
| 1768 return NULL; | 1766 return NULL; |
| 1769 p->kind = SetComp_kind; | 1767 p->kind = SetComp_kind; |
| 1770 p->v.SetComp.elt = elt; | 1768 p->v.SetComp.elt = elt; |
| 1771 p->v.SetComp.generators = generators; | 1769 p->v.SetComp.generators = generators; |
| 1772 p->lineno = lineno; | 1770 p->lineno = lineno; |
| 1773 p->col_offset = col_offset; | 1771 p->col_offset = col_offset; |
| 1774 return p; | 1772 return p; |
| 1775 } | 1773 } |
| 1776 | 1774 |
| 1777 expr_ty | 1775 expr_ty |
| 1778 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int | 1776 DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int |
| 1779 col_offset, PyArena *arena) | 1777 col_offset, PyArena *arena) |
| 1780 { | 1778 { |
| 1781 expr_ty p; | 1779 expr_ty p; |
| 1782 if (!key) { | 1780 if (!key) { |
| 1783 PyErr_SetString(PyExc_ValueError, | 1781 PyErr_SetString(PyExc_ValueError, |
| 1784 "field key is required for DictComp"); | 1782 "field key is required for DictComp"); |
| 1785 return NULL; | 1783 return NULL; |
| 1786 } | 1784 } |
| 1787 if (!value) { | 1785 if (!value) { |
| 1788 PyErr_SetString(PyExc_ValueError, | 1786 PyErr_SetString(PyExc_ValueError, |
| 1789 "field value is required for DictComp"); | 1787 "field value is required for DictComp"); |
| 1790 return NULL; | 1788 return NULL; |
| 1791 } | 1789 } |
| 1792 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1790 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1793 if (!p) | 1791 if (!p) |
| 1794 return NULL; | 1792 return NULL; |
| 1795 p->kind = DictComp_kind; | 1793 p->kind = DictComp_kind; |
| 1796 p->v.DictComp.key = key; | 1794 p->v.DictComp.key = key; |
| 1797 p->v.DictComp.value = value; | 1795 p->v.DictComp.value = value; |
| 1798 p->v.DictComp.generators = generators; | 1796 p->v.DictComp.generators = generators; |
| 1799 p->lineno = lineno; | 1797 p->lineno = lineno; |
| 1800 p->col_offset = col_offset; | 1798 p->col_offset = col_offset; |
| 1801 return p; | 1799 return p; |
| 1802 } | 1800 } |
| 1803 | 1801 |
| 1804 expr_ty | 1802 expr_ty |
| 1805 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, | 1803 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, |
| 1806 PyArena *arena) | 1804 PyArena *arena) |
| 1807 { | 1805 { |
| 1808 expr_ty p; | 1806 expr_ty p; |
| 1809 if (!elt) { | 1807 if (!elt) { |
| 1810 PyErr_SetString(PyExc_ValueError, | 1808 PyErr_SetString(PyExc_ValueError, |
| 1811 "field elt is required for GeneratorExp"); | 1809 "field elt is required for GeneratorExp"); |
| 1812 return NULL; | 1810 return NULL; |
| 1813 } | 1811 } |
| 1814 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1812 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1815 if (!p) | 1813 if (!p) |
| 1816 return NULL; | 1814 return NULL; |
| 1817 p->kind = GeneratorExp_kind; | 1815 p->kind = GeneratorExp_kind; |
| 1818 p->v.GeneratorExp.elt = elt; | 1816 p->v.GeneratorExp.elt = elt; |
| 1819 p->v.GeneratorExp.generators = generators; | 1817 p->v.GeneratorExp.generators = generators; |
| 1820 p->lineno = lineno; | 1818 p->lineno = lineno; |
| 1821 p->col_offset = col_offset; | 1819 p->col_offset = col_offset; |
| 1822 return p; | 1820 return p; |
| 1823 } | 1821 } |
| 1824 | 1822 |
| 1825 expr_ty | 1823 expr_ty |
| 1826 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) | 1824 Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 1827 { | 1825 { |
| 1828 expr_ty p; | 1826 expr_ty p; |
| 1829 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1827 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1830 if (!p) | 1828 if (!p) |
| 1831 return NULL; | 1829 return NULL; |
| 1832 p->kind = Yield_kind; | 1830 p->kind = Yield_kind; |
| 1833 p->v.Yield.value = value; | 1831 p->v.Yield.value = value; |
| 1834 p->lineno = lineno; | 1832 p->lineno = lineno; |
| 1835 p->col_offset = col_offset; | 1833 p->col_offset = col_offset; |
| 1836 return p; | 1834 return p; |
| 1837 } | 1835 } |
| 1838 | 1836 |
| 1839 expr_ty | 1837 expr_ty |
| 1840 YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena) | 1838 YieldFrom(expr_ty value, int lineno, int col_offset, PyArena *arena) |
| 1841 { | 1839 { |
| 1842 expr_ty p; | 1840 expr_ty p; |
| 1843 if (!value) { | 1841 if (!value) { |
| 1844 PyErr_SetString(PyExc_ValueError, | 1842 PyErr_SetString(PyExc_ValueError, |
| 1845 "field value is required for YieldFrom"); | 1843 "field value is required for YieldFrom"); |
| 1846 return NULL; | 1844 return NULL; |
| 1847 } | 1845 } |
| 1848 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1846 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1849 if (!p) | 1847 if (!p) |
| 1850 return NULL; | 1848 return NULL; |
| 1851 p->kind = YieldFrom_kind; | 1849 p->kind = YieldFrom_kind; |
| 1852 p->v.YieldFrom.value = value; | 1850 p->v.YieldFrom.value = value; |
| 1853 p->lineno = lineno; | 1851 p->lineno = lineno; |
| 1854 p->col_offset = col_offset; | 1852 p->col_offset = col_offset; |
| 1855 return p; | 1853 return p; |
| 1856 } | 1854 } |
| 1857 | 1855 |
| 1858 expr_ty | 1856 expr_ty |
| 1859 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, | 1857 Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, |
| 1860 int col_offset, PyArena *arena) | 1858 int col_offset, PyArena *arena) |
| 1861 { | 1859 { |
| 1862 expr_ty p; | 1860 expr_ty p; |
| 1863 if (!left) { | 1861 if (!left) { |
| 1864 PyErr_SetString(PyExc_ValueError, | 1862 PyErr_SetString(PyExc_ValueError, |
| 1865 "field left is required for Compare"); | 1863 "field left is required for Compare"); |
| 1866 return NULL; | 1864 return NULL; |
| 1867 } | 1865 } |
| 1868 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1866 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1869 if (!p) | 1867 if (!p) |
| 1870 return NULL; | 1868 return NULL; |
| 1871 p->kind = Compare_kind; | 1869 p->kind = Compare_kind; |
| 1872 p->v.Compare.left = left; | 1870 p->v.Compare.left = left; |
| 1873 p->v.Compare.ops = ops; | 1871 p->v.Compare.ops = ops; |
| 1874 p->v.Compare.comparators = comparators; | 1872 p->v.Compare.comparators = comparators; |
| 1875 p->lineno = lineno; | 1873 p->lineno = lineno; |
| 1876 p->col_offset = col_offset; | 1874 p->col_offset = col_offset; |
| 1877 return p; | 1875 return p; |
| 1878 } | 1876 } |
| 1879 | 1877 |
| 1880 expr_ty | 1878 expr_ty |
| 1881 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, | 1879 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, |
| 1882 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) | 1880 expr_ty kwargs, int lineno, int col_offset, PyArena *arena) |
| 1883 { | 1881 { |
| 1884 expr_ty p; | 1882 expr_ty p; |
| 1885 if (!func) { | 1883 if (!func) { |
| 1886 PyErr_SetString(PyExc_ValueError, | 1884 PyErr_SetString(PyExc_ValueError, |
| 1887 "field func is required for Call"); | 1885 "field func is required for Call"); |
| 1888 return NULL; | 1886 return NULL; |
| 1889 } | 1887 } |
| 1890 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1888 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1891 if (!p) | 1889 if (!p) |
| 1892 return NULL; | 1890 return NULL; |
| 1893 p->kind = Call_kind; | 1891 p->kind = Call_kind; |
| 1894 p->v.Call.func = func; | 1892 p->v.Call.func = func; |
| 1895 p->v.Call.args = args; | 1893 p->v.Call.args = args; |
| 1896 p->v.Call.keywords = keywords; | 1894 p->v.Call.keywords = keywords; |
| 1897 p->v.Call.starargs = starargs; | 1895 p->v.Call.starargs = starargs; |
| 1898 p->v.Call.kwargs = kwargs; | 1896 p->v.Call.kwargs = kwargs; |
| 1899 p->lineno = lineno; | 1897 p->lineno = lineno; |
| 1900 p->col_offset = col_offset; | 1898 p->col_offset = col_offset; |
| 1901 return p; | 1899 return p; |
| 1902 } | 1900 } |
| 1903 | 1901 |
| 1904 expr_ty | 1902 expr_ty |
| 1905 Num(object n, int lineno, int col_offset, PyArena *arena) | 1903 Num(object n, int lineno, int col_offset, PyArena *arena) |
| 1906 { | 1904 { |
| 1907 expr_ty p; | 1905 expr_ty p; |
| 1908 if (!n) { | 1906 if (!n) { |
| 1909 PyErr_SetString(PyExc_ValueError, | 1907 PyErr_SetString(PyExc_ValueError, |
| 1910 "field n is required for Num"); | 1908 "field n is required for Num"); |
| 1911 return NULL; | 1909 return NULL; |
| 1912 } | 1910 } |
| 1913 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1911 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1914 if (!p) | 1912 if (!p) |
| 1915 return NULL; | 1913 return NULL; |
| 1916 p->kind = Num_kind; | 1914 p->kind = Num_kind; |
| 1917 p->v.Num.n = n; | 1915 p->v.Num.n = n; |
| 1918 p->lineno = lineno; | 1916 p->lineno = lineno; |
| 1919 p->col_offset = col_offset; | 1917 p->col_offset = col_offset; |
| 1920 return p; | 1918 return p; |
| 1921 } | 1919 } |
| 1922 | 1920 |
| 1923 expr_ty | 1921 expr_ty |
| 1924 Str(string s, int lineno, int col_offset, PyArena *arena) | 1922 Str(string s, int lineno, int col_offset, PyArena *arena) |
| 1925 { | 1923 { |
| 1926 expr_ty p; | 1924 expr_ty p; |
| 1927 if (!s) { | 1925 if (!s) { |
| 1928 PyErr_SetString(PyExc_ValueError, | 1926 PyErr_SetString(PyExc_ValueError, |
| 1929 "field s is required for Str"); | 1927 "field s is required for Str"); |
| 1930 return NULL; | 1928 return NULL; |
| 1931 } | 1929 } |
| 1932 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1930 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1933 if (!p) | 1931 if (!p) |
| 1934 return NULL; | 1932 return NULL; |
| 1935 p->kind = Str_kind; | 1933 p->kind = Str_kind; |
| 1936 p->v.Str.s = s; | 1934 p->v.Str.s = s; |
| 1937 p->lineno = lineno; | 1935 p->lineno = lineno; |
| 1938 p->col_offset = col_offset; | 1936 p->col_offset = col_offset; |
| 1939 return p; | 1937 return p; |
| 1940 } | 1938 } |
| 1941 | 1939 |
| 1942 expr_ty | 1940 expr_ty |
| 1943 Bytes(bytes s, int lineno, int col_offset, PyArena *arena) | 1941 Bytes(bytes s, int lineno, int col_offset, PyArena *arena) |
| 1944 { | 1942 { |
| 1945 expr_ty p; | 1943 expr_ty p; |
| 1946 if (!s) { | 1944 if (!s) { |
| 1947 PyErr_SetString(PyExc_ValueError, | 1945 PyErr_SetString(PyExc_ValueError, |
| 1948 "field s is required for Bytes"); | 1946 "field s is required for Bytes"); |
| 1949 return NULL; | 1947 return NULL; |
| 1950 } | 1948 } |
| 1951 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1949 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1952 if (!p) | 1950 if (!p) |
| 1953 return NULL; | 1951 return NULL; |
| 1954 p->kind = Bytes_kind; | 1952 p->kind = Bytes_kind; |
| 1955 p->v.Bytes.s = s; | 1953 p->v.Bytes.s = s; |
| 1956 p->lineno = lineno; | 1954 p->lineno = lineno; |
| 1957 p->col_offset = col_offset; | 1955 p->col_offset = col_offset; |
| 1958 return p; | 1956 return p; |
| 1959 } | 1957 } |
| 1960 | 1958 |
| 1961 expr_ty | 1959 expr_ty |
| 1962 NameConstant(singleton value, int lineno, int col_offset, PyArena *arena) | 1960 NameConstant(singleton value, int lineno, int col_offset, PyArena *arena) |
| 1963 { | 1961 { |
| 1964 expr_ty p; | 1962 expr_ty p; |
| 1965 if (!value) { | 1963 if (!value) { |
| 1966 PyErr_SetString(PyExc_ValueError, | 1964 PyErr_SetString(PyExc_ValueError, |
| 1967 "field value is required for NameConstant"); | 1965 "field value is required for NameConstant"); |
| 1968 return NULL; | 1966 return NULL; |
| 1969 } | 1967 } |
| 1970 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1968 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1971 if (!p) | 1969 if (!p) |
| 1972 return NULL; | 1970 return NULL; |
| 1973 p->kind = NameConstant_kind; | 1971 p->kind = NameConstant_kind; |
| 1974 p->v.NameConstant.value = value; | 1972 p->v.NameConstant.value = value; |
| 1975 p->lineno = lineno; | 1973 p->lineno = lineno; |
| 1976 p->col_offset = col_offset; | 1974 p->col_offset = col_offset; |
| 1977 return p; | 1975 return p; |
| 1978 } | 1976 } |
| 1979 | 1977 |
| 1980 expr_ty | 1978 expr_ty |
| 1981 Ellipsis(int lineno, int col_offset, PyArena *arena) | 1979 Ellipsis(int lineno, int col_offset, PyArena *arena) |
| 1982 { | 1980 { |
| 1983 expr_ty p; | 1981 expr_ty p; |
| 1984 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 1982 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1985 if (!p) | 1983 if (!p) |
| 1986 return NULL; | 1984 return NULL; |
| 1987 p->kind = Ellipsis_kind; | 1985 p->kind = Ellipsis_kind; |
| 1988 p->lineno = lineno; | 1986 p->lineno = lineno; |
| 1989 p->col_offset = col_offset; | 1987 p->col_offset = col_offset; |
| 1990 return p; | 1988 return p; |
| 1991 } | 1989 } |
| 1992 | 1990 |
| 1993 expr_ty | 1991 expr_ty |
| 1994 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int | 1992 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int |
| 1995 col_offset, PyArena *arena) | 1993 col_offset, PyArena *arena) |
| 1996 { | 1994 { |
| 1997 expr_ty p; | 1995 expr_ty p; |
| 1998 if (!value) { | 1996 if (!value) { |
| 1999 PyErr_SetString(PyExc_ValueError, | 1997 PyErr_SetString(PyExc_ValueError, |
| 2000 "field value is required for Attribute"); | 1998 "field value is required for Attribute"); |
| 2001 return NULL; | 1999 return NULL; |
| 2002 } | 2000 } |
| 2003 if (!attr) { | 2001 if (!attr) { |
| 2004 PyErr_SetString(PyExc_ValueError, | 2002 PyErr_SetString(PyExc_ValueError, |
| 2005 "field attr is required for Attribute"); | 2003 "field attr is required for Attribute"); |
| 2006 return NULL; | 2004 return NULL; |
| 2007 } | 2005 } |
| 2008 if (!ctx) { | 2006 if (!ctx) { |
| 2009 PyErr_SetString(PyExc_ValueError, | 2007 PyErr_SetString(PyExc_ValueError, |
| 2010 "field ctx is required for Attribute"); | 2008 "field ctx is required for Attribute"); |
| 2011 return NULL; | 2009 return NULL; |
| 2012 } | 2010 } |
| 2013 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 2011 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2014 if (!p) | 2012 if (!p) |
| 2015 return NULL; | 2013 return NULL; |
| 2016 p->kind = Attribute_kind; | 2014 p->kind = Attribute_kind; |
| 2017 p->v.Attribute.value = value; | 2015 p->v.Attribute.value = value; |
| 2018 p->v.Attribute.attr = attr; | 2016 p->v.Attribute.attr = attr; |
| 2019 p->v.Attribute.ctx = ctx; | 2017 p->v.Attribute.ctx = ctx; |
| 2020 p->lineno = lineno; | 2018 p->lineno = lineno; |
| 2021 p->col_offset = col_offset; | 2019 p->col_offset = col_offset; |
| 2022 return p; | 2020 return p; |
| 2023 } | 2021 } |
| 2024 | 2022 |
| 2025 expr_ty | 2023 expr_ty |
| 2026 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int | 2024 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int |
| 2027 col_offset, PyArena *arena) | 2025 col_offset, PyArena *arena) |
| 2028 { | 2026 { |
| 2029 expr_ty p; | 2027 expr_ty p; |
| 2030 if (!value) { | 2028 if (!value) { |
| 2031 PyErr_SetString(PyExc_ValueError, | 2029 PyErr_SetString(PyExc_ValueError, |
| 2032 "field value is required for Subscript"); | 2030 "field value is required for Subscript"); |
| 2033 return NULL; | 2031 return NULL; |
| 2034 } | 2032 } |
| 2035 if (!slice) { | 2033 if (!slice) { |
| 2036 PyErr_SetString(PyExc_ValueError, | 2034 PyErr_SetString(PyExc_ValueError, |
| 2037 "field slice is required for Subscript"); | 2035 "field slice is required for Subscript"); |
| 2038 return NULL; | 2036 return NULL; |
| 2039 } | 2037 } |
| 2040 if (!ctx) { | 2038 if (!ctx) { |
| 2041 PyErr_SetString(PyExc_ValueError, | 2039 PyErr_SetString(PyExc_ValueError, |
| 2042 "field ctx is required for Subscript"); | 2040 "field ctx is required for Subscript"); |
| 2043 return NULL; | 2041 return NULL; |
| 2044 } | 2042 } |
| 2045 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 2043 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2046 if (!p) | 2044 if (!p) |
| 2047 return NULL; | 2045 return NULL; |
| 2048 p->kind = Subscript_kind; | 2046 p->kind = Subscript_kind; |
| 2049 p->v.Subscript.value = value; | 2047 p->v.Subscript.value = value; |
| 2050 p->v.Subscript.slice = slice; | 2048 p->v.Subscript.slice = slice; |
| 2051 p->v.Subscript.ctx = ctx; | 2049 p->v.Subscript.ctx = ctx; |
| 2052 p->lineno = lineno; | 2050 p->lineno = lineno; |
| 2053 p->col_offset = col_offset; | 2051 p->col_offset = col_offset; |
| 2054 return p; | 2052 return p; |
| 2055 } | 2053 } |
| 2056 | 2054 |
| 2057 expr_ty | 2055 expr_ty |
| 2058 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena | 2056 Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, PyArena |
| 2059 *arena) | 2057 *arena) |
| 2060 { | 2058 { |
| 2061 expr_ty p; | 2059 expr_ty p; |
| 2062 if (!value) { | 2060 if (!value) { |
| 2063 PyErr_SetString(PyExc_ValueError, | 2061 PyErr_SetString(PyExc_ValueError, |
| 2064 "field value is required for Starred"); | 2062 "field value is required for Starred"); |
| 2065 return NULL; | 2063 return NULL; |
| 2066 } | 2064 } |
| 2067 if (!ctx) { | 2065 if (!ctx) { |
| 2068 PyErr_SetString(PyExc_ValueError, | 2066 PyErr_SetString(PyExc_ValueError, |
| 2069 "field ctx is required for Starred"); | 2067 "field ctx is required for Starred"); |
| 2070 return NULL; | 2068 return NULL; |
| 2071 } | 2069 } |
| 2072 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 2070 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2073 if (!p) | 2071 if (!p) |
| 2074 return NULL; | 2072 return NULL; |
| 2075 p->kind = Starred_kind; | 2073 p->kind = Starred_kind; |
| 2076 p->v.Starred.value = value; | 2074 p->v.Starred.value = value; |
| 2077 p->v.Starred.ctx = ctx; | 2075 p->v.Starred.ctx = ctx; |
| 2078 p->lineno = lineno; | 2076 p->lineno = lineno; |
| 2079 p->col_offset = col_offset; | 2077 p->col_offset = col_offset; |
| 2080 return p; | 2078 return p; |
| 2081 } | 2079 } |
| 2082 | 2080 |
| 2083 expr_ty | 2081 expr_ty |
| 2084 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena | 2082 Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena |
| 2085 *arena) | 2083 *arena) |
| 2086 { | 2084 { |
| 2087 expr_ty p; | 2085 expr_ty p; |
| 2088 if (!id) { | 2086 if (!id) { |
| 2089 PyErr_SetString(PyExc_ValueError, | 2087 PyErr_SetString(PyExc_ValueError, |
| 2090 "field id is required for Name"); | 2088 "field id is required for Name"); |
| 2091 return NULL; | 2089 return NULL; |
| 2092 } | 2090 } |
| 2093 if (!ctx) { | 2091 if (!ctx) { |
| 2094 PyErr_SetString(PyExc_ValueError, | 2092 PyErr_SetString(PyExc_ValueError, |
| 2095 "field ctx is required for Name"); | 2093 "field ctx is required for Name"); |
| 2096 return NULL; | 2094 return NULL; |
| 2097 } | 2095 } |
| 2098 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 2096 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2099 if (!p) | 2097 if (!p) |
| 2100 return NULL; | 2098 return NULL; |
| 2101 p->kind = Name_kind; | 2099 p->kind = Name_kind; |
| 2102 p->v.Name.id = id; | 2100 p->v.Name.id = id; |
| 2103 p->v.Name.ctx = ctx; | 2101 p->v.Name.ctx = ctx; |
| 2104 p->lineno = lineno; | 2102 p->lineno = lineno; |
| 2105 p->col_offset = col_offset; | 2103 p->col_offset = col_offset; |
| 2106 return p; | 2104 return p; |
| 2107 } | 2105 } |
| 2108 | 2106 |
| 2109 expr_ty | 2107 expr_ty |
| 2110 List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena | 2108 List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena |
| 2111 *arena) | 2109 *arena) |
| 2112 { | 2110 { |
| 2113 expr_ty p; | 2111 expr_ty p; |
| 2114 if (!ctx) { | 2112 if (!ctx) { |
| 2115 PyErr_SetString(PyExc_ValueError, | 2113 PyErr_SetString(PyExc_ValueError, |
| 2116 "field ctx is required for List"); | 2114 "field ctx is required for List"); |
| 2117 return NULL; | 2115 return NULL; |
| 2118 } | 2116 } |
| 2119 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 2117 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2120 if (!p) | 2118 if (!p) |
| 2121 return NULL; | 2119 return NULL; |
| 2122 p->kind = List_kind; | 2120 p->kind = List_kind; |
| 2123 p->v.List.elts = elts; | 2121 p->v.List.elts = elts; |
| 2124 p->v.List.ctx = ctx; | 2122 p->v.List.ctx = ctx; |
| 2125 p->lineno = lineno; | 2123 p->lineno = lineno; |
| 2126 p->col_offset = col_offset; | 2124 p->col_offset = col_offset; |
| 2127 return p; | 2125 return p; |
| 2128 } | 2126 } |
| 2129 | 2127 |
| 2130 expr_ty | 2128 expr_ty |
| 2131 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena | 2129 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena |
| 2132 *arena) | 2130 *arena) |
| 2133 { | 2131 { |
| 2134 expr_ty p; | 2132 expr_ty p; |
| 2135 if (!ctx) { | 2133 if (!ctx) { |
| 2136 PyErr_SetString(PyExc_ValueError, | 2134 PyErr_SetString(PyExc_ValueError, |
| 2137 "field ctx is required for Tuple"); | 2135 "field ctx is required for Tuple"); |
| 2138 return NULL; | 2136 return NULL; |
| 2139 } | 2137 } |
| 2140 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); | 2138 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2141 if (!p) | 2139 if (!p) |
| 2142 return NULL; | 2140 return NULL; |
| 2143 p->kind = Tuple_kind; | 2141 p->kind = Tuple_kind; |
| 2144 p->v.Tuple.elts = elts; | 2142 p->v.Tuple.elts = elts; |
| 2145 p->v.Tuple.ctx = ctx; | 2143 p->v.Tuple.ctx = ctx; |
| 2146 p->lineno = lineno; | 2144 p->lineno = lineno; |
| 2147 p->col_offset = col_offset; | 2145 p->col_offset = col_offset; |
| 2148 return p; | 2146 return p; |
| 2149 } | 2147 } |
| 2150 | 2148 |
| 2151 slice_ty | 2149 slice_ty |
| 2152 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) | 2150 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 2153 { | 2151 { |
| 2154 slice_ty p; | 2152 slice_ty p; |
| 2155 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); | 2153 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2156 if (!p) | 2154 if (!p) |
| 2157 return NULL; | 2155 return NULL; |
| 2158 p->kind = Slice_kind; | 2156 p->kind = Slice_kind; |
| 2159 p->v.Slice.lower = lower; | 2157 p->v.Slice.lower = lower; |
| 2160 p->v.Slice.upper = upper; | 2158 p->v.Slice.upper = upper; |
| 2161 p->v.Slice.step = step; | 2159 p->v.Slice.step = step; |
| 2162 return p; | 2160 return p; |
| 2163 } | 2161 } |
| 2164 | 2162 |
| 2165 slice_ty | 2163 slice_ty |
| 2166 ExtSlice(asdl_seq * dims, PyArena *arena) | 2164 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 2167 { | 2165 { |
| 2168 slice_ty p; | 2166 slice_ty p; |
| 2169 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); | 2167 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2170 if (!p) | 2168 if (!p) |
| 2171 return NULL; | 2169 return NULL; |
| 2172 p->kind = ExtSlice_kind; | 2170 p->kind = ExtSlice_kind; |
| 2173 p->v.ExtSlice.dims = dims; | 2171 p->v.ExtSlice.dims = dims; |
| 2174 return p; | 2172 return p; |
| 2175 } | 2173 } |
| 2176 | 2174 |
| 2177 slice_ty | 2175 slice_ty |
| 2178 Index(expr_ty value, PyArena *arena) | 2176 Index(expr_ty value, PyArena *arena) |
| 2179 { | 2177 { |
| 2180 slice_ty p; | 2178 slice_ty p; |
| 2181 if (!value) { | 2179 if (!value) { |
| 2182 PyErr_SetString(PyExc_ValueError, | 2180 PyErr_SetString(PyExc_ValueError, |
| 2183 "field value is required for Index"); | 2181 "field value is required for Index"); |
| 2184 return NULL; | 2182 return NULL; |
| 2185 } | 2183 } |
| 2186 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); | 2184 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2187 if (!p) | 2185 if (!p) |
| 2188 return NULL; | 2186 return NULL; |
| 2189 p->kind = Index_kind; | 2187 p->kind = Index_kind; |
| 2190 p->v.Index.value = value; | 2188 p->v.Index.value = value; |
| 2191 return p; | 2189 return p; |
| 2192 } | 2190 } |
| 2193 | 2191 |
| 2194 comprehension_ty | 2192 comprehension_ty |
| 2195 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) | 2193 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 2196 { | 2194 { |
| 2197 comprehension_ty p; | 2195 comprehension_ty p; |
| 2198 if (!target) { | 2196 if (!target) { |
| 2199 PyErr_SetString(PyExc_ValueError, | 2197 PyErr_SetString(PyExc_ValueError, |
| 2200 "field target is required for comprehension"); | 2198 "field target is required for comprehension"); |
| 2201 return NULL; | 2199 return NULL; |
| 2202 } | 2200 } |
| 2203 if (!iter) { | 2201 if (!iter) { |
| 2204 PyErr_SetString(PyExc_ValueError, | 2202 PyErr_SetString(PyExc_ValueError, |
| 2205 "field iter is required for comprehension"); | 2203 "field iter is required for comprehension"); |
| 2206 return NULL; | 2204 return NULL; |
| 2207 } | 2205 } |
| 2208 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); | 2206 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2209 if (!p) | 2207 if (!p) |
| 2210 return NULL; | 2208 return NULL; |
| 2211 p->target = target; | 2209 p->target = target; |
| 2212 p->iter = iter; | 2210 p->iter = iter; |
| 2213 p->ifs = ifs; | 2211 p->ifs = ifs; |
| 2214 return p; | 2212 return p; |
| 2215 } | 2213 } |
| 2216 | 2214 |
| 2217 excepthandler_ty | 2215 excepthandler_ty |
| 2218 ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int | 2216 ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int |
| 2219 col_offset, PyArena *arena) | 2217 col_offset, PyArena *arena) |
| 2220 { | 2218 { |
| 2221 excepthandler_ty p; | 2219 excepthandler_ty p; |
| 2222 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); | 2220 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2223 if (!p) | 2221 if (!p) |
| 2224 return NULL; | 2222 return NULL; |
| 2225 p->kind = ExceptHandler_kind; | 2223 p->kind = ExceptHandler_kind; |
| 2226 p->v.ExceptHandler.type = type; | 2224 p->v.ExceptHandler.type = type; |
| 2227 p->v.ExceptHandler.name = name; | 2225 p->v.ExceptHandler.name = name; |
| 2228 p->v.ExceptHandler.body = body; | 2226 p->v.ExceptHandler.body = body; |
| 2229 p->lineno = lineno; | 2227 p->lineno = lineno; |
| 2230 p->col_offset = col_offset; | 2228 p->col_offset = col_offset; |
| 2231 return p; | 2229 return p; |
| 2232 } | 2230 } |
| 2233 | 2231 |
| 2234 arguments_ty | 2232 arguments_ty |
| 2235 arguments(asdl_seq * args, arg_ty vararg, asdl_seq * kwonlyargs, asdl_seq * | 2233 arguments(asdl_seq * args, arg_ty vararg, asdl_seq * kwonlyargs, asdl_seq * |
| 2236 kw_defaults, arg_ty kwarg, asdl_seq * defaults, PyArena *arena) | 2234 kw_defaults, arg_ty kwarg, asdl_seq * defaults, PyArena *arena) |
| 2237 { | 2235 { |
| 2238 arguments_ty p; | 2236 arguments_ty p; |
| 2239 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); | 2237 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2240 if (!p) | 2238 if (!p) |
| 2241 return NULL; | 2239 return NULL; |
| 2242 p->args = args; | 2240 p->args = args; |
| 2243 p->vararg = vararg; | 2241 p->vararg = vararg; |
| 2244 p->kwonlyargs = kwonlyargs; | 2242 p->kwonlyargs = kwonlyargs; |
| 2245 p->kw_defaults = kw_defaults; | 2243 p->kw_defaults = kw_defaults; |
| 2246 p->kwarg = kwarg; | 2244 p->kwarg = kwarg; |
| 2247 p->defaults = defaults; | 2245 p->defaults = defaults; |
| 2248 return p; | 2246 return p; |
| 2249 } | 2247 } |
| 2250 | 2248 |
| 2251 arg_ty | 2249 arg_ty |
| 2252 arg(identifier arg, expr_ty annotation, PyArena *arena) | 2250 arg(identifier arg, expr_ty annotation, PyArena *arena) |
| 2253 { | 2251 { |
| 2254 arg_ty p; | 2252 arg_ty p; |
| 2255 if (!arg) { | 2253 if (!arg) { |
| 2256 PyErr_SetString(PyExc_ValueError, | 2254 PyErr_SetString(PyExc_ValueError, |
| 2257 "field arg is required for arg"); | 2255 "field arg is required for arg"); |
| 2258 return NULL; | 2256 return NULL; |
| 2259 } | 2257 } |
| 2260 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); | 2258 p = (arg_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2261 if (!p) | 2259 if (!p) |
| 2262 return NULL; | 2260 return NULL; |
| 2263 p->arg = arg; | 2261 p->arg = arg; |
| 2264 p->annotation = annotation; | 2262 p->annotation = annotation; |
| 2265 return p; | 2263 return p; |
| 2266 } | 2264 } |
| 2267 | 2265 |
| 2268 keyword_ty | 2266 keyword_ty |
| 2269 keyword(identifier arg, expr_ty value, PyArena *arena) | 2267 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 2270 { | 2268 { |
| 2271 keyword_ty p; | 2269 keyword_ty p; |
| 2272 if (!arg) { | 2270 if (!arg) { |
| 2273 PyErr_SetString(PyExc_ValueError, | 2271 PyErr_SetString(PyExc_ValueError, |
| 2274 "field arg is required for keyword"); | 2272 "field arg is required for keyword"); |
| 2275 return NULL; | 2273 return NULL; |
| 2276 } | 2274 } |
| 2277 if (!value) { | 2275 if (!value) { |
| 2278 PyErr_SetString(PyExc_ValueError, | 2276 PyErr_SetString(PyExc_ValueError, |
| 2279 "field value is required for keyword"); | 2277 "field value is required for keyword"); |
| 2280 return NULL; | 2278 return NULL; |
| 2281 } | 2279 } |
| 2282 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); | 2280 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2283 if (!p) | 2281 if (!p) |
| 2284 return NULL; | 2282 return NULL; |
| 2285 p->arg = arg; | 2283 p->arg = arg; |
| 2286 p->value = value; | 2284 p->value = value; |
| 2287 return p; | 2285 return p; |
| 2288 } | 2286 } |
| 2289 | 2287 |
| 2290 alias_ty | 2288 alias_ty |
| 2291 alias(identifier name, identifier asname, PyArena *arena) | 2289 alias(identifier name, identifier asname, PyArena *arena) |
| 2292 { | 2290 { |
| 2293 alias_ty p; | 2291 alias_ty p; |
| 2294 if (!name) { | 2292 if (!name) { |
| 2295 PyErr_SetString(PyExc_ValueError, | 2293 PyErr_SetString(PyExc_ValueError, |
| 2296 "field name is required for alias"); | 2294 "field name is required for alias"); |
| 2297 return NULL; | 2295 return NULL; |
| 2298 } | 2296 } |
| 2299 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); | 2297 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2300 if (!p) | 2298 if (!p) |
| 2301 return NULL; | 2299 return NULL; |
| 2302 p->name = name; | 2300 p->name = name; |
| 2303 p->asname = asname; | 2301 p->asname = asname; |
| 2304 return p; | 2302 return p; |
| 2305 } | 2303 } |
| 2306 | 2304 |
| 2307 withitem_ty | 2305 withitem_ty |
| 2308 withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena) | 2306 withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena) |
| 2309 { | 2307 { |
| 2310 withitem_ty p; | 2308 withitem_ty p; |
| 2311 if (!context_expr) { | 2309 if (!context_expr) { |
| 2312 PyErr_SetString(PyExc_ValueError, | 2310 PyErr_SetString(PyExc_ValueError, |
| 2313 "field context_expr is required for withitem"); | 2311 "field context_expr is required for withitem"); |
| 2314 return NULL; | 2312 return NULL; |
| 2315 } | 2313 } |
| 2316 p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p)); | 2314 p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 2317 if (!p) | 2315 if (!p) |
| 2318 return NULL; | 2316 return NULL; |
| 2319 p->context_expr = context_expr; | 2317 p->context_expr = context_expr; |
| 2320 p->optional_vars = optional_vars; | 2318 p->optional_vars = optional_vars; |
| 2321 return p; | 2319 return p; |
| 2322 } | 2320 } |
| 2323 | 2321 |
| 2324 | 2322 |
| 2325 PyObject* | 2323 PyObject* |
| 2326 ast2obj_mod(void* _o) | 2324 ast2obj_mod(void* _o) |
| 2327 { | 2325 { |
| 2328 mod_ty o = (mod_ty)_o; | 2326 mod_ty o = (mod_ty)_o; |
| 2329 PyObject *result = NULL, *value = NULL; | 2327 PyObject *result = NULL, *value = NULL; |
| 2330 if (!o) { | 2328 if (!o) { |
| 2331 Py_INCREF(Py_None); | 2329 Py_INCREF(Py_None); |
| 2332 return Py_None; | 2330 return Py_None; |
| 2333 } | 2331 } |
| 2334 | 2332 |
| 2335 switch (o->kind) { | 2333 switch (o->kind) { |
| 2336 case Module_kind: | 2334 case Module_kind: |
| 2337 result = PyType_GenericNew(Module_type, NULL, NULL); | 2335 result = PyType_GenericNew(Module_type, NULL, NULL); |
| 2338 if (!result) goto failed; | 2336 if (!result) goto failed; |
| 2339 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); | 2337 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); |
| 2340 if (!value) goto failed; | 2338 if (!value) goto failed; |
| 2341 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2339 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2342 goto failed; | 2340 goto failed; |
| 2343 Py_DECREF(value); | 2341 Py_DECREF(value); |
| 2344 break; | 2342 break; |
| 2345 case Interactive_kind: | 2343 case Interactive_kind: |
| 2346 result = PyType_GenericNew(Interactive_type, NULL, NULL); | 2344 result = PyType_GenericNew(Interactive_type, NULL, NULL); |
| 2347 if (!result) goto failed; | 2345 if (!result) goto failed; |
| 2348 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); | 2346 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); |
| 2349 if (!value) goto failed; | 2347 if (!value) goto failed; |
| 2350 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2348 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2351 goto failed; | 2349 goto failed; |
| 2352 Py_DECREF(value); | 2350 Py_DECREF(value); |
| 2353 break; | 2351 break; |
| 2354 case Expression_kind: | 2352 case Expression_kind: |
| 2355 result = PyType_GenericNew(Expression_type, NULL, NULL); | 2353 result = PyType_GenericNew(Expression_type, NULL, NULL); |
| 2356 if (!result) goto failed; | 2354 if (!result) goto failed; |
| 2357 value = ast2obj_expr(o->v.Expression.body); | 2355 value = ast2obj_expr(o->v.Expression.body); |
| 2358 if (!value) goto failed; | 2356 if (!value) goto failed; |
| 2359 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2357 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2360 goto failed; | 2358 goto failed; |
| 2361 Py_DECREF(value); | 2359 Py_DECREF(value); |
| 2362 break; | 2360 break; |
| 2363 case Suite_kind: | 2361 case Suite_kind: |
| 2364 result = PyType_GenericNew(Suite_type, NULL, NULL); | 2362 result = PyType_GenericNew(Suite_type, NULL, NULL); |
| 2365 if (!result) goto failed; | 2363 if (!result) goto failed; |
| 2366 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); | 2364 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); |
| 2367 if (!value) goto failed; | 2365 if (!value) goto failed; |
| 2368 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2366 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2369 goto failed; | 2367 goto failed; |
| 2370 Py_DECREF(value); | 2368 Py_DECREF(value); |
| 2371 break; | 2369 break; |
| 2372 } | 2370 } |
| 2373 return result; | 2371 return result; |
| 2374 failed: | 2372 failed: |
| 2375 Py_XDECREF(value); | 2373 Py_XDECREF(value); |
| 2376 Py_XDECREF(result); | 2374 Py_XDECREF(result); |
| 2377 return NULL; | 2375 return NULL; |
| 2378 } | 2376 } |
| 2379 | 2377 |
| 2380 PyObject* | 2378 PyObject* |
| 2381 ast2obj_stmt(void* _o) | 2379 ast2obj_stmt(void* _o) |
| 2382 { | 2380 { |
| 2383 stmt_ty o = (stmt_ty)_o; | 2381 stmt_ty o = (stmt_ty)_o; |
| 2384 PyObject *result = NULL, *value = NULL; | 2382 PyObject *result = NULL, *value = NULL; |
| 2385 if (!o) { | 2383 if (!o) { |
| 2386 Py_INCREF(Py_None); | 2384 Py_INCREF(Py_None); |
| 2387 return Py_None; | 2385 return Py_None; |
| 2388 } | 2386 } |
| 2389 | 2387 |
| 2390 switch (o->kind) { | 2388 switch (o->kind) { |
| 2391 case FunctionDef_kind: | 2389 case FunctionDef_kind: |
| 2392 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); | 2390 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); |
| 2393 if (!result) goto failed; | 2391 if (!result) goto failed; |
| 2394 value = ast2obj_identifier(o->v.FunctionDef.name); | 2392 value = ast2obj_identifier(o->v.FunctionDef.name); |
| 2395 if (!value) goto failed; | 2393 if (!value) goto failed; |
| 2396 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) | 2394 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
| 2397 goto failed; | 2395 goto failed; |
| 2398 Py_DECREF(value); | 2396 Py_DECREF(value); |
| 2399 value = ast2obj_arguments(o->v.FunctionDef.args); | 2397 value = ast2obj_arguments(o->v.FunctionDef.args); |
| 2400 if (!value) goto failed; | 2398 if (!value) goto failed; |
| 2401 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) | 2399 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
| 2402 goto failed; | 2400 goto failed; |
| 2403 Py_DECREF(value); | 2401 Py_DECREF(value); |
| 2404 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); | 2402 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); |
| 2405 if (!value) goto failed; | 2403 if (!value) goto failed; |
| 2406 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2404 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2407 goto failed; | 2405 goto failed; |
| 2408 Py_DECREF(value); | 2406 Py_DECREF(value); |
| 2409 value = ast2obj_list(o->v.FunctionDef.decorator_list, | 2407 value = ast2obj_list(o->v.FunctionDef.decorator_list, ast2obj_expr); |
| 2410 ast2obj_expr); | 2408 if (!value) goto failed; |
| 2411 if (!value) goto failed; | 2409 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1) |
| 2412 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == | 2410 goto failed; |
| 2413 -1) | 2411 Py_DECREF(value); |
| 2414 goto failed; | 2412 value = ast2obj_expr(o->v.FunctionDef.returns); |
| 2415 Py_DECREF(value); | 2413 if (!value) goto failed; |
| 2416 value = ast2obj_expr(o->v.FunctionDef.returns); | 2414 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1) |
| 2417 if (!value) goto failed; | 2415 goto failed; |
| 2418 if (_PyObject_SetAttrId(result, &PyId_returns, value) == -1) | 2416 Py_DECREF(value); |
| 2419 goto failed; | 2417 break; |
| 2420 Py_DECREF(value); | 2418 case ClassDef_kind: |
| 2421 break; | 2419 result = PyType_GenericNew(ClassDef_type, NULL, NULL); |
| 2422 case ClassDef_kind: | 2420 if (!result) goto failed; |
| 2423 result = PyType_GenericNew(ClassDef_type, NULL, NULL); | 2421 value = ast2obj_identifier(o->v.ClassDef.name); |
| 2424 if (!result) goto failed; | 2422 if (!value) goto failed; |
| 2425 value = ast2obj_identifier(o->v.ClassDef.name); | 2423 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
| 2426 if (!value) goto failed; | 2424 goto failed; |
| 2427 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) | 2425 Py_DECREF(value); |
| 2428 goto failed; | 2426 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); |
| 2429 Py_DECREF(value); | 2427 if (!value) goto failed; |
| 2430 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); | 2428 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1) |
| 2431 if (!value) goto failed; | 2429 goto failed; |
| 2432 if (_PyObject_SetAttrId(result, &PyId_bases, value) == -1) | 2430 Py_DECREF(value); |
| 2433 goto failed; | 2431 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword); |
| 2434 Py_DECREF(value); | 2432 if (!value) goto failed; |
| 2435 value = ast2obj_list(o->v.ClassDef.keywords, ast2obj_keyword); | 2433 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) |
| 2436 if (!value) goto failed; | 2434 goto failed; |
| 2437 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) | 2435 Py_DECREF(value); |
| 2438 goto failed; | 2436 value = ast2obj_expr(o->v.ClassDef.starargs); |
| 2439 Py_DECREF(value); | 2437 if (!value) goto failed; |
| 2440 value = ast2obj_expr(o->v.ClassDef.starargs); | 2438 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) |
| 2441 if (!value) goto failed; | 2439 goto failed; |
| 2442 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) | 2440 Py_DECREF(value); |
| 2443 goto failed; | 2441 value = ast2obj_expr(o->v.ClassDef.kwargs); |
| 2444 Py_DECREF(value); | 2442 if (!value) goto failed; |
| 2445 value = ast2obj_expr(o->v.ClassDef.kwargs); | 2443 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) |
| 2446 if (!value) goto failed; | 2444 goto failed; |
| 2447 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) | 2445 Py_DECREF(value); |
| 2448 goto failed; | 2446 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); |
| 2449 Py_DECREF(value); | 2447 if (!value) goto failed; |
| 2450 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); | 2448 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2451 if (!value) goto failed; | 2449 goto failed; |
| 2452 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2450 Py_DECREF(value); |
| 2453 goto failed; | 2451 value = ast2obj_list(o->v.ClassDef.decorator_list, ast2obj_expr); |
| 2454 Py_DECREF(value); | 2452 if (!value) goto failed; |
| 2455 value = ast2obj_list(o->v.ClassDef.decorator_list, | 2453 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == -1) |
| 2456 ast2obj_expr); | 2454 goto failed; |
| 2457 if (!value) goto failed; | 2455 Py_DECREF(value); |
| 2458 if (_PyObject_SetAttrId(result, &PyId_decorator_list, value) == | 2456 break; |
| 2459 -1) | 2457 case Return_kind: |
| 2460 goto failed; | 2458 result = PyType_GenericNew(Return_type, NULL, NULL); |
| 2461 Py_DECREF(value); | 2459 if (!result) goto failed; |
| 2462 break; | 2460 value = ast2obj_expr(o->v.Return.value); |
| 2463 case Return_kind: | 2461 if (!value) goto failed; |
| 2464 result = PyType_GenericNew(Return_type, NULL, NULL); | 2462 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2465 if (!result) goto failed; | 2463 goto failed; |
| 2466 value = ast2obj_expr(o->v.Return.value); | 2464 Py_DECREF(value); |
| 2467 if (!value) goto failed; | 2465 break; |
| 2468 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2466 case Delete_kind: |
| 2469 goto failed; | 2467 result = PyType_GenericNew(Delete_type, NULL, NULL); |
| 2470 Py_DECREF(value); | 2468 if (!result) goto failed; |
| 2471 break; | 2469 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); |
| 2472 case Delete_kind: | 2470 if (!value) goto failed; |
| 2473 result = PyType_GenericNew(Delete_type, NULL, NULL); | 2471 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) |
| 2474 if (!result) goto failed; | 2472 goto failed; |
| 2475 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); | 2473 Py_DECREF(value); |
| 2476 if (!value) goto failed; | 2474 break; |
| 2477 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) | 2475 case Assign_kind: |
| 2478 goto failed; | 2476 result = PyType_GenericNew(Assign_type, NULL, NULL); |
| 2479 Py_DECREF(value); | 2477 if (!result) goto failed; |
| 2480 break; | 2478 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); |
| 2481 case Assign_kind: | 2479 if (!value) goto failed; |
| 2482 result = PyType_GenericNew(Assign_type, NULL, NULL); | 2480 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) |
| 2483 if (!result) goto failed; | 2481 goto failed; |
| 2484 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); | 2482 Py_DECREF(value); |
| 2485 if (!value) goto failed; | 2483 value = ast2obj_expr(o->v.Assign.value); |
| 2486 if (_PyObject_SetAttrId(result, &PyId_targets, value) == -1) | 2484 if (!value) goto failed; |
| 2487 goto failed; | 2485 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2488 Py_DECREF(value); | 2486 goto failed; |
| 2489 value = ast2obj_expr(o->v.Assign.value); | 2487 Py_DECREF(value); |
| 2490 if (!value) goto failed; | 2488 break; |
| 2491 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2489 case AugAssign_kind: |
| 2492 goto failed; | 2490 result = PyType_GenericNew(AugAssign_type, NULL, NULL); |
| 2493 Py_DECREF(value); | 2491 if (!result) goto failed; |
| 2494 break; | 2492 value = ast2obj_expr(o->v.AugAssign.target); |
| 2495 case AugAssign_kind: | 2493 if (!value) goto failed; |
| 2496 result = PyType_GenericNew(AugAssign_type, NULL, NULL); | 2494 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) |
| 2497 if (!result) goto failed; | 2495 goto failed; |
| 2498 value = ast2obj_expr(o->v.AugAssign.target); | 2496 Py_DECREF(value); |
| 2499 if (!value) goto failed; | 2497 value = ast2obj_operator(o->v.AugAssign.op); |
| 2500 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) | 2498 if (!value) goto failed; |
| 2501 goto failed; | 2499 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
| 2502 Py_DECREF(value); | 2500 goto failed; |
| 2503 value = ast2obj_operator(o->v.AugAssign.op); | 2501 Py_DECREF(value); |
| 2504 if (!value) goto failed; | 2502 value = ast2obj_expr(o->v.AugAssign.value); |
| 2505 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) | 2503 if (!value) goto failed; |
| 2506 goto failed; | 2504 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2507 Py_DECREF(value); | 2505 goto failed; |
| 2508 value = ast2obj_expr(o->v.AugAssign.value); | 2506 Py_DECREF(value); |
| 2509 if (!value) goto failed; | 2507 break; |
| 2510 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2508 case For_kind: |
| 2511 goto failed; | 2509 result = PyType_GenericNew(For_type, NULL, NULL); |
| 2512 Py_DECREF(value); | 2510 if (!result) goto failed; |
| 2513 break; | 2511 value = ast2obj_expr(o->v.For.target); |
| 2514 case For_kind: | 2512 if (!value) goto failed; |
| 2515 result = PyType_GenericNew(For_type, NULL, NULL); | 2513 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) |
| 2516 if (!result) goto failed; | 2514 goto failed; |
| 2517 value = ast2obj_expr(o->v.For.target); | 2515 Py_DECREF(value); |
| 2518 if (!value) goto failed; | 2516 value = ast2obj_expr(o->v.For.iter); |
| 2519 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) | 2517 if (!value) goto failed; |
| 2520 goto failed; | 2518 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) |
| 2521 Py_DECREF(value); | 2519 goto failed; |
| 2522 value = ast2obj_expr(o->v.For.iter); | 2520 Py_DECREF(value); |
| 2523 if (!value) goto failed; | 2521 value = ast2obj_list(o->v.For.body, ast2obj_stmt); |
| 2524 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) | 2522 if (!value) goto failed; |
| 2525 goto failed; | 2523 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2526 Py_DECREF(value); | 2524 goto failed; |
| 2527 value = ast2obj_list(o->v.For.body, ast2obj_stmt); | 2525 Py_DECREF(value); |
| 2528 if (!value) goto failed; | 2526 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); |
| 2529 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2527 if (!value) goto failed; |
| 2530 goto failed; | 2528 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
| 2531 Py_DECREF(value); | 2529 goto failed; |
| 2532 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); | 2530 Py_DECREF(value); |
| 2533 if (!value) goto failed; | 2531 break; |
| 2534 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) | 2532 case While_kind: |
| 2535 goto failed; | 2533 result = PyType_GenericNew(While_type, NULL, NULL); |
| 2536 Py_DECREF(value); | 2534 if (!result) goto failed; |
| 2537 break; | 2535 value = ast2obj_expr(o->v.While.test); |
| 2538 case While_kind: | 2536 if (!value) goto failed; |
| 2539 result = PyType_GenericNew(While_type, NULL, NULL); | 2537 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
| 2540 if (!result) goto failed; | 2538 goto failed; |
| 2541 value = ast2obj_expr(o->v.While.test); | 2539 Py_DECREF(value); |
| 2542 if (!value) goto failed; | 2540 value = ast2obj_list(o->v.While.body, ast2obj_stmt); |
| 2543 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) | 2541 if (!value) goto failed; |
| 2544 goto failed; | 2542 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2545 Py_DECREF(value); | 2543 goto failed; |
| 2546 value = ast2obj_list(o->v.While.body, ast2obj_stmt); | 2544 Py_DECREF(value); |
| 2547 if (!value) goto failed; | 2545 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); |
| 2548 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2546 if (!value) goto failed; |
| 2549 goto failed; | 2547 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
| 2550 Py_DECREF(value); | 2548 goto failed; |
| 2551 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); | 2549 Py_DECREF(value); |
| 2552 if (!value) goto failed; | 2550 break; |
| 2553 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) | 2551 case If_kind: |
| 2554 goto failed; | 2552 result = PyType_GenericNew(If_type, NULL, NULL); |
| 2555 Py_DECREF(value); | 2553 if (!result) goto failed; |
| 2556 break; | 2554 value = ast2obj_expr(o->v.If.test); |
| 2557 case If_kind: | 2555 if (!value) goto failed; |
| 2558 result = PyType_GenericNew(If_type, NULL, NULL); | 2556 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
| 2559 if (!result) goto failed; | 2557 goto failed; |
| 2560 value = ast2obj_expr(o->v.If.test); | 2558 Py_DECREF(value); |
| 2561 if (!value) goto failed; | 2559 value = ast2obj_list(o->v.If.body, ast2obj_stmt); |
| 2562 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) | 2560 if (!value) goto failed; |
| 2563 goto failed; | 2561 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2564 Py_DECREF(value); | 2562 goto failed; |
| 2565 value = ast2obj_list(o->v.If.body, ast2obj_stmt); | 2563 Py_DECREF(value); |
| 2566 if (!value) goto failed; | 2564 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); |
| 2567 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2565 if (!value) goto failed; |
| 2568 goto failed; | 2566 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
| 2569 Py_DECREF(value); | 2567 goto failed; |
| 2570 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); | 2568 Py_DECREF(value); |
| 2571 if (!value) goto failed; | 2569 break; |
| 2572 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) | 2570 case With_kind: |
| 2573 goto failed; | 2571 result = PyType_GenericNew(With_type, NULL, NULL); |
| 2574 Py_DECREF(value); | 2572 if (!result) goto failed; |
| 2575 break; | 2573 value = ast2obj_list(o->v.With.items, ast2obj_withitem); |
| 2576 case With_kind: | 2574 if (!value) goto failed; |
| 2577 result = PyType_GenericNew(With_type, NULL, NULL); | 2575 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1) |
| 2578 if (!result) goto failed; | 2576 goto failed; |
| 2579 value = ast2obj_list(o->v.With.items, ast2obj_withitem); | 2577 Py_DECREF(value); |
| 2580 if (!value) goto failed; | 2578 value = ast2obj_list(o->v.With.body, ast2obj_stmt); |
| 2581 if (_PyObject_SetAttrId(result, &PyId_items, value) == -1) | 2579 if (!value) goto failed; |
| 2582 goto failed; | 2580 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2583 Py_DECREF(value); | 2581 goto failed; |
| 2584 value = ast2obj_list(o->v.With.body, ast2obj_stmt); | 2582 Py_DECREF(value); |
| 2585 if (!value) goto failed; | 2583 break; |
| 2586 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2584 case Raise_kind: |
| 2587 goto failed; | 2585 result = PyType_GenericNew(Raise_type, NULL, NULL); |
| 2588 Py_DECREF(value); | 2586 if (!result) goto failed; |
| 2589 break; | 2587 value = ast2obj_expr(o->v.Raise.exc); |
| 2590 case Raise_kind: | 2588 if (!value) goto failed; |
| 2591 result = PyType_GenericNew(Raise_type, NULL, NULL); | 2589 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1) |
| 2592 if (!result) goto failed; | 2590 goto failed; |
| 2593 value = ast2obj_expr(o->v.Raise.exc); | 2591 Py_DECREF(value); |
| 2594 if (!value) goto failed; | 2592 value = ast2obj_expr(o->v.Raise.cause); |
| 2595 if (_PyObject_SetAttrId(result, &PyId_exc, value) == -1) | 2593 if (!value) goto failed; |
| 2596 goto failed; | 2594 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1) |
| 2597 Py_DECREF(value); | 2595 goto failed; |
| 2598 value = ast2obj_expr(o->v.Raise.cause); | 2596 Py_DECREF(value); |
| 2599 if (!value) goto failed; | 2597 break; |
| 2600 if (_PyObject_SetAttrId(result, &PyId_cause, value) == -1) | 2598 case Try_kind: |
| 2601 goto failed; | 2599 result = PyType_GenericNew(Try_type, NULL, NULL); |
| 2602 Py_DECREF(value); | 2600 if (!result) goto failed; |
| 2603 break; | 2601 value = ast2obj_list(o->v.Try.body, ast2obj_stmt); |
| 2604 case Try_kind: | 2602 if (!value) goto failed; |
| 2605 result = PyType_GenericNew(Try_type, NULL, NULL); | 2603 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2606 if (!result) goto failed; | 2604 goto failed; |
| 2607 value = ast2obj_list(o->v.Try.body, ast2obj_stmt); | 2605 Py_DECREF(value); |
| 2608 if (!value) goto failed; | 2606 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler); |
| 2609 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2607 if (!value) goto failed; |
| 2610 goto failed; | 2608 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1) |
| 2611 Py_DECREF(value); | 2609 goto failed; |
| 2612 value = ast2obj_list(o->v.Try.handlers, ast2obj_excepthandler); | 2610 Py_DECREF(value); |
| 2613 if (!value) goto failed; | 2611 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt); |
| 2614 if (_PyObject_SetAttrId(result, &PyId_handlers, value) == -1) | 2612 if (!value) goto failed; |
| 2615 goto failed; | 2613 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
| 2616 Py_DECREF(value); | 2614 goto failed; |
| 2617 value = ast2obj_list(o->v.Try.orelse, ast2obj_stmt); | 2615 Py_DECREF(value); |
| 2618 if (!value) goto failed; | 2616 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt); |
| 2619 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) | 2617 if (!value) goto failed; |
| 2620 goto failed; | 2618 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1) |
| 2621 Py_DECREF(value); | 2619 goto failed; |
| 2622 value = ast2obj_list(o->v.Try.finalbody, ast2obj_stmt); | 2620 Py_DECREF(value); |
| 2623 if (!value) goto failed; | 2621 break; |
| 2624 if (_PyObject_SetAttrId(result, &PyId_finalbody, value) == -1) | 2622 case Assert_kind: |
| 2625 goto failed; | 2623 result = PyType_GenericNew(Assert_type, NULL, NULL); |
| 2626 Py_DECREF(value); | 2624 if (!result) goto failed; |
| 2627 break; | 2625 value = ast2obj_expr(o->v.Assert.test); |
| 2628 case Assert_kind: | 2626 if (!value) goto failed; |
| 2629 result = PyType_GenericNew(Assert_type, NULL, NULL); | 2627 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
| 2630 if (!result) goto failed; | 2628 goto failed; |
| 2631 value = ast2obj_expr(o->v.Assert.test); | 2629 Py_DECREF(value); |
| 2632 if (!value) goto failed; | 2630 value = ast2obj_expr(o->v.Assert.msg); |
| 2633 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) | 2631 if (!value) goto failed; |
| 2634 goto failed; | 2632 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1) |
| 2635 Py_DECREF(value); | 2633 goto failed; |
| 2636 value = ast2obj_expr(o->v.Assert.msg); | 2634 Py_DECREF(value); |
| 2637 if (!value) goto failed; | 2635 break; |
| 2638 if (_PyObject_SetAttrId(result, &PyId_msg, value) == -1) | 2636 case Import_kind: |
| 2639 goto failed; | 2637 result = PyType_GenericNew(Import_type, NULL, NULL); |
| 2640 Py_DECREF(value); | 2638 if (!result) goto failed; |
| 2641 break; | 2639 value = ast2obj_list(o->v.Import.names, ast2obj_alias); |
| 2642 case Import_kind: | 2640 if (!value) goto failed; |
| 2643 result = PyType_GenericNew(Import_type, NULL, NULL); | 2641 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
| 2644 if (!result) goto failed; | 2642 goto failed; |
| 2645 value = ast2obj_list(o->v.Import.names, ast2obj_alias); | 2643 Py_DECREF(value); |
| 2646 if (!value) goto failed; | 2644 break; |
| 2647 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) | 2645 case ImportFrom_kind: |
| 2648 goto failed; | 2646 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); |
| 2649 Py_DECREF(value); | 2647 if (!result) goto failed; |
| 2650 break; | 2648 value = ast2obj_identifier(o->v.ImportFrom.module); |
| 2651 case ImportFrom_kind: | 2649 if (!value) goto failed; |
| 2652 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); | 2650 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1) |
| 2653 if (!result) goto failed; | 2651 goto failed; |
| 2654 value = ast2obj_identifier(o->v.ImportFrom.module); | 2652 Py_DECREF(value); |
| 2655 if (!value) goto failed; | 2653 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); |
| 2656 if (_PyObject_SetAttrId(result, &PyId_module, value) == -1) | 2654 if (!value) goto failed; |
| 2657 goto failed; | 2655 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
| 2658 Py_DECREF(value); | 2656 goto failed; |
| 2659 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); | 2657 Py_DECREF(value); |
| 2660 if (!value) goto failed; | 2658 value = ast2obj_int(o->v.ImportFrom.level); |
| 2661 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) | 2659 if (!value) goto failed; |
| 2662 goto failed; | 2660 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1) |
| 2663 Py_DECREF(value); | 2661 goto failed; |
| 2664 value = ast2obj_int(o->v.ImportFrom.level); | 2662 Py_DECREF(value); |
| 2665 if (!value) goto failed; | 2663 break; |
| 2666 if (_PyObject_SetAttrId(result, &PyId_level, value) == -1) | 2664 case Global_kind: |
| 2667 goto failed; | 2665 result = PyType_GenericNew(Global_type, NULL, NULL); |
| 2668 Py_DECREF(value); | 2666 if (!result) goto failed; |
| 2669 break; | 2667 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); |
| 2670 case Global_kind: | 2668 if (!value) goto failed; |
| 2671 result = PyType_GenericNew(Global_type, NULL, NULL); | 2669 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
| 2672 if (!result) goto failed; | 2670 goto failed; |
| 2673 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); | 2671 Py_DECREF(value); |
| 2674 if (!value) goto failed; | 2672 break; |
| 2675 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) | 2673 case Nonlocal_kind: |
| 2676 goto failed; | 2674 result = PyType_GenericNew(Nonlocal_type, NULL, NULL); |
| 2677 Py_DECREF(value); | 2675 if (!result) goto failed; |
| 2678 break; | 2676 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier); |
| 2679 case Nonlocal_kind: | 2677 if (!value) goto failed; |
| 2680 result = PyType_GenericNew(Nonlocal_type, NULL, NULL); | 2678 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) |
| 2681 if (!result) goto failed; | 2679 goto failed; |
| 2682 value = ast2obj_list(o->v.Nonlocal.names, ast2obj_identifier); | 2680 Py_DECREF(value); |
| 2683 if (!value) goto failed; | 2681 break; |
| 2684 if (_PyObject_SetAttrId(result, &PyId_names, value) == -1) | 2682 case Expr_kind: |
| 2685 goto failed; | 2683 result = PyType_GenericNew(Expr_type, NULL, NULL); |
| 2686 Py_DECREF(value); | 2684 if (!result) goto failed; |
| 2687 break; | 2685 value = ast2obj_expr(o->v.Expr.value); |
| 2688 case Expr_kind: | 2686 if (!value) goto failed; |
| 2689 result = PyType_GenericNew(Expr_type, NULL, NULL); | 2687 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2690 if (!result) goto failed; | 2688 goto failed; |
| 2691 value = ast2obj_expr(o->v.Expr.value); | 2689 Py_DECREF(value); |
| 2692 if (!value) goto failed; | 2690 break; |
| 2693 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2691 case Pass_kind: |
| 2694 goto failed; | 2692 result = PyType_GenericNew(Pass_type, NULL, NULL); |
| 2695 Py_DECREF(value); | 2693 if (!result) goto failed; |
| 2696 break; | 2694 break; |
| 2697 case Pass_kind: | 2695 case Break_kind: |
| 2698 result = PyType_GenericNew(Pass_type, NULL, NULL); | 2696 result = PyType_GenericNew(Break_type, NULL, NULL); |
| 2699 if (!result) goto failed; | 2697 if (!result) goto failed; |
| 2700 break; | 2698 break; |
| 2701 case Break_kind: | 2699 case Continue_kind: |
| 2702 result = PyType_GenericNew(Break_type, NULL, NULL); | 2700 result = PyType_GenericNew(Continue_type, NULL, NULL); |
| 2703 if (!result) goto failed; | 2701 if (!result) goto failed; |
| 2704 break; | 2702 break; |
| 2705 case Continue_kind: | 2703 } |
| 2706 result = PyType_GenericNew(Continue_type, NULL, NULL); | 2704 value = ast2obj_int(o->lineno); |
| 2707 if (!result) goto failed; | 2705 if (!value) goto failed; |
| 2708 break; | 2706 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
| 2709 } | 2707 goto failed; |
| 2710 value = ast2obj_int(o->lineno); | 2708 Py_DECREF(value); |
| 2711 if (!value) goto failed; | 2709 value = ast2obj_int(o->col_offset); |
| 2712 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) | 2710 if (!value) goto failed; |
| 2713 goto failed; | 2711 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
| 2714 Py_DECREF(value); | 2712 goto failed; |
| 2715 value = ast2obj_int(o->col_offset); | 2713 Py_DECREF(value); |
| 2716 if (!value) goto failed; | 2714 return result; |
| 2717 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) | |
| 2718 goto failed; | |
| 2719 Py_DECREF(value); | |
| 2720 return result; | |
| 2721 failed: | 2715 failed: |
| 2722 Py_XDECREF(value); | 2716 Py_XDECREF(value); |
| 2723 Py_XDECREF(result); | 2717 Py_XDECREF(result); |
| 2724 return NULL; | 2718 return NULL; |
| 2725 } | 2719 } |
| 2726 | 2720 |
| 2727 PyObject* | 2721 PyObject* |
| 2728 ast2obj_expr(void* _o) | 2722 ast2obj_expr(void* _o) |
| 2729 { | 2723 { |
| 2730 expr_ty o = (expr_ty)_o; | 2724 expr_ty o = (expr_ty)_o; |
| 2731 PyObject *result = NULL, *value = NULL; | 2725 PyObject *result = NULL, *value = NULL; |
| 2732 if (!o) { | 2726 if (!o) { |
| 2733 Py_INCREF(Py_None); | 2727 Py_INCREF(Py_None); |
| 2734 return Py_None; | 2728 return Py_None; |
| 2735 } | 2729 } |
| 2736 | 2730 |
| 2737 switch (o->kind) { | 2731 switch (o->kind) { |
| 2738 case BoolOp_kind: | 2732 case BoolOp_kind: |
| 2739 result = PyType_GenericNew(BoolOp_type, NULL, NULL); | 2733 result = PyType_GenericNew(BoolOp_type, NULL, NULL); |
| 2740 if (!result) goto failed; | 2734 if (!result) goto failed; |
| 2741 value = ast2obj_boolop(o->v.BoolOp.op); | 2735 value = ast2obj_boolop(o->v.BoolOp.op); |
| 2742 if (!value) goto failed; | 2736 if (!value) goto failed; |
| 2743 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) | 2737 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
| 2744 goto failed; | 2738 goto failed; |
| 2745 Py_DECREF(value); | 2739 Py_DECREF(value); |
| 2746 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); | 2740 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); |
| 2747 if (!value) goto failed; | 2741 if (!value) goto failed; |
| 2748 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) | 2742 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) |
| 2749 goto failed; | 2743 goto failed; |
| 2750 Py_DECREF(value); | 2744 Py_DECREF(value); |
| 2751 break; | 2745 break; |
| 2752 case BinOp_kind: | 2746 case BinOp_kind: |
| 2753 result = PyType_GenericNew(BinOp_type, NULL, NULL); | 2747 result = PyType_GenericNew(BinOp_type, NULL, NULL); |
| 2754 if (!result) goto failed; | 2748 if (!result) goto failed; |
| 2755 value = ast2obj_expr(o->v.BinOp.left); | 2749 value = ast2obj_expr(o->v.BinOp.left); |
| 2756 if (!value) goto failed; | 2750 if (!value) goto failed; |
| 2757 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) | 2751 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) |
| 2758 goto failed; | 2752 goto failed; |
| 2759 Py_DECREF(value); | 2753 Py_DECREF(value); |
| 2760 value = ast2obj_operator(o->v.BinOp.op); | 2754 value = ast2obj_operator(o->v.BinOp.op); |
| 2761 if (!value) goto failed; | 2755 if (!value) goto failed; |
| 2762 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) | 2756 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
| 2763 goto failed; | 2757 goto failed; |
| 2764 Py_DECREF(value); | 2758 Py_DECREF(value); |
| 2765 value = ast2obj_expr(o->v.BinOp.right); | 2759 value = ast2obj_expr(o->v.BinOp.right); |
| 2766 if (!value) goto failed; | 2760 if (!value) goto failed; |
| 2767 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1) | 2761 if (_PyObject_SetAttrId(result, &PyId_right, value) == -1) |
| 2768 goto failed; | 2762 goto failed; |
| 2769 Py_DECREF(value); | 2763 Py_DECREF(value); |
| 2770 break; | 2764 break; |
| 2771 case UnaryOp_kind: | 2765 case UnaryOp_kind: |
| 2772 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); | 2766 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); |
| 2773 if (!result) goto failed; | 2767 if (!result) goto failed; |
| 2774 value = ast2obj_unaryop(o->v.UnaryOp.op); | 2768 value = ast2obj_unaryop(o->v.UnaryOp.op); |
| 2775 if (!value) goto failed; | 2769 if (!value) goto failed; |
| 2776 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) | 2770 if (_PyObject_SetAttrId(result, &PyId_op, value) == -1) |
| 2777 goto failed; | 2771 goto failed; |
| 2778 Py_DECREF(value); | 2772 Py_DECREF(value); |
| 2779 value = ast2obj_expr(o->v.UnaryOp.operand); | 2773 value = ast2obj_expr(o->v.UnaryOp.operand); |
| 2780 if (!value) goto failed; | 2774 if (!value) goto failed; |
| 2781 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1) | 2775 if (_PyObject_SetAttrId(result, &PyId_operand, value) == -1) |
| 2782 goto failed; | 2776 goto failed; |
| 2783 Py_DECREF(value); | 2777 Py_DECREF(value); |
| 2784 break; | 2778 break; |
| 2785 case Lambda_kind: | 2779 case Lambda_kind: |
| 2786 result = PyType_GenericNew(Lambda_type, NULL, NULL); | 2780 result = PyType_GenericNew(Lambda_type, NULL, NULL); |
| 2787 if (!result) goto failed; | 2781 if (!result) goto failed; |
| 2788 value = ast2obj_arguments(o->v.Lambda.args); | 2782 value = ast2obj_arguments(o->v.Lambda.args); |
| 2789 if (!value) goto failed; | 2783 if (!value) goto failed; |
| 2790 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) | 2784 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
| 2791 goto failed; | 2785 goto failed; |
| 2792 Py_DECREF(value); | 2786 Py_DECREF(value); |
| 2793 value = ast2obj_expr(o->v.Lambda.body); | 2787 value = ast2obj_expr(o->v.Lambda.body); |
| 2794 if (!value) goto failed; | 2788 if (!value) goto failed; |
| 2795 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2789 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2796 goto failed; | 2790 goto failed; |
| 2797 Py_DECREF(value); | 2791 Py_DECREF(value); |
| 2798 break; | 2792 break; |
| 2799 case IfExp_kind: | 2793 case IfExp_kind: |
| 2800 result = PyType_GenericNew(IfExp_type, NULL, NULL); | 2794 result = PyType_GenericNew(IfExp_type, NULL, NULL); |
| 2801 if (!result) goto failed; | 2795 if (!result) goto failed; |
| 2802 value = ast2obj_expr(o->v.IfExp.test); | 2796 value = ast2obj_expr(o->v.IfExp.test); |
| 2803 if (!value) goto failed; | 2797 if (!value) goto failed; |
| 2804 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) | 2798 if (_PyObject_SetAttrId(result, &PyId_test, value) == -1) |
| 2805 goto failed; | 2799 goto failed; |
| 2806 Py_DECREF(value); | 2800 Py_DECREF(value); |
| 2807 value = ast2obj_expr(o->v.IfExp.body); | 2801 value = ast2obj_expr(o->v.IfExp.body); |
| 2808 if (!value) goto failed; | 2802 if (!value) goto failed; |
| 2809 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 2803 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 2810 goto failed; | 2804 goto failed; |
| 2811 Py_DECREF(value); | 2805 Py_DECREF(value); |
| 2812 value = ast2obj_expr(o->v.IfExp.orelse); | 2806 value = ast2obj_expr(o->v.IfExp.orelse); |
| 2813 if (!value) goto failed; | 2807 if (!value) goto failed; |
| 2814 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) | 2808 if (_PyObject_SetAttrId(result, &PyId_orelse, value) == -1) |
| 2815 goto failed; | 2809 goto failed; |
| 2816 Py_DECREF(value); | 2810 Py_DECREF(value); |
| 2817 break; | 2811 break; |
| 2818 case Dict_kind: | 2812 case Dict_kind: |
| 2819 result = PyType_GenericNew(Dict_type, NULL, NULL); | 2813 result = PyType_GenericNew(Dict_type, NULL, NULL); |
| 2820 if (!result) goto failed; | 2814 if (!result) goto failed; |
| 2821 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); | 2815 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); |
| 2822 if (!value) goto failed; | 2816 if (!value) goto failed; |
| 2823 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1) | 2817 if (_PyObject_SetAttrId(result, &PyId_keys, value) == -1) |
| 2824 goto failed; | 2818 goto failed; |
| 2825 Py_DECREF(value); | 2819 Py_DECREF(value); |
| 2826 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); | 2820 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); |
| 2827 if (!value) goto failed; | 2821 if (!value) goto failed; |
| 2828 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) | 2822 if (_PyObject_SetAttrId(result, &PyId_values, value) == -1) |
| 2829 goto failed; | 2823 goto failed; |
| 2830 Py_DECREF(value); | 2824 Py_DECREF(value); |
| 2831 break; | 2825 break; |
| 2832 case Set_kind: | 2826 case Set_kind: |
| 2833 result = PyType_GenericNew(Set_type, NULL, NULL); | 2827 result = PyType_GenericNew(Set_type, NULL, NULL); |
| 2834 if (!result) goto failed; | 2828 if (!result) goto failed; |
| 2835 value = ast2obj_list(o->v.Set.elts, ast2obj_expr); | 2829 value = ast2obj_list(o->v.Set.elts, ast2obj_expr); |
| 2836 if (!value) goto failed; | 2830 if (!value) goto failed; |
| 2837 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) | 2831 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) |
| 2838 goto failed; | 2832 goto failed; |
| 2839 Py_DECREF(value); | 2833 Py_DECREF(value); |
| 2840 break; | 2834 break; |
| 2841 case ListComp_kind: | 2835 case ListComp_kind: |
| 2842 result = PyType_GenericNew(ListComp_type, NULL, NULL); | 2836 result = PyType_GenericNew(ListComp_type, NULL, NULL); |
| 2843 if (!result) goto failed; | 2837 if (!result) goto failed; |
| 2844 value = ast2obj_expr(o->v.ListComp.elt); | 2838 value = ast2obj_expr(o->v.ListComp.elt); |
| 2845 if (!value) goto failed; | 2839 if (!value) goto failed; |
| 2846 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) | 2840 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) |
| 2847 goto failed; | 2841 goto failed; |
| 2848 Py_DECREF(value); | 2842 Py_DECREF(value); |
| 2849 value = ast2obj_list(o->v.ListComp.generators, | 2843 value = ast2obj_list(o->v.ListComp.generators, ast2obj_comprehension); |
| 2850 ast2obj_comprehension); | 2844 if (!value) goto failed; |
| 2851 if (!value) goto failed; | 2845 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
| 2852 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) | 2846 goto failed; |
| 2853 goto failed; | 2847 Py_DECREF(value); |
| 2854 Py_DECREF(value); | 2848 break; |
| 2855 break; | 2849 case SetComp_kind: |
| 2856 case SetComp_kind: | 2850 result = PyType_GenericNew(SetComp_type, NULL, NULL); |
| 2857 result = PyType_GenericNew(SetComp_type, NULL, NULL); | 2851 if (!result) goto failed; |
| 2858 if (!result) goto failed; | 2852 value = ast2obj_expr(o->v.SetComp.elt); |
| 2859 value = ast2obj_expr(o->v.SetComp.elt); | 2853 if (!value) goto failed; |
| 2860 if (!value) goto failed; | 2854 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) |
| 2861 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) | 2855 goto failed; |
| 2862 goto failed; | 2856 Py_DECREF(value); |
| 2863 Py_DECREF(value); | 2857 value = ast2obj_list(o->v.SetComp.generators, ast2obj_comprehension); |
| 2864 value = ast2obj_list(o->v.SetComp.generators, | 2858 if (!value) goto failed; |
| 2865 ast2obj_comprehension); | 2859 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
| 2866 if (!value) goto failed; | 2860 goto failed; |
| 2867 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) | 2861 Py_DECREF(value); |
| 2868 goto failed; | 2862 break; |
| 2869 Py_DECREF(value); | 2863 case DictComp_kind: |
| 2870 break; | 2864 result = PyType_GenericNew(DictComp_type, NULL, NULL); |
| 2871 case DictComp_kind: | 2865 if (!result) goto failed; |
| 2872 result = PyType_GenericNew(DictComp_type, NULL, NULL); | 2866 value = ast2obj_expr(o->v.DictComp.key); |
| 2873 if (!result) goto failed; | 2867 if (!value) goto failed; |
| 2874 value = ast2obj_expr(o->v.DictComp.key); | 2868 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1) |
| 2875 if (!value) goto failed; | 2869 goto failed; |
| 2876 if (_PyObject_SetAttrId(result, &PyId_key, value) == -1) | 2870 Py_DECREF(value); |
| 2877 goto failed; | 2871 value = ast2obj_expr(o->v.DictComp.value); |
| 2878 Py_DECREF(value); | 2872 if (!value) goto failed; |
| 2879 value = ast2obj_expr(o->v.DictComp.value); | 2873 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2880 if (!value) goto failed; | 2874 goto failed; |
| 2881 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2875 Py_DECREF(value); |
| 2882 goto failed; | 2876 value = ast2obj_list(o->v.DictComp.generators, ast2obj_comprehension); |
| 2883 Py_DECREF(value); | 2877 if (!value) goto failed; |
| 2884 value = ast2obj_list(o->v.DictComp.generators, | 2878 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
| 2885 ast2obj_comprehension); | 2879 goto failed; |
| 2886 if (!value) goto failed; | 2880 Py_DECREF(value); |
| 2887 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) | 2881 break; |
| 2888 goto failed; | 2882 case GeneratorExp_kind: |
| 2889 Py_DECREF(value); | 2883 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); |
| 2890 break; | 2884 if (!result) goto failed; |
| 2891 case GeneratorExp_kind: | 2885 value = ast2obj_expr(o->v.GeneratorExp.elt); |
| 2892 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); | 2886 if (!value) goto failed; |
| 2893 if (!result) goto failed; | 2887 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) |
| 2894 value = ast2obj_expr(o->v.GeneratorExp.elt); | 2888 goto failed; |
| 2895 if (!value) goto failed; | 2889 Py_DECREF(value); |
| 2896 if (_PyObject_SetAttrId(result, &PyId_elt, value) == -1) | 2890 value = ast2obj_list(o->v.GeneratorExp.generators, |
| 2897 goto failed; | 2891 ast2obj_comprehension); |
| 2898 Py_DECREF(value); | 2892 if (!value) goto failed; |
| 2899 value = ast2obj_list(o->v.GeneratorExp.generators, | 2893 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) |
| 2900 ast2obj_comprehension); | 2894 goto failed; |
| 2901 if (!value) goto failed; | 2895 Py_DECREF(value); |
| 2902 if (_PyObject_SetAttrId(result, &PyId_generators, value) == -1) | 2896 break; |
| 2903 goto failed; | 2897 case Yield_kind: |
| 2904 Py_DECREF(value); | 2898 result = PyType_GenericNew(Yield_type, NULL, NULL); |
| 2905 break; | 2899 if (!result) goto failed; |
| 2906 case Yield_kind: | 2900 value = ast2obj_expr(o->v.Yield.value); |
| 2907 result = PyType_GenericNew(Yield_type, NULL, NULL); | 2901 if (!value) goto failed; |
| 2908 if (!result) goto failed; | 2902 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2909 value = ast2obj_expr(o->v.Yield.value); | 2903 goto failed; |
| 2910 if (!value) goto failed; | 2904 Py_DECREF(value); |
| 2911 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2905 break; |
| 2912 goto failed; | 2906 case YieldFrom_kind: |
| 2913 Py_DECREF(value); | 2907 result = PyType_GenericNew(YieldFrom_type, NULL, NULL); |
| 2914 break; | 2908 if (!result) goto failed; |
| 2915 case YieldFrom_kind: | 2909 value = ast2obj_expr(o->v.YieldFrom.value); |
| 2916 result = PyType_GenericNew(YieldFrom_type, NULL, NULL); | 2910 if (!value) goto failed; |
| 2917 if (!result) goto failed; | 2911 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 2918 value = ast2obj_expr(o->v.YieldFrom.value); | 2912 goto failed; |
| 2919 if (!value) goto failed; | 2913 Py_DECREF(value); |
| 2920 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 2914 break; |
| 2921 goto failed; | 2915 case Compare_kind: |
| 2922 Py_DECREF(value); | 2916 result = PyType_GenericNew(Compare_type, NULL, NULL); |
| 2923 break; | 2917 if (!result) goto failed; |
| 2924 case Compare_kind: | 2918 value = ast2obj_expr(o->v.Compare.left); |
| 2925 result = PyType_GenericNew(Compare_type, NULL, NULL); | 2919 if (!value) goto failed; |
| 2926 if (!result) goto failed; | 2920 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) |
| 2927 value = ast2obj_expr(o->v.Compare.left); | 2921 goto failed; |
| 2928 if (!value) goto failed; | 2922 Py_DECREF(value); |
| 2929 if (_PyObject_SetAttrId(result, &PyId_left, value) == -1) | 2923 { |
| 2930 goto failed; | 2924 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops); |
| 2931 Py_DECREF(value); | 2925 value = PyList_New(n); |
| 2932 { | 2926 if (!value) goto failed; |
| 2933 Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops); | 2927 for(i = 0; i < n; i++) |
| 2934 value = PyList_New(n); | 2928 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i))); |
| 2935 if (!value) goto failed; | 2929 } |
| 2936 for(i = 0; i < n; i++) | 2930 if (!value) goto failed; |
| 2937 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i))); | 2931 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1) |
| 2938 } | 2932 goto failed; |
| 2939 if (!value) goto failed; | 2933 Py_DECREF(value); |
| 2940 if (_PyObject_SetAttrId(result, &PyId_ops, value) == -1) | 2934 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); |
| 2941 goto failed; | 2935 if (!value) goto failed; |
| 2942 Py_DECREF(value); | 2936 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1) |
| 2943 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); | 2937 goto failed; |
| 2944 if (!value) goto failed; | 2938 Py_DECREF(value); |
| 2945 if (_PyObject_SetAttrId(result, &PyId_comparators, value) == -1) | 2939 break; |
| 2946 goto failed; | 2940 case Call_kind: |
| 2947 Py_DECREF(value); | 2941 result = PyType_GenericNew(Call_type, NULL, NULL); |
| 2948 break; | 2942 if (!result) goto failed; |
| 2949 case Call_kind: | 2943 value = ast2obj_expr(o->v.Call.func); |
| 2950 result = PyType_GenericNew(Call_type, NULL, NULL); | 2944 if (!value) goto failed; |
| 2951 if (!result) goto failed; | 2945 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1) |
| 2952 value = ast2obj_expr(o->v.Call.func); | 2946 goto failed; |
| 2953 if (!value) goto failed; | 2947 Py_DECREF(value); |
| 2954 if (_PyObject_SetAttrId(result, &PyId_func, value) == -1) | 2948 value = ast2obj_list(o->v.Call.args, ast2obj_expr); |
| 2955 goto failed; | 2949 if (!value) goto failed; |
| 2956 Py_DECREF(value); | 2950 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
| 2957 value = ast2obj_list(o->v.Call.args, ast2obj_expr); | 2951 goto failed; |
| 2958 if (!value) goto failed; | 2952 Py_DECREF(value); |
| 2959 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) | 2953 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); |
| 2960 goto failed; | 2954 if (!value) goto failed; |
| 2961 Py_DECREF(value); | 2955 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) |
| 2962 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); | 2956 goto failed; |
| 2963 if (!value) goto failed; | 2957 Py_DECREF(value); |
| 2964 if (_PyObject_SetAttrId(result, &PyId_keywords, value) == -1) | 2958 value = ast2obj_expr(o->v.Call.starargs); |
| 2965 goto failed; | 2959 if (!value) goto failed; |
| 2966 Py_DECREF(value); | 2960 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) |
| 2967 value = ast2obj_expr(o->v.Call.starargs); | 2961 goto failed; |
| 2968 if (!value) goto failed; | 2962 Py_DECREF(value); |
| 2969 if (_PyObject_SetAttrId(result, &PyId_starargs, value) == -1) | 2963 value = ast2obj_expr(o->v.Call.kwargs); |
| 2970 goto failed; | 2964 if (!value) goto failed; |
| 2971 Py_DECREF(value); | 2965 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) |
| 2972 value = ast2obj_expr(o->v.Call.kwargs); | 2966 goto failed; |
| 2973 if (!value) goto failed; | 2967 Py_DECREF(value); |
| 2974 if (_PyObject_SetAttrId(result, &PyId_kwargs, value) == -1) | 2968 break; |
| 2975 goto failed; | 2969 case Num_kind: |
| 2976 Py_DECREF(value); | 2970 result = PyType_GenericNew(Num_type, NULL, NULL); |
| 2977 break; | 2971 if (!result) goto failed; |
| 2978 case Num_kind: | 2972 value = ast2obj_object(o->v.Num.n); |
| 2979 result = PyType_GenericNew(Num_type, NULL, NULL); | 2973 if (!value) goto failed; |
| 2980 if (!result) goto failed; | 2974 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1) |
| 2981 value = ast2obj_object(o->v.Num.n); | 2975 goto failed; |
| 2982 if (!value) goto failed; | 2976 Py_DECREF(value); |
| 2983 if (_PyObject_SetAttrId(result, &PyId_n, value) == -1) | 2977 break; |
| 2984 goto failed; | 2978 case Str_kind: |
| 2985 Py_DECREF(value); | 2979 result = PyType_GenericNew(Str_type, NULL, NULL); |
| 2986 break; | 2980 if (!result) goto failed; |
| 2987 case Str_kind: | 2981 value = ast2obj_string(o->v.Str.s); |
| 2988 result = PyType_GenericNew(Str_type, NULL, NULL); | 2982 if (!value) goto failed; |
| 2989 if (!result) goto failed; | 2983 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) |
| 2990 value = ast2obj_string(o->v.Str.s); | 2984 goto failed; |
| 2991 if (!value) goto failed; | 2985 Py_DECREF(value); |
| 2992 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) | 2986 break; |
| 2993 goto failed; | 2987 case Bytes_kind: |
| 2994 Py_DECREF(value); | 2988 result = PyType_GenericNew(Bytes_type, NULL, NULL); |
| 2995 break; | 2989 if (!result) goto failed; |
| 2996 case Bytes_kind: | 2990 value = ast2obj_bytes(o->v.Bytes.s); |
| 2997 result = PyType_GenericNew(Bytes_type, NULL, NULL); | 2991 if (!value) goto failed; |
| 2998 if (!result) goto failed; | 2992 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) |
| 2999 value = ast2obj_bytes(o->v.Bytes.s); | 2993 goto failed; |
| 3000 if (!value) goto failed; | 2994 Py_DECREF(value); |
| 3001 if (_PyObject_SetAttrId(result, &PyId_s, value) == -1) | 2995 break; |
| 3002 goto failed; | 2996 case NameConstant_kind: |
| 3003 Py_DECREF(value); | 2997 result = PyType_GenericNew(NameConstant_type, NULL, NULL); |
| 3004 break; | 2998 if (!result) goto failed; |
| 3005 case NameConstant_kind: | 2999 value = ast2obj_singleton(o->v.NameConstant.value); |
| 3006 result = PyType_GenericNew(NameConstant_type, NULL, NULL); | 3000 if (!value) goto failed; |
| 3007 if (!result) goto failed; | 3001 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 3008 value = ast2obj_singleton(o->v.NameConstant.value); | 3002 goto failed; |
| 3009 if (!value) goto failed; | 3003 Py_DECREF(value); |
| 3010 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 3004 break; |
| 3011 goto failed; | 3005 case Ellipsis_kind: |
| 3012 Py_DECREF(value); | 3006 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); |
| 3013 break; | 3007 if (!result) goto failed; |
| 3014 case Ellipsis_kind: | 3008 break; |
| 3015 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); | 3009 case Attribute_kind: |
| 3016 if (!result) goto failed; | 3010 result = PyType_GenericNew(Attribute_type, NULL, NULL); |
| 3017 break; | 3011 if (!result) goto failed; |
| 3018 case Attribute_kind: | 3012 value = ast2obj_expr(o->v.Attribute.value); |
| 3019 result = PyType_GenericNew(Attribute_type, NULL, NULL); | 3013 if (!value) goto failed; |
| 3020 if (!result) goto failed; | 3014 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 3021 value = ast2obj_expr(o->v.Attribute.value); | 3015 goto failed; |
| 3022 if (!value) goto failed; | 3016 Py_DECREF(value); |
| 3023 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 3017 value = ast2obj_identifier(o->v.Attribute.attr); |
| 3024 goto failed; | 3018 if (!value) goto failed; |
| 3025 Py_DECREF(value); | 3019 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1) |
| 3026 value = ast2obj_identifier(o->v.Attribute.attr); | 3020 goto failed; |
| 3027 if (!value) goto failed; | 3021 Py_DECREF(value); |
| 3028 if (_PyObject_SetAttrId(result, &PyId_attr, value) == -1) | 3022 value = ast2obj_expr_context(o->v.Attribute.ctx); |
| 3029 goto failed; | 3023 if (!value) goto failed; |
| 3030 Py_DECREF(value); | 3024 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
| 3031 value = ast2obj_expr_context(o->v.Attribute.ctx); | 3025 goto failed; |
| 3032 if (!value) goto failed; | 3026 Py_DECREF(value); |
| 3033 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) | 3027 break; |
| 3034 goto failed; | 3028 case Subscript_kind: |
| 3035 Py_DECREF(value); | 3029 result = PyType_GenericNew(Subscript_type, NULL, NULL); |
| 3036 break; | 3030 if (!result) goto failed; |
| 3037 case Subscript_kind: | 3031 value = ast2obj_expr(o->v.Subscript.value); |
| 3038 result = PyType_GenericNew(Subscript_type, NULL, NULL); | 3032 if (!value) goto failed; |
| 3039 if (!result) goto failed; | 3033 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 3040 value = ast2obj_expr(o->v.Subscript.value); | 3034 goto failed; |
| 3041 if (!value) goto failed; | 3035 Py_DECREF(value); |
| 3042 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 3036 value = ast2obj_slice(o->v.Subscript.slice); |
| 3043 goto failed; | 3037 if (!value) goto failed; |
| 3044 Py_DECREF(value); | 3038 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1) |
| 3045 value = ast2obj_slice(o->v.Subscript.slice); | 3039 goto failed; |
| 3046 if (!value) goto failed; | 3040 Py_DECREF(value); |
| 3047 if (_PyObject_SetAttrId(result, &PyId_slice, value) == -1) | 3041 value = ast2obj_expr_context(o->v.Subscript.ctx); |
| 3048 goto failed; | 3042 if (!value) goto failed; |
| 3049 Py_DECREF(value); | 3043 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
| 3050 value = ast2obj_expr_context(o->v.Subscript.ctx); | 3044 goto failed; |
| 3051 if (!value) goto failed; | 3045 Py_DECREF(value); |
| 3052 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) | 3046 break; |
| 3053 goto failed; | 3047 case Starred_kind: |
| 3054 Py_DECREF(value); | 3048 result = PyType_GenericNew(Starred_type, NULL, NULL); |
| 3055 break; | 3049 if (!result) goto failed; |
| 3056 case Starred_kind: | 3050 value = ast2obj_expr(o->v.Starred.value); |
| 3057 result = PyType_GenericNew(Starred_type, NULL, NULL); | 3051 if (!value) goto failed; |
| 3058 if (!result) goto failed; | 3052 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 3059 value = ast2obj_expr(o->v.Starred.value); | 3053 goto failed; |
| 3060 if (!value) goto failed; | 3054 Py_DECREF(value); |
| 3061 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 3055 value = ast2obj_expr_context(o->v.Starred.ctx); |
| 3062 goto failed; | 3056 if (!value) goto failed; |
| 3063 Py_DECREF(value); | 3057 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
| 3064 value = ast2obj_expr_context(o->v.Starred.ctx); | 3058 goto failed; |
| 3065 if (!value) goto failed; | 3059 Py_DECREF(value); |
| 3066 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) | 3060 break; |
| 3067 goto failed; | 3061 case Name_kind: |
| 3068 Py_DECREF(value); | 3062 result = PyType_GenericNew(Name_type, NULL, NULL); |
| 3069 break; | 3063 if (!result) goto failed; |
| 3070 case Name_kind: | 3064 value = ast2obj_identifier(o->v.Name.id); |
| 3071 result = PyType_GenericNew(Name_type, NULL, NULL); | 3065 if (!value) goto failed; |
| 3072 if (!result) goto failed; | 3066 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1) |
| 3073 value = ast2obj_identifier(o->v.Name.id); | 3067 goto failed; |
| 3074 if (!value) goto failed; | 3068 Py_DECREF(value); |
| 3075 if (_PyObject_SetAttrId(result, &PyId_id, value) == -1) | 3069 value = ast2obj_expr_context(o->v.Name.ctx); |
| 3076 goto failed; | 3070 if (!value) goto failed; |
| 3077 Py_DECREF(value); | 3071 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
| 3078 value = ast2obj_expr_context(o->v.Name.ctx); | 3072 goto failed; |
| 3079 if (!value) goto failed; | 3073 Py_DECREF(value); |
| 3080 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) | 3074 break; |
| 3081 goto failed; | 3075 case List_kind: |
| 3082 Py_DECREF(value); | 3076 result = PyType_GenericNew(List_type, NULL, NULL); |
| 3083 break; | 3077 if (!result) goto failed; |
| 3084 case List_kind: | 3078 value = ast2obj_list(o->v.List.elts, ast2obj_expr); |
| 3085 result = PyType_GenericNew(List_type, NULL, NULL); | 3079 if (!value) goto failed; |
| 3086 if (!result) goto failed; | 3080 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) |
| 3087 value = ast2obj_list(o->v.List.elts, ast2obj_expr); | 3081 goto failed; |
| 3088 if (!value) goto failed; | 3082 Py_DECREF(value); |
| 3089 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) | 3083 value = ast2obj_expr_context(o->v.List.ctx); |
| 3090 goto failed; | 3084 if (!value) goto failed; |
| 3091 Py_DECREF(value); | 3085 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
| 3092 value = ast2obj_expr_context(o->v.List.ctx); | 3086 goto failed; |
| 3093 if (!value) goto failed; | 3087 Py_DECREF(value); |
| 3094 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) | 3088 break; |
| 3095 goto failed; | 3089 case Tuple_kind: |
| 3096 Py_DECREF(value); | 3090 result = PyType_GenericNew(Tuple_type, NULL, NULL); |
| 3097 break; | 3091 if (!result) goto failed; |
| 3098 case Tuple_kind: | 3092 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); |
| 3099 result = PyType_GenericNew(Tuple_type, NULL, NULL); | 3093 if (!value) goto failed; |
| 3100 if (!result) goto failed; | 3094 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) |
| 3101 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); | 3095 goto failed; |
| 3102 if (!value) goto failed; | 3096 Py_DECREF(value); |
| 3103 if (_PyObject_SetAttrId(result, &PyId_elts, value) == -1) | 3097 value = ast2obj_expr_context(o->v.Tuple.ctx); |
| 3104 goto failed; | 3098 if (!value) goto failed; |
| 3105 Py_DECREF(value); | 3099 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) |
| 3106 value = ast2obj_expr_context(o->v.Tuple.ctx); | 3100 goto failed; |
| 3107 if (!value) goto failed; | 3101 Py_DECREF(value); |
| 3108 if (_PyObject_SetAttrId(result, &PyId_ctx, value) == -1) | 3102 break; |
| 3109 goto failed; | 3103 } |
| 3110 Py_DECREF(value); | 3104 value = ast2obj_int(o->lineno); |
| 3111 break; | 3105 if (!value) goto failed; |
| 3112 } | 3106 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
| 3113 value = ast2obj_int(o->lineno); | 3107 goto failed; |
| 3114 if (!value) goto failed; | 3108 Py_DECREF(value); |
| 3115 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) | 3109 value = ast2obj_int(o->col_offset); |
| 3116 goto failed; | 3110 if (!value) goto failed; |
| 3117 Py_DECREF(value); | 3111 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
| 3118 value = ast2obj_int(o->col_offset); | 3112 goto failed; |
| 3119 if (!value) goto failed; | 3113 Py_DECREF(value); |
| 3120 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) | 3114 return result; |
| 3121 goto failed; | |
| 3122 Py_DECREF(value); | |
| 3123 return result; | |
| 3124 failed: | 3115 failed: |
| 3125 Py_XDECREF(value); | 3116 Py_XDECREF(value); |
| 3126 Py_XDECREF(result); | 3117 Py_XDECREF(result); |
| 3127 return NULL; | 3118 return NULL; |
| 3128 } | 3119 } |
| 3129 | 3120 |
| 3130 PyObject* ast2obj_expr_context(expr_context_ty o) | 3121 PyObject* ast2obj_expr_context(expr_context_ty o) |
| 3131 { | 3122 { |
| 3132 switch(o) { | 3123 switch(o) { |
| 3133 case Load: | 3124 case Load: |
| 3134 Py_INCREF(Load_singleton); | 3125 Py_INCREF(Load_singleton); |
| 3135 return Load_singleton; | 3126 return Load_singleton; |
| 3136 case Store: | 3127 case Store: |
| 3137 Py_INCREF(Store_singleton); | 3128 Py_INCREF(Store_singleton); |
| 3138 return Store_singleton; | 3129 return Store_singleton; |
| 3139 case Del: | 3130 case Del: |
| 3140 Py_INCREF(Del_singleton); | 3131 Py_INCREF(Del_singleton); |
| 3141 return Del_singleton; | 3132 return Del_singleton; |
| 3142 case AugLoad: | 3133 case AugLoad: |
| 3143 Py_INCREF(AugLoad_singleton); | 3134 Py_INCREF(AugLoad_singleton); |
| 3144 return AugLoad_singleton; | 3135 return AugLoad_singleton; |
| 3145 case AugStore: | 3136 case AugStore: |
| 3146 Py_INCREF(AugStore_singleton); | 3137 Py_INCREF(AugStore_singleton); |
| 3147 return AugStore_singleton; | 3138 return AugStore_singleton; |
| 3148 case Param: | 3139 case Param: |
| 3149 Py_INCREF(Param_singleton); | 3140 Py_INCREF(Param_singleton); |
| 3150 return Param_singleton; | 3141 return Param_singleton; |
| 3151 default: | 3142 default: |
| 3152 /* should never happen, but just in case ... */ | 3143 /* should never happen, but just in case ... */ |
| 3153 PyErr_Format(PyExc_SystemError, "unknown expr_context found"); | 3144 PyErr_Format(PyExc_SystemError, "unknown expr_context found"); |
| 3154 return NULL; | 3145 return NULL; |
| 3155 } | 3146 } |
| 3156 } | 3147 } |
| 3157 PyObject* | 3148 PyObject* |
| 3158 ast2obj_slice(void* _o) | 3149 ast2obj_slice(void* _o) |
| 3159 { | 3150 { |
| 3160 slice_ty o = (slice_ty)_o; | 3151 slice_ty o = (slice_ty)_o; |
| 3161 PyObject *result = NULL, *value = NULL; | 3152 PyObject *result = NULL, *value = NULL; |
| 3162 if (!o) { | 3153 if (!o) { |
| 3163 Py_INCREF(Py_None); | 3154 Py_INCREF(Py_None); |
| 3164 return Py_None; | 3155 return Py_None; |
| 3165 } | 3156 } |
| 3166 | 3157 |
| 3167 switch (o->kind) { | 3158 switch (o->kind) { |
| 3168 case Slice_kind: | 3159 case Slice_kind: |
| 3169 result = PyType_GenericNew(Slice_type, NULL, NULL); | 3160 result = PyType_GenericNew(Slice_type, NULL, NULL); |
| 3170 if (!result) goto failed; | 3161 if (!result) goto failed; |
| 3171 value = ast2obj_expr(o->v.Slice.lower); | 3162 value = ast2obj_expr(o->v.Slice.lower); |
| 3172 if (!value) goto failed; | 3163 if (!value) goto failed; |
| 3173 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1) | 3164 if (_PyObject_SetAttrId(result, &PyId_lower, value) == -1) |
| 3174 goto failed; | 3165 goto failed; |
| 3175 Py_DECREF(value); | 3166 Py_DECREF(value); |
| 3176 value = ast2obj_expr(o->v.Slice.upper); | 3167 value = ast2obj_expr(o->v.Slice.upper); |
| 3177 if (!value) goto failed; | 3168 if (!value) goto failed; |
| 3178 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1) | 3169 if (_PyObject_SetAttrId(result, &PyId_upper, value) == -1) |
| 3179 goto failed; | 3170 goto failed; |
| 3180 Py_DECREF(value); | 3171 Py_DECREF(value); |
| 3181 value = ast2obj_expr(o->v.Slice.step); | 3172 value = ast2obj_expr(o->v.Slice.step); |
| 3182 if (!value) goto failed; | 3173 if (!value) goto failed; |
| 3183 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1) | 3174 if (_PyObject_SetAttrId(result, &PyId_step, value) == -1) |
| 3184 goto failed; | 3175 goto failed; |
| 3185 Py_DECREF(value); | 3176 Py_DECREF(value); |
| 3186 break; | 3177 break; |
| 3187 case ExtSlice_kind: | 3178 case ExtSlice_kind: |
| 3188 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); | 3179 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); |
| 3189 if (!result) goto failed; | 3180 if (!result) goto failed; |
| 3190 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); | 3181 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); |
| 3191 if (!value) goto failed; | 3182 if (!value) goto failed; |
| 3192 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1) | 3183 if (_PyObject_SetAttrId(result, &PyId_dims, value) == -1) |
| 3193 goto failed; | 3184 goto failed; |
| 3194 Py_DECREF(value); | 3185 Py_DECREF(value); |
| 3195 break; | 3186 break; |
| 3196 case Index_kind: | 3187 case Index_kind: |
| 3197 result = PyType_GenericNew(Index_type, NULL, NULL); | 3188 result = PyType_GenericNew(Index_type, NULL, NULL); |
| 3198 if (!result) goto failed; | 3189 if (!result) goto failed; |
| 3199 value = ast2obj_expr(o->v.Index.value); | 3190 value = ast2obj_expr(o->v.Index.value); |
| 3200 if (!value) goto failed; | 3191 if (!value) goto failed; |
| 3201 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 3192 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 3202 goto failed; | 3193 goto failed; |
| 3203 Py_DECREF(value); | 3194 Py_DECREF(value); |
| 3204 break; | 3195 break; |
| 3205 } | 3196 } |
| 3206 return result; | 3197 return result; |
| 3207 failed: | 3198 failed: |
| 3208 Py_XDECREF(value); | 3199 Py_XDECREF(value); |
| 3209 Py_XDECREF(result); | 3200 Py_XDECREF(result); |
| 3210 return NULL; | 3201 return NULL; |
| 3211 } | 3202 } |
| 3212 | 3203 |
| 3213 PyObject* ast2obj_boolop(boolop_ty o) | 3204 PyObject* ast2obj_boolop(boolop_ty o) |
| 3214 { | 3205 { |
| 3215 switch(o) { | 3206 switch(o) { |
| 3216 case And: | 3207 case And: |
| 3217 Py_INCREF(And_singleton); | 3208 Py_INCREF(And_singleton); |
| 3218 return And_singleton; | 3209 return And_singleton; |
| 3219 case Or: | 3210 case Or: |
| 3220 Py_INCREF(Or_singleton); | 3211 Py_INCREF(Or_singleton); |
| 3221 return Or_singleton; | 3212 return Or_singleton; |
| 3222 default: | 3213 default: |
| 3223 /* should never happen, but just in case ... */ | 3214 /* should never happen, but just in case ... */ |
| 3224 PyErr_Format(PyExc_SystemError, "unknown boolop found"); | 3215 PyErr_Format(PyExc_SystemError, "unknown boolop found"); |
| 3225 return NULL; | 3216 return NULL; |
| 3226 } | 3217 } |
| 3227 } | 3218 } |
| 3228 PyObject* ast2obj_operator(operator_ty o) | 3219 PyObject* ast2obj_operator(operator_ty o) |
| 3229 { | 3220 { |
| 3230 switch(o) { | 3221 switch(o) { |
| 3231 case Add: | 3222 case Add: |
| 3232 Py_INCREF(Add_singleton); | 3223 Py_INCREF(Add_singleton); |
| 3233 return Add_singleton; | 3224 return Add_singleton; |
| 3234 case Sub: | 3225 case Sub: |
| 3235 Py_INCREF(Sub_singleton); | 3226 Py_INCREF(Sub_singleton); |
| 3236 return Sub_singleton; | 3227 return Sub_singleton; |
| 3237 case Mult: | 3228 case Mult: |
| 3238 Py_INCREF(Mult_singleton); | 3229 Py_INCREF(Mult_singleton); |
| 3239 return Mult_singleton; | 3230 return Mult_singleton; |
| 3240 case Div: | 3231 case Div: |
| 3241 Py_INCREF(Div_singleton); | 3232 Py_INCREF(Div_singleton); |
| 3242 return Div_singleton; | 3233 return Div_singleton; |
| 3243 case Mod: | 3234 case Mod: |
| 3244 Py_INCREF(Mod_singleton); | 3235 Py_INCREF(Mod_singleton); |
| 3245 return Mod_singleton; | 3236 return Mod_singleton; |
| 3246 case Pow: | 3237 case Pow: |
| 3247 Py_INCREF(Pow_singleton); | 3238 Py_INCREF(Pow_singleton); |
| 3248 return Pow_singleton; | 3239 return Pow_singleton; |
| 3249 case LShift: | 3240 case LShift: |
| 3250 Py_INCREF(LShift_singleton); | 3241 Py_INCREF(LShift_singleton); |
| 3251 return LShift_singleton; | 3242 return LShift_singleton; |
| 3252 case RShift: | 3243 case RShift: |
| 3253 Py_INCREF(RShift_singleton); | 3244 Py_INCREF(RShift_singleton); |
| 3254 return RShift_singleton; | 3245 return RShift_singleton; |
| 3255 case BitOr: | 3246 case BitOr: |
| 3256 Py_INCREF(BitOr_singleton); | 3247 Py_INCREF(BitOr_singleton); |
| 3257 return BitOr_singleton; | 3248 return BitOr_singleton; |
| 3258 case BitXor: | 3249 case BitXor: |
| 3259 Py_INCREF(BitXor_singleton); | 3250 Py_INCREF(BitXor_singleton); |
| 3260 return BitXor_singleton; | 3251 return BitXor_singleton; |
| 3261 case BitAnd: | 3252 case BitAnd: |
| 3262 Py_INCREF(BitAnd_singleton); | 3253 Py_INCREF(BitAnd_singleton); |
| 3263 return BitAnd_singleton; | 3254 return BitAnd_singleton; |
| 3264 case FloorDiv: | 3255 case FloorDiv: |
| 3265 Py_INCREF(FloorDiv_singleton); | 3256 Py_INCREF(FloorDiv_singleton); |
| 3266 return FloorDiv_singleton; | 3257 return FloorDiv_singleton; |
| 3267 default: | 3258 default: |
| 3268 /* should never happen, but just in case ... */ | 3259 /* should never happen, but just in case ... */ |
| 3269 PyErr_Format(PyExc_SystemError, "unknown operator found"); | 3260 PyErr_Format(PyExc_SystemError, "unknown operator found"); |
| 3270 return NULL; | 3261 return NULL; |
| 3271 } | 3262 } |
| 3272 } | 3263 } |
| 3273 PyObject* ast2obj_unaryop(unaryop_ty o) | 3264 PyObject* ast2obj_unaryop(unaryop_ty o) |
| 3274 { | 3265 { |
| 3275 switch(o) { | 3266 switch(o) { |
| 3276 case Invert: | 3267 case Invert: |
| 3277 Py_INCREF(Invert_singleton); | 3268 Py_INCREF(Invert_singleton); |
| 3278 return Invert_singleton; | 3269 return Invert_singleton; |
| 3279 case Not: | 3270 case Not: |
| 3280 Py_INCREF(Not_singleton); | 3271 Py_INCREF(Not_singleton); |
| 3281 return Not_singleton; | 3272 return Not_singleton; |
| 3282 case UAdd: | 3273 case UAdd: |
| 3283 Py_INCREF(UAdd_singleton); | 3274 Py_INCREF(UAdd_singleton); |
| 3284 return UAdd_singleton; | 3275 return UAdd_singleton; |
| 3285 case USub: | 3276 case USub: |
| 3286 Py_INCREF(USub_singleton); | 3277 Py_INCREF(USub_singleton); |
| 3287 return USub_singleton; | 3278 return USub_singleton; |
| 3288 default: | 3279 default: |
| 3289 /* should never happen, but just in case ... */ | 3280 /* should never happen, but just in case ... */ |
| 3290 PyErr_Format(PyExc_SystemError, "unknown unaryop found"); | 3281 PyErr_Format(PyExc_SystemError, "unknown unaryop found"); |
| 3291 return NULL; | 3282 return NULL; |
| 3292 } | 3283 } |
| 3293 } | 3284 } |
| 3294 PyObject* ast2obj_cmpop(cmpop_ty o) | 3285 PyObject* ast2obj_cmpop(cmpop_ty o) |
| 3295 { | 3286 { |
| 3296 switch(o) { | 3287 switch(o) { |
| 3297 case Eq: | 3288 case Eq: |
| 3298 Py_INCREF(Eq_singleton); | 3289 Py_INCREF(Eq_singleton); |
| 3299 return Eq_singleton; | 3290 return Eq_singleton; |
| 3300 case NotEq: | 3291 case NotEq: |
| 3301 Py_INCREF(NotEq_singleton); | 3292 Py_INCREF(NotEq_singleton); |
| 3302 return NotEq_singleton; | 3293 return NotEq_singleton; |
| 3303 case Lt: | 3294 case Lt: |
| 3304 Py_INCREF(Lt_singleton); | 3295 Py_INCREF(Lt_singleton); |
| 3305 return Lt_singleton; | 3296 return Lt_singleton; |
| 3306 case LtE: | 3297 case LtE: |
| 3307 Py_INCREF(LtE_singleton); | 3298 Py_INCREF(LtE_singleton); |
| 3308 return LtE_singleton; | 3299 return LtE_singleton; |
| 3309 case Gt: | 3300 case Gt: |
| 3310 Py_INCREF(Gt_singleton); | 3301 Py_INCREF(Gt_singleton); |
| 3311 return Gt_singleton; | 3302 return Gt_singleton; |
| 3312 case GtE: | 3303 case GtE: |
| 3313 Py_INCREF(GtE_singleton); | 3304 Py_INCREF(GtE_singleton); |
| 3314 return GtE_singleton; | 3305 return GtE_singleton; |
| 3315 case Is: | 3306 case Is: |
| 3316 Py_INCREF(Is_singleton); | 3307 Py_INCREF(Is_singleton); |
| 3317 return Is_singleton; | 3308 return Is_singleton; |
| 3318 case IsNot: | 3309 case IsNot: |
| 3319 Py_INCREF(IsNot_singleton); | 3310 Py_INCREF(IsNot_singleton); |
| 3320 return IsNot_singleton; | 3311 return IsNot_singleton; |
| 3321 case In: | 3312 case In: |
| 3322 Py_INCREF(In_singleton); | 3313 Py_INCREF(In_singleton); |
| 3323 return In_singleton; | 3314 return In_singleton; |
| 3324 case NotIn: | 3315 case NotIn: |
| 3325 Py_INCREF(NotIn_singleton); | 3316 Py_INCREF(NotIn_singleton); |
| 3326 return NotIn_singleton; | 3317 return NotIn_singleton; |
| 3327 default: | 3318 default: |
| 3328 /* should never happen, but just in case ... */ | 3319 /* should never happen, but just in case ... */ |
| 3329 PyErr_Format(PyExc_SystemError, "unknown cmpop found"); | 3320 PyErr_Format(PyExc_SystemError, "unknown cmpop found"); |
| 3330 return NULL; | 3321 return NULL; |
| 3331 } | 3322 } |
| 3332 } | 3323 } |
| 3333 PyObject* | 3324 PyObject* |
| 3334 ast2obj_comprehension(void* _o) | 3325 ast2obj_comprehension(void* _o) |
| 3335 { | 3326 { |
| 3336 comprehension_ty o = (comprehension_ty)_o; | 3327 comprehension_ty o = (comprehension_ty)_o; |
| 3337 PyObject *result = NULL, *value = NULL; | 3328 PyObject *result = NULL, *value = NULL; |
| 3338 if (!o) { | 3329 if (!o) { |
| 3339 Py_INCREF(Py_None); | 3330 Py_INCREF(Py_None); |
| 3340 return Py_None; | 3331 return Py_None; |
| 3341 } | 3332 } |
| 3342 | 3333 |
| 3343 result = PyType_GenericNew(comprehension_type, NULL, NULL); | 3334 result = PyType_GenericNew(comprehension_type, NULL, NULL); |
| 3344 if (!result) return NULL; | 3335 if (!result) return NULL; |
| 3345 value = ast2obj_expr(o->target); | 3336 value = ast2obj_expr(o->target); |
| 3346 if (!value) goto failed; | 3337 if (!value) goto failed; |
| 3347 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) | 3338 if (_PyObject_SetAttrId(result, &PyId_target, value) == -1) |
| 3348 goto failed; | 3339 goto failed; |
| 3349 Py_DECREF(value); | 3340 Py_DECREF(value); |
| 3350 value = ast2obj_expr(o->iter); | 3341 value = ast2obj_expr(o->iter); |
| 3351 if (!value) goto failed; | 3342 if (!value) goto failed; |
| 3352 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) | 3343 if (_PyObject_SetAttrId(result, &PyId_iter, value) == -1) |
| 3353 goto failed; | 3344 goto failed; |
| 3354 Py_DECREF(value); | 3345 Py_DECREF(value); |
| 3355 value = ast2obj_list(o->ifs, ast2obj_expr); | 3346 value = ast2obj_list(o->ifs, ast2obj_expr); |
| 3356 if (!value) goto failed; | 3347 if (!value) goto failed; |
| 3357 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1) | 3348 if (_PyObject_SetAttrId(result, &PyId_ifs, value) == -1) |
| 3358 goto failed; | 3349 goto failed; |
| 3359 Py_DECREF(value); | 3350 Py_DECREF(value); |
| 3360 return result; | 3351 return result; |
| 3361 failed: | 3352 failed: |
| 3362 Py_XDECREF(value); | 3353 Py_XDECREF(value); |
| 3363 Py_XDECREF(result); | 3354 Py_XDECREF(result); |
| 3364 return NULL; | 3355 return NULL; |
| 3365 } | 3356 } |
| 3366 | 3357 |
| 3367 PyObject* | 3358 PyObject* |
| 3368 ast2obj_excepthandler(void* _o) | 3359 ast2obj_excepthandler(void* _o) |
| 3369 { | 3360 { |
| 3370 excepthandler_ty o = (excepthandler_ty)_o; | 3361 excepthandler_ty o = (excepthandler_ty)_o; |
| 3371 PyObject *result = NULL, *value = NULL; | 3362 PyObject *result = NULL, *value = NULL; |
| 3372 if (!o) { | 3363 if (!o) { |
| 3373 Py_INCREF(Py_None); | 3364 Py_INCREF(Py_None); |
| 3374 return Py_None; | 3365 return Py_None; |
| 3375 } | 3366 } |
| 3376 | 3367 |
| 3377 switch (o->kind) { | 3368 switch (o->kind) { |
| 3378 case ExceptHandler_kind: | 3369 case ExceptHandler_kind: |
| 3379 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL); | 3370 result = PyType_GenericNew(ExceptHandler_type, NULL, NULL); |
| 3380 if (!result) goto failed; | 3371 if (!result) goto failed; |
| 3381 value = ast2obj_expr(o->v.ExceptHandler.type); | 3372 value = ast2obj_expr(o->v.ExceptHandler.type); |
| 3382 if (!value) goto failed; | 3373 if (!value) goto failed; |
| 3383 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1) | 3374 if (_PyObject_SetAttrId(result, &PyId_type, value) == -1) |
| 3384 goto failed; | 3375 goto failed; |
| 3385 Py_DECREF(value); | 3376 Py_DECREF(value); |
| 3386 value = ast2obj_identifier(o->v.ExceptHandler.name); | 3377 value = ast2obj_identifier(o->v.ExceptHandler.name); |
| 3387 if (!value) goto failed; | 3378 if (!value) goto failed; |
| 3388 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) | 3379 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
| 3389 goto failed; | 3380 goto failed; |
| 3390 Py_DECREF(value); | 3381 Py_DECREF(value); |
| 3391 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt); | 3382 value = ast2obj_list(o->v.ExceptHandler.body, ast2obj_stmt); |
| 3392 if (!value) goto failed; | 3383 if (!value) goto failed; |
| 3393 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) | 3384 if (_PyObject_SetAttrId(result, &PyId_body, value) == -1) |
| 3394 goto failed; | 3385 goto failed; |
| 3395 Py_DECREF(value); | 3386 Py_DECREF(value); |
| 3396 break; | 3387 break; |
| 3397 } | 3388 } |
| 3398 value = ast2obj_int(o->lineno); | 3389 value = ast2obj_int(o->lineno); |
| 3399 if (!value) goto failed; | 3390 if (!value) goto failed; |
| 3400 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) | 3391 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
| 3401 goto failed; | 3392 goto failed; |
| 3402 Py_DECREF(value); | 3393 Py_DECREF(value); |
| 3403 value = ast2obj_int(o->col_offset); | 3394 value = ast2obj_int(o->col_offset); |
| 3404 if (!value) goto failed; | 3395 if (!value) goto failed; |
| 3405 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) | 3396 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
| 3406 goto failed; | 3397 goto failed; |
| 3407 Py_DECREF(value); | 3398 Py_DECREF(value); |
| 3408 return result; | 3399 return result; |
| 3409 failed: | 3400 failed: |
| 3410 Py_XDECREF(value); | 3401 Py_XDECREF(value); |
| 3411 Py_XDECREF(result); | 3402 Py_XDECREF(result); |
| 3412 return NULL; | 3403 return NULL; |
| 3413 } | 3404 } |
| 3414 | 3405 |
| 3415 PyObject* | 3406 PyObject* |
| 3416 ast2obj_arguments(void* _o) | 3407 ast2obj_arguments(void* _o) |
| 3417 { | 3408 { |
| 3418 arguments_ty o = (arguments_ty)_o; | 3409 arguments_ty o = (arguments_ty)_o; |
| 3419 PyObject *result = NULL, *value = NULL; | 3410 PyObject *result = NULL, *value = NULL; |
| 3420 if (!o) { | 3411 if (!o) { |
| 3421 Py_INCREF(Py_None); | 3412 Py_INCREF(Py_None); |
| 3422 return Py_None; | 3413 return Py_None; |
| 3423 } | 3414 } |
| 3424 | 3415 |
| 3425 result = PyType_GenericNew(arguments_type, NULL, NULL); | 3416 result = PyType_GenericNew(arguments_type, NULL, NULL); |
| 3426 if (!result) return NULL; | 3417 if (!result) return NULL; |
| 3427 value = ast2obj_list(o->args, ast2obj_arg); | 3418 value = ast2obj_list(o->args, ast2obj_arg); |
| 3428 if (!value) goto failed; | 3419 if (!value) goto failed; |
| 3429 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) | 3420 if (_PyObject_SetAttrId(result, &PyId_args, value) == -1) |
| 3430 goto failed; | 3421 goto failed; |
| 3431 Py_DECREF(value); | 3422 Py_DECREF(value); |
| 3432 value = ast2obj_arg(o->vararg); | 3423 value = ast2obj_arg(o->vararg); |
| 3433 if (!value) goto failed; | 3424 if (!value) goto failed; |
| 3434 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1) | 3425 if (_PyObject_SetAttrId(result, &PyId_vararg, value) == -1) |
| 3435 goto failed; | 3426 goto failed; |
| 3436 Py_DECREF(value); | 3427 Py_DECREF(value); |
| 3437 value = ast2obj_list(o->kwonlyargs, ast2obj_arg); | 3428 value = ast2obj_list(o->kwonlyargs, ast2obj_arg); |
| 3438 if (!value) goto failed; | 3429 if (!value) goto failed; |
| 3439 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1) | 3430 if (_PyObject_SetAttrId(result, &PyId_kwonlyargs, value) == -1) |
| 3440 goto failed; | 3431 goto failed; |
| 3441 Py_DECREF(value); | 3432 Py_DECREF(value); |
| 3442 value = ast2obj_list(o->kw_defaults, ast2obj_expr); | 3433 value = ast2obj_list(o->kw_defaults, ast2obj_expr); |
| 3443 if (!value) goto failed; | 3434 if (!value) goto failed; |
| 3444 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1) | 3435 if (_PyObject_SetAttrId(result, &PyId_kw_defaults, value) == -1) |
| 3445 goto failed; | 3436 goto failed; |
| 3446 Py_DECREF(value); | 3437 Py_DECREF(value); |
| 3447 value = ast2obj_arg(o->kwarg); | 3438 value = ast2obj_arg(o->kwarg); |
| 3448 if (!value) goto failed; | 3439 if (!value) goto failed; |
| 3449 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1) | 3440 if (_PyObject_SetAttrId(result, &PyId_kwarg, value) == -1) |
| 3450 goto failed; | 3441 goto failed; |
| 3451 Py_DECREF(value); | 3442 Py_DECREF(value); |
| 3452 value = ast2obj_list(o->defaults, ast2obj_expr); | 3443 value = ast2obj_list(o->defaults, ast2obj_expr); |
| 3453 if (!value) goto failed; | 3444 if (!value) goto failed; |
| 3454 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1) | 3445 if (_PyObject_SetAttrId(result, &PyId_defaults, value) == -1) |
| 3455 goto failed; | 3446 goto failed; |
| 3456 Py_DECREF(value); | 3447 Py_DECREF(value); |
| 3457 return result; | 3448 return result; |
| 3458 failed: | 3449 failed: |
| 3459 Py_XDECREF(value); | 3450 Py_XDECREF(value); |
| 3460 Py_XDECREF(result); | 3451 Py_XDECREF(result); |
| 3461 return NULL; | 3452 return NULL; |
| 3462 } | 3453 } |
| 3463 | 3454 |
| 3464 PyObject* | 3455 PyObject* |
| 3465 ast2obj_arg(void* _o) | 3456 ast2obj_arg(void* _o) |
| 3466 { | 3457 { |
| 3467 arg_ty o = (arg_ty)_o; | 3458 arg_ty o = (arg_ty)_o; |
| 3468 PyObject *result = NULL, *value = NULL; | 3459 PyObject *result = NULL, *value = NULL; |
| 3469 if (!o) { | 3460 if (!o) { |
| 3470 Py_INCREF(Py_None); | 3461 Py_INCREF(Py_None); |
| 3471 return Py_None; | 3462 return Py_None; |
| 3472 } | 3463 } |
| 3473 | 3464 |
| 3474 result = PyType_GenericNew(arg_type, NULL, NULL); | 3465 result = PyType_GenericNew(arg_type, NULL, NULL); |
| 3475 if (!result) return NULL; | 3466 if (!result) return NULL; |
| 3476 value = ast2obj_identifier(o->arg); | 3467 value = ast2obj_identifier(o->arg); |
| 3477 if (!value) goto failed; | 3468 if (!value) goto failed; |
| 3478 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) | 3469 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) |
| 3479 goto failed; | 3470 goto failed; |
| 3480 Py_DECREF(value); | 3471 Py_DECREF(value); |
| 3481 value = ast2obj_expr(o->annotation); | 3472 value = ast2obj_expr(o->annotation); |
| 3482 if (!value) goto failed; | 3473 if (!value) goto failed; |
| 3483 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1) | 3474 if (_PyObject_SetAttrId(result, &PyId_annotation, value) == -1) |
| 3484 goto failed; | 3475 goto failed; |
| 3485 Py_DECREF(value); | 3476 Py_DECREF(value); |
| 3486 value = ast2obj_int(o->lineno); | 3477 value = ast2obj_int(o->lineno); |
| 3487 if (!value) goto failed; | 3478 if (!value) goto failed; |
| 3488 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) | 3479 if (_PyObject_SetAttrId(result, &PyId_lineno, value) < 0) |
| 3489 goto failed; | 3480 goto failed; |
| 3490 Py_DECREF(value); | 3481 Py_DECREF(value); |
| 3491 value = ast2obj_int(o->col_offset); | 3482 value = ast2obj_int(o->col_offset); |
| 3492 if (!value) goto failed; | 3483 if (!value) goto failed; |
| 3493 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) | 3484 if (_PyObject_SetAttrId(result, &PyId_col_offset, value) < 0) |
| 3494 goto failed; | 3485 goto failed; |
| 3495 Py_DECREF(value); | 3486 Py_DECREF(value); |
| 3496 return result; | 3487 return result; |
| 3497 failed: | 3488 failed: |
| 3498 Py_XDECREF(value); | 3489 Py_XDECREF(value); |
| 3499 Py_XDECREF(result); | 3490 Py_XDECREF(result); |
| 3500 return NULL; | 3491 return NULL; |
| 3501 } | 3492 } |
| 3502 | 3493 |
| 3503 PyObject* | 3494 PyObject* |
| 3504 ast2obj_keyword(void* _o) | 3495 ast2obj_keyword(void* _o) |
| 3505 { | 3496 { |
| 3506 keyword_ty o = (keyword_ty)_o; | 3497 keyword_ty o = (keyword_ty)_o; |
| 3507 PyObject *result = NULL, *value = NULL; | 3498 PyObject *result = NULL, *value = NULL; |
| 3508 if (!o) { | 3499 if (!o) { |
| 3509 Py_INCREF(Py_None); | 3500 Py_INCREF(Py_None); |
| 3510 return Py_None; | 3501 return Py_None; |
| 3511 } | 3502 } |
| 3512 | 3503 |
| 3513 result = PyType_GenericNew(keyword_type, NULL, NULL); | 3504 result = PyType_GenericNew(keyword_type, NULL, NULL); |
| 3514 if (!result) return NULL; | 3505 if (!result) return NULL; |
| 3515 value = ast2obj_identifier(o->arg); | 3506 value = ast2obj_identifier(o->arg); |
| 3516 if (!value) goto failed; | 3507 if (!value) goto failed; |
| 3517 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) | 3508 if (_PyObject_SetAttrId(result, &PyId_arg, value) == -1) |
| 3518 goto failed; | 3509 goto failed; |
| 3519 Py_DECREF(value); | 3510 Py_DECREF(value); |
| 3520 value = ast2obj_expr(o->value); | 3511 value = ast2obj_expr(o->value); |
| 3521 if (!value) goto failed; | 3512 if (!value) goto failed; |
| 3522 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) | 3513 if (_PyObject_SetAttrId(result, &PyId_value, value) == -1) |
| 3523 goto failed; | 3514 goto failed; |
| 3524 Py_DECREF(value); | 3515 Py_DECREF(value); |
| 3525 return result; | 3516 return result; |
| 3526 failed: | 3517 failed: |
| 3527 Py_XDECREF(value); | 3518 Py_XDECREF(value); |
| 3528 Py_XDECREF(result); | 3519 Py_XDECREF(result); |
| 3529 return NULL; | 3520 return NULL; |
| 3530 } | 3521 } |
| 3531 | 3522 |
| 3532 PyObject* | 3523 PyObject* |
| 3533 ast2obj_alias(void* _o) | 3524 ast2obj_alias(void* _o) |
| 3534 { | 3525 { |
| 3535 alias_ty o = (alias_ty)_o; | 3526 alias_ty o = (alias_ty)_o; |
| 3536 PyObject *result = NULL, *value = NULL; | 3527 PyObject *result = NULL, *value = NULL; |
| 3537 if (!o) { | 3528 if (!o) { |
| 3538 Py_INCREF(Py_None); | 3529 Py_INCREF(Py_None); |
| 3539 return Py_None; | 3530 return Py_None; |
| 3540 } | 3531 } |
| 3541 | 3532 |
| 3542 result = PyType_GenericNew(alias_type, NULL, NULL); | 3533 result = PyType_GenericNew(alias_type, NULL, NULL); |
| 3543 if (!result) return NULL; | 3534 if (!result) return NULL; |
| 3544 value = ast2obj_identifier(o->name); | 3535 value = ast2obj_identifier(o->name); |
| 3545 if (!value) goto failed; | 3536 if (!value) goto failed; |
| 3546 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) | 3537 if (_PyObject_SetAttrId(result, &PyId_name, value) == -1) |
| 3547 goto failed; | 3538 goto failed; |
| 3548 Py_DECREF(value); | 3539 Py_DECREF(value); |
| 3549 value = ast2obj_identifier(o->asname); | 3540 value = ast2obj_identifier(o->asname); |
| 3550 if (!value) goto failed; | 3541 if (!value) goto failed; |
| 3551 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1) | 3542 if (_PyObject_SetAttrId(result, &PyId_asname, value) == -1) |
| 3552 goto failed; | 3543 goto failed; |
| 3553 Py_DECREF(value); | 3544 Py_DECREF(value); |
| 3554 return result; | 3545 return result; |
| 3555 failed: | 3546 failed: |
| 3556 Py_XDECREF(value); | 3547 Py_XDECREF(value); |
| 3557 Py_XDECREF(result); | 3548 Py_XDECREF(result); |
| 3558 return NULL; | 3549 return NULL; |
| 3559 } | 3550 } |
| 3560 | 3551 |
| 3561 PyObject* | 3552 PyObject* |
| 3562 ast2obj_withitem(void* _o) | 3553 ast2obj_withitem(void* _o) |
| 3563 { | 3554 { |
| 3564 withitem_ty o = (withitem_ty)_o; | 3555 withitem_ty o = (withitem_ty)_o; |
| 3565 PyObject *result = NULL, *value = NULL; | 3556 PyObject *result = NULL, *value = NULL; |
| 3566 if (!o) { | 3557 if (!o) { |
| 3567 Py_INCREF(Py_None); | 3558 Py_INCREF(Py_None); |
| 3568 return Py_None; | 3559 return Py_None; |
| 3569 } | 3560 } |
| 3570 | 3561 |
| 3571 result = PyType_GenericNew(withitem_type, NULL, NULL); | 3562 result = PyType_GenericNew(withitem_type, NULL, NULL); |
| 3572 if (!result) return NULL; | 3563 if (!result) return NULL; |
| 3573 value = ast2obj_expr(o->context_expr); | 3564 value = ast2obj_expr(o->context_expr); |
| 3574 if (!value) goto failed; | 3565 if (!value) goto failed; |
| 3575 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1) | 3566 if (_PyObject_SetAttrId(result, &PyId_context_expr, value) == -1) |
| 3576 goto failed; | 3567 goto failed; |
| 3577 Py_DECREF(value); | 3568 Py_DECREF(value); |
| 3578 value = ast2obj_expr(o->optional_vars); | 3569 value = ast2obj_expr(o->optional_vars); |
| 3579 if (!value) goto failed; | 3570 if (!value) goto failed; |
| 3580 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1) | 3571 if (_PyObject_SetAttrId(result, &PyId_optional_vars, value) == -1) |
| 3581 goto failed; | 3572 goto failed; |
| 3582 Py_DECREF(value); | 3573 Py_DECREF(value); |
| 3583 return result; | 3574 return result; |
| 3584 failed: | 3575 failed: |
| 3585 Py_XDECREF(value); | 3576 Py_XDECREF(value); |
| 3586 Py_XDECREF(result); | 3577 Py_XDECREF(result); |
| 3587 return NULL; | 3578 return NULL; |
| 3588 } | 3579 } |
| 3589 | 3580 |
| 3590 | 3581 |
| 3591 int | 3582 int |
| 3592 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) | 3583 obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena) |
| 3593 { | 3584 { |
| 3594 int isinstance; | 3585 int isinstance; |
| 3595 | 3586 |
| 3596 PyObject *tmp = NULL; | 3587 PyObject *tmp = NULL; |
| 3597 | 3588 |
| 3598 if (obj == Py_None) { | 3589 if (obj == Py_None) { |
| 3599 *out = NULL; | 3590 *out = NULL; |
| 3600 return 0; | 3591 return 0; |
| 3601 } | 3592 } |
| 3602 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); | 3593 isinstance = PyObject_IsInstance(obj, (PyObject*)Module_type); |
| 3603 if (isinstance == -1) { | 3594 if (isinstance == -1) { |
| 3604 return 1; | 3595 return 1; |
| 3605 } | 3596 } |
| 3606 if (isinstance) { | 3597 if (isinstance) { |
| 3607 asdl_seq* body; | 3598 asdl_seq* body; |
| 3608 | 3599 |
| 3609 if (_PyObject_HasAttrId(obj, &PyId_body)) { | 3600 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
| 3610 int res; | 3601 int res; |
| 3611 Py_ssize_t len; | 3602 Py_ssize_t len; |
| 3612 Py_ssize_t i; | 3603 Py_ssize_t i; |
| 3613 tmp = _PyObject_GetAttrId(obj, &PyId_body); | 3604 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
| 3614 if (tmp == NULL) goto failed; | 3605 if (tmp == NULL) goto failed; |
| 3615 if (!PyList_Check(tmp)) { | 3606 if (!PyList_Check(tmp)) { |
| 3616 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 3607 PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 3617 goto failed; | 3608 goto failed; |
| 3618 } | 3609 } |
| 3619 len = PyList_GET_SIZE(tmp); | 3610 len = PyList_GET_SIZE(tmp); |
| 3620 body = asdl_seq_new(len, arena); | 3611 body = asdl_seq_new(len, arena); |
| 3621 if (body == NULL) goto failed; | 3612 if (body == NULL) goto failed; |
| 3622 for (i = 0; i < len; i++) { | 3613 for (i = 0; i < len; i++) { |
| 3623 stmt_ty value; | 3614 stmt_ty value; |
| 3624 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | 3615 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
| 3625 if (res != 0) goto failed; | 3616 if (res != 0) goto failed; |
| 3626 asdl_seq_SET(body, i, value); | 3617 asdl_seq_SET(body, i, value); |
| 3627 } | 3618 } |
| 3628 Py_XDECREF(tmp); | 3619 Py_XDECREF(tmp); |
| 3629 tmp = NULL; | 3620 tmp = NULL; |
| 3630 } else { | 3621 } else { |
| 3631 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module"); | 3622 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module"); |
| 3632 return 1; | 3623 return 1; |
| 3633 } | 3624 } |
| 3634 *out = Module(body, arena); | 3625 *out = Module(body, arena); |
| 3635 if (*out == NULL) goto failed; | 3626 if (*out == NULL) goto failed; |
| 3636 return 0; | 3627 return 0; |
| 3637 } | 3628 } |
| 3638 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); | 3629 isinstance = PyObject_IsInstance(obj, (PyObject*)Interactive_type); |
| 3639 if (isinstance == -1) { | 3630 if (isinstance == -1) { |
| 3640 return 1; | 3631 return 1; |
| 3641 } | 3632 } |
| 3642 if (isinstance) { | 3633 if (isinstance) { |
| 3643 asdl_seq* body; | 3634 asdl_seq* body; |
| 3644 | 3635 |
| 3645 if (_PyObject_HasAttrId(obj, &PyId_body)) { | 3636 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
| 3646 int res; | 3637 int res; |
| 3647 Py_ssize_t len; | 3638 Py_ssize_t len; |
| 3648 Py_ssize_t i; | 3639 Py_ssize_t i; |
| 3649 tmp = _PyObject_GetAttrId(obj, &PyId_body); | 3640 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
| 3650 if (tmp == NULL) goto failed; | 3641 if (tmp == NULL) goto failed; |
| 3651 if (!PyList_Check(tmp)) { | 3642 if (!PyList_Check(tmp)) { |
| 3652 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 3643 PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 3653 goto failed; | 3644 goto failed; |
| 3654 } | 3645 } |
| 3655 len = PyList_GET_SIZE(tmp); | 3646 len = PyList_GET_SIZE(tmp); |
| 3656 body = asdl_seq_new(len, arena); | 3647 body = asdl_seq_new(len, arena); |
| 3657 if (body == NULL) goto failed; | 3648 if (body == NULL) goto failed; |
| 3658 for (i = 0; i < len; i++) { | 3649 for (i = 0; i < len; i++) { |
| 3659 stmt_ty value; | 3650 stmt_ty value; |
| 3660 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | 3651 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
| 3661 if (res != 0) goto failed; | 3652 if (res != 0) goto failed; |
| 3662 asdl_seq_SET(body, i, value); | 3653 asdl_seq_SET(body, i, value); |
| 3663 } | 3654 } |
| 3664 Py_XDECREF(tmp); | 3655 Py_XDECREF(tmp); |
| 3665 tmp = NULL; | 3656 tmp = NULL; |
| 3666 } else { | 3657 } else { |
| 3667 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive"); | 3658 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive"); |
| 3668 return 1; | 3659 return 1; |
| 3669 } | 3660 } |
| 3670 *out = Interactive(body, arena); | 3661 *out = Interactive(body, arena); |
| 3671 if (*out == NULL) goto failed; | 3662 if (*out == NULL) goto failed; |
| 3672 return 0; | 3663 return 0; |
| 3673 } | 3664 } |
| 3674 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); | 3665 isinstance = PyObject_IsInstance(obj, (PyObject*)Expression_type); |
| 3675 if (isinstance == -1) { | 3666 if (isinstance == -1) { |
| 3676 return 1; | 3667 return 1; |
| 3677 } | 3668 } |
| 3678 if (isinstance) { | 3669 if (isinstance) { |
| 3679 expr_ty body; | 3670 expr_ty body; |
| 3680 | 3671 |
| 3681 if (_PyObject_HasAttrId(obj, &PyId_body)) { | 3672 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
| 3682 int res; | 3673 int res; |
| 3683 tmp = _PyObject_GetAttrId(obj, &PyId_body); | 3674 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
| 3684 if (tmp == NULL) goto failed; | 3675 if (tmp == NULL) goto failed; |
| 3685 res = obj2ast_expr(tmp, &body, arena); | 3676 res = obj2ast_expr(tmp, &body, arena); |
| 3686 if (res != 0) goto failed; | 3677 if (res != 0) goto failed; |
| 3687 Py_XDECREF(tmp); | 3678 Py_XDECREF(tmp); |
| 3688 tmp = NULL; | 3679 tmp = NULL; |
| 3689 } else { | 3680 } else { |
| 3690 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression"); | 3681 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression"); |
| 3691 return 1; | 3682 return 1; |
| 3692 } | 3683 } |
| 3693 *out = Expression(body, arena); | 3684 *out = Expression(body, arena); |
| 3694 if (*out == NULL) goto failed; | 3685 if (*out == NULL) goto failed; |
| 3695 return 0; | 3686 return 0; |
| 3696 } | 3687 } |
| 3697 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); | 3688 isinstance = PyObject_IsInstance(obj, (PyObject*)Suite_type); |
| 3698 if (isinstance == -1) { | 3689 if (isinstance == -1) { |
| 3699 return 1; | 3690 return 1; |
| 3700 } | 3691 } |
| 3701 if (isinstance) { | 3692 if (isinstance) { |
| 3702 asdl_seq* body; | 3693 asdl_seq* body; |
| 3703 | 3694 |
| 3704 if (_PyObject_HasAttrId(obj, &PyId_body)) { | 3695 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
| 3705 int res; | 3696 int res; |
| 3706 Py_ssize_t len; | 3697 Py_ssize_t len; |
| 3707 Py_ssize_t i; | 3698 Py_ssize_t i; |
| 3708 tmp = _PyObject_GetAttrId(obj, &PyId_body); | 3699 tmp = _PyObject_GetAttrId(obj, &PyId_body); |
| 3709 if (tmp == NULL) goto failed; | 3700 if (tmp == NULL) goto failed; |
| 3710 if (!PyList_Check(tmp)) { | 3701 if (!PyList_Check(tmp)) { |
| 3711 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 3702 PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 3712 goto failed; | 3703 goto failed; |
| 3713 } | 3704 } |
| 3714 len = PyList_GET_SIZE(tmp); | 3705 len = PyList_GET_SIZE(tmp); |
| 3715 body = asdl_seq_new(len, arena); | 3706 body = asdl_seq_new(len, arena); |
| 3716 if (body == NULL) goto failed; | 3707 if (body == NULL) goto failed; |
| 3717 for (i = 0; i < len; i++) { | 3708 for (i = 0; i < len; i++) { |
| 3718 stmt_ty value; | 3709 stmt_ty value; |
| 3719 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | 3710 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); |
| 3720 if (res != 0) goto failed; | 3711 if (res != 0) goto failed; |
| 3721 asdl_seq_SET(body, i, value); | 3712 asdl_seq_SET(body, i, value); |
| 3722 } | 3713 } |
| 3723 Py_XDECREF(tmp); | 3714 Py_XDECREF(tmp); |
| 3724 tmp = NULL; | 3715 tmp = NULL; |
| 3725 } else { | 3716 } else { |
| 3726 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite"); | 3717 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite"); |
| 3727 return 1; | 3718 return 1; |
| 3728 } | 3719 } |
| 3729 *out = Suite(body, arena); | 3720 *out = Suite(body, arena); |
| 3730 if (*out == NULL) goto failed; | 3721 if (*out == NULL) goto failed; |
| 3731 return 0; | 3722 return 0; |
| 3732 } | 3723 } |
| 3733 | 3724 |
| 3734 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj); | 3725 PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj); |
| 3735 failed: | 3726 failed: |
| 3736 Py_XDECREF(tmp); | 3727 Py_XDECREF(tmp); |
| 3737 return 1; | 3728 return 1; |
| 3738 } | 3729 } |
| 3739 | 3730 |
| 3740 int | 3731 int |
| 3741 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) | 3732 obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena) |
| 3742 { | 3733 { |
| 3743 int isinstance; | 3734 int isinstance; |
| 3744 | 3735 |
| 3745 PyObject *tmp = NULL; | 3736 PyObject *tmp = NULL; |
| 3746 int lineno; | 3737 int lineno; |
| 3747 int col_offset; | 3738 int col_offset; |
| 3748 | 3739 |
| 3749 if (obj == Py_None) { | 3740 if (obj == Py_None) { |
| 3750 *out = NULL; | 3741 *out = NULL; |
| 3751 return 0; | 3742 return 0; |
| 3752 } | 3743 } |
| 3753 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { | 3744 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { |
| 3754 int res; | 3745 int res; |
| 3755 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); | 3746 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); |
| 3756 if (tmp == NULL) goto failed; | 3747 if (tmp == NULL) goto failed; |
| 3757 res = obj2ast_int(tmp, &lineno, arena); | 3748 res = obj2ast_int(tmp, &lineno, arena); |
| 3749 if (res != 0) goto failed; | |
| 3750 Py_XDECREF(tmp); | |
| 3751 tmp = NULL; | |
| 3752 } else { | |
| 3753 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt"); | |
| 3754 return 1; | |
| 3755 } | |
| 3756 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { | |
| 3757 int res; | |
| 3758 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); | |
| 3759 if (tmp == NULL) goto failed; | |
| 3760 res = obj2ast_int(tmp, &col_offset, arena); | |
| 3761 if (res != 0) goto failed; | |
| 3762 Py_XDECREF(tmp); | |
| 3763 tmp = NULL; | |
| 3764 } else { | |
| 3765 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); | |
| 3766 return 1; | |
| 3767 } | |
| 3768 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); | |
| 3769 if (isinstance == -1) { | |
| 3770 return 1; | |
| 3771 } | |
| 3772 if (isinstance) { | |
| 3773 identifier name; | |
| 3774 arguments_ty args; | |
| 3775 asdl_seq* body; | |
| 3776 asdl_seq* decorator_list; | |
| 3777 expr_ty returns; | |
| 3778 | |
| 3779 if (_PyObject_HasAttrId(obj, &PyId_name)) { | |
| 3780 int res; | |
| 3781 tmp = _PyObject_GetAttrId(obj, &PyId_name); | |
| 3782 if (tmp == NULL) goto failed; | |
| 3783 res = obj2ast_identifier(tmp, &name, arena); | |
| 3784 if (res != 0) goto failed; | |
| 3785 Py_XDECREF(tmp); | |
| 3786 tmp = NULL; | |
| 3787 } else { | |
| 3788 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef"); | |
| 3789 return 1; | |
| 3790 } | |
| 3791 if (_PyObject_HasAttrId(obj, &PyId_args)) { | |
| 3792 int res; | |
| 3793 tmp = _PyObject_GetAttrId(obj, &PyId_args); | |
| 3794 if (tmp == NULL) goto failed; | |
| 3795 res = obj2ast_arguments(tmp, &args, arena); | |
| 3796 if (res != 0) goto failed; | |
| 3797 Py_XDECREF(tmp); | |
| 3798 tmp = NULL; | |
| 3799 } else { | |
| 3800 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef"); | |
| 3801 return 1; | |
| 3802 } | |
| 3803 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 3804 int res; | |
| 3805 Py_ssize_t len; | |
| 3806 Py_ssize_t i; | |
| 3807 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 3808 if (tmp == NULL) goto failed; | |
| 3809 if (!PyList_Check(tmp)) { | |
| 3810 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3811 goto failed; | |
| 3812 } | |
| 3813 len = PyList_GET_SIZE(tmp); | |
| 3814 body = asdl_seq_new(len, arena); | |
| 3815 if (body == NULL) goto failed; | |
| 3816 for (i = 0; i < len; i++) { | |
| 3817 stmt_ty value; | |
| 3818 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3758 if (res != 0) goto failed; | 3819 if (res != 0) goto failed; |
| 3759 Py_XDECREF(tmp); | 3820 asdl_seq_SET(body, i, value); |
| 3760 tmp = NULL; | 3821 } |
| 3761 } else { | 3822 Py_XDECREF(tmp); |
| 3762 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt"); | 3823 tmp = NULL; |
| 3763 return 1; | 3824 } else { |
| 3764 } | 3825 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef"); |
| 3765 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { | 3826 return 1; |
| 3766 int res; | 3827 } |
| 3767 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); | 3828 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) { |
| 3768 if (tmp == NULL) goto failed; | 3829 int res; |
| 3769 res = obj2ast_int(tmp, &col_offset, arena); | 3830 Py_ssize_t len; |
| 3831 Py_ssize_t i; | |
| 3832 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); | |
| 3833 if (tmp == NULL) goto failed; | |
| 3834 if (!PyList_Check(tmp)) { | |
| 3835 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3836 goto failed; | |
| 3837 } | |
| 3838 len = PyList_GET_SIZE(tmp); | |
| 3839 decorator_list = asdl_seq_new(len, arena); | |
| 3840 if (decorator_list == NULL) goto failed; | |
| 3841 for (i = 0; i < len; i++) { | |
| 3842 expr_ty value; | |
| 3843 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3770 if (res != 0) goto failed; | 3844 if (res != 0) goto failed; |
| 3771 Py_XDECREF(tmp); | 3845 asdl_seq_SET(decorator_list, i, value); |
| 3772 tmp = NULL; | 3846 } |
| 3773 } else { | 3847 Py_XDECREF(tmp); |
| 3774 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt"); | 3848 tmp = NULL; |
| 3775 return 1; | 3849 } else { |
| 3776 } | 3850 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef"); |
| 3777 isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type); | 3851 return 1; |
| 3778 if (isinstance == -1) { | 3852 } |
| 3779 return 1; | 3853 if (exists_not_none(obj, &PyId_returns)) { |
| 3780 } | 3854 int res; |
| 3781 if (isinstance) { | 3855 tmp = _PyObject_GetAttrId(obj, &PyId_returns); |
| 3782 identifier name; | 3856 if (tmp == NULL) goto failed; |
| 3783 arguments_ty args; | 3857 res = obj2ast_expr(tmp, &returns, arena); |
| 3784 asdl_seq* body; | 3858 if (res != 0) goto failed; |
| 3785 asdl_seq* decorator_list; | 3859 Py_XDECREF(tmp); |
| 3786 expr_ty returns; | 3860 tmp = NULL; |
| 3787 | 3861 } else { |
| 3788 if (_PyObject_HasAttrId(obj, &PyId_name)) { | 3862 returns = NULL; |
| 3789 int res; | 3863 } |
| 3790 tmp = _PyObject_GetAttrId(obj, &PyId_name); | 3864 *out = FunctionDef(name, args, body, decorator_list, returns, lineno, |
| 3791 if (tmp == NULL) goto failed; | 3865 col_offset, arena); |
| 3792 res = obj2ast_identifier(tmp, &name, arena); | 3866 if (*out == NULL) goto failed; |
| 3793 if (res != 0) goto failed; | 3867 return 0; |
| 3794 Py_XDECREF(tmp); | 3868 } |
| 3795 tmp = NULL; | 3869 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); |
| 3796 } else { | 3870 if (isinstance == -1) { |
| 3797 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef"); | 3871 return 1; |
| 3798 return 1; | 3872 } |
| 3799 } | 3873 if (isinstance) { |
| 3800 if (_PyObject_HasAttrId(obj, &PyId_args)) { | 3874 identifier name; |
| 3801 int res; | 3875 asdl_seq* bases; |
| 3802 tmp = _PyObject_GetAttrId(obj, &PyId_args); | 3876 asdl_seq* keywords; |
| 3803 if (tmp == NULL) goto failed; | 3877 expr_ty starargs; |
| 3804 res = obj2ast_arguments(tmp, &args, arena); | 3878 expr_ty kwargs; |
| 3805 if (res != 0) goto failed; | 3879 asdl_seq* body; |
| 3806 Py_XDECREF(tmp); | 3880 asdl_seq* decorator_list; |
| 3807 tmp = NULL; | 3881 |
| 3808 } else { | 3882 if (_PyObject_HasAttrId(obj, &PyId_name)) { |
| 3809 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef"); | 3883 int res; |
| 3810 return 1; | 3884 tmp = _PyObject_GetAttrId(obj, &PyId_name); |
| 3811 } | 3885 if (tmp == NULL) goto failed; |
| 3812 if (_PyObject_HasAttrId(obj, &PyId_body)) { | 3886 res = obj2ast_identifier(tmp, &name, arena); |
| 3813 int res; | 3887 if (res != 0) goto failed; |
| 3814 Py_ssize_t len; | 3888 Py_XDECREF(tmp); |
| 3815 Py_ssize_t i; | 3889 tmp = NULL; |
| 3816 tmp = _PyObject_GetAttrId(obj, &PyId_body); | 3890 } else { |
| 3817 if (tmp == NULL) goto failed; | 3891 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef"); |
| 3818 if (!PyList_Check(tmp)) { | 3892 return 1; |
| 3819 PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 3893 } |
| 3820 goto failed; | 3894 if (_PyObject_HasAttrId(obj, &PyId_bases)) { |
| 3821 } | 3895 int res; |
| 3822 len = PyList_GET_SIZE(tmp); | 3896 Py_ssize_t len; |
| 3823 body = asdl_seq_new(len, arena); | 3897 Py_ssize_t i; |
| 3824 if (body == NULL) goto failed; | 3898 tmp = _PyObject_GetAttrId(obj, &PyId_bases); |
| 3825 for (i = 0; i < len; i++) { | 3899 if (tmp == NULL) goto failed; |
| 3826 stmt_ty value; | 3900 if (!PyList_Check(tmp)) { |
| 3827 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | 3901 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 3828 if (res != 0) goto failed; | 3902 goto failed; |
| 3829 asdl_seq_SET(body, i, value); | 3903 } |
| 3830 } | 3904 len = PyList_GET_SIZE(tmp); |
| 3831 Py_XDECREF(tmp); | 3905 bases = asdl_seq_new(len, arena); |
| 3832 tmp = NULL; | 3906 if (bases == NULL) goto failed; |
| 3833 } else { | 3907 for (i = 0; i < len; i++) { |
| 3834 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef"); | |
| 3835 return 1; | |
| 3836 } | |
| 3837 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) { | |
| 3838 int res; | |
| 3839 Py_ssize_t len; | |
| 3840 Py_ssize_t i; | |
| 3841 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); | |
| 3842 if (tmp == NULL) goto failed; | |
| 3843 if (!PyList_Check(tmp)) { | |
| 3844 PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3845 goto failed; | |
| 3846 } | |
| 3847 len = PyList_GET_SIZE(tmp); | |
| 3848 decorator_list = asdl_seq_new(len, arena); | |
| 3849 if (decorator_list == NULL) goto failed; | |
| 3850 for (i = 0; i < len; i++) { | |
| 3851 expr_ty value; | |
| 3852 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3853 if (res != 0) goto failed; | |
| 3854 asdl_seq_SET(decorator_list, i, value); | |
| 3855 } | |
| 3856 Py_XDECREF(tmp); | |
| 3857 tmp = NULL; | |
| 3858 } else { | |
| 3859 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef"); | |
| 3860 return 1; | |
| 3861 } | |
| 3862 if (exists_not_none(obj, &PyId_returns)) { | |
| 3863 int res; | |
| 3864 tmp = _PyObject_GetAttrId(obj, &PyId_returns); | |
| 3865 if (tmp == NULL) goto failed; | |
| 3866 res = obj2ast_expr(tmp, &returns, arena); | |
| 3867 if (res != 0) goto failed; | |
| 3868 Py_XDECREF(tmp); | |
| 3869 tmp = NULL; | |
| 3870 } else { | |
| 3871 returns = NULL; | |
| 3872 } | |
| 3873 *out = FunctionDef(name, args, body, decorator_list, returns, | |
| 3874 lineno, col_offset, arena); | |
| 3875 if (*out == NULL) goto failed; | |
| 3876 return 0; | |
| 3877 } | |
| 3878 isinstance = PyObject_IsInstance(obj, (PyObject*)ClassDef_type); | |
| 3879 if (isinstance == -1) { | |
| 3880 return 1; | |
| 3881 } | |
| 3882 if (isinstance) { | |
| 3883 identifier name; | |
| 3884 asdl_seq* bases; | |
| 3885 asdl_seq* keywords; | |
| 3886 expr_ty starargs; | |
| 3887 expr_ty kwargs; | |
| 3888 asdl_seq* body; | |
| 3889 asdl_seq* decorator_list; | |
| 3890 | |
| 3891 if (_PyObject_HasAttrId(obj, &PyId_name)) { | |
| 3892 int res; | |
| 3893 tmp = _PyObject_GetAttrId(obj, &PyId_name); | |
| 3894 if (tmp == NULL) goto failed; | |
| 3895 res = obj2ast_identifier(tmp, &name, arena); | |
| 3896 if (res != 0) goto failed; | |
| 3897 Py_XDECREF(tmp); | |
| 3898 tmp = NULL; | |
| 3899 } else { | |
| 3900 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef"); | |
| 3901 return 1; | |
| 3902 } | |
| 3903 if (_PyObject_HasAttrId(obj, &PyId_bases)) { | |
| 3904 int res; | |
| 3905 Py_ssize_t len; | |
| 3906 Py_ssize_t i; | |
| 3907 tmp = _PyObject_GetAttrId(obj, &PyId_bases); | |
| 3908 if (tmp == NULL) goto failed; | |
| 3909 if (!PyList_Check(tmp)) { | |
| 3910 PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3911 goto failed; | |
| 3912 } | |
| 3913 len = PyList_GET_SIZE(tmp); | |
| 3914 bases = asdl_seq_new(len, arena); | |
| 3915 if (bases == NULL) goto failed; | |
| 3916 for (i = 0; i < len; i++) { | |
| 3917 expr_ty value; | |
| 3918 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3919 if (res != 0) goto failed; | |
| 3920 asdl_seq_SET(bases, i, value); | |
| 3921 } | |
| 3922 Py_XDECREF(tmp); | |
| 3923 tmp = NULL; | |
| 3924 } else { | |
| 3925 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef"); | |
| 3926 return 1; | |
| 3927 } | |
| 3928 if (_PyObject_HasAttrId(obj, &PyId_keywords)) { | |
| 3929 int res; | |
| 3930 Py_ssize_t len; | |
| 3931 Py_ssize_t i; | |
| 3932 tmp = _PyObject_GetAttrId(obj, &PyId_keywords); | |
| 3933 if (tmp == NULL) goto failed; | |
| 3934 if (!PyList_Check(tmp)) { | |
| 3935 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3936 goto failed; | |
| 3937 } | |
| 3938 len = PyList_GET_SIZE(tmp); | |
| 3939 keywords = asdl_seq_new(len, arena); | |
| 3940 if (keywords == NULL) goto failed; | |
| 3941 for (i = 0; i < len; i++) { | |
| 3942 keyword_ty value; | |
| 3943 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3944 if (res != 0) goto failed; | |
| 3945 asdl_seq_SET(keywords, i, value); | |
| 3946 } | |
| 3947 Py_XDECREF(tmp); | |
| 3948 tmp = NULL; | |
| 3949 } else { | |
| 3950 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef"); | |
| 3951 return 1; | |
| 3952 } | |
| 3953 if (exists_not_none(obj, &PyId_starargs)) { | |
| 3954 int res; | |
| 3955 tmp = _PyObject_GetAttrId(obj, &PyId_starargs); | |
| 3956 if (tmp == NULL) goto failed; | |
| 3957 res = obj2ast_expr(tmp, &starargs, arena); | |
| 3958 if (res != 0) goto failed; | |
| 3959 Py_XDECREF(tmp); | |
| 3960 tmp = NULL; | |
| 3961 } else { | |
| 3962 starargs = NULL; | |
| 3963 } | |
| 3964 if (exists_not_none(obj, &PyId_kwargs)) { | |
| 3965 int res; | |
| 3966 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs); | |
| 3967 if (tmp == NULL) goto failed; | |
| 3968 res = obj2ast_expr(tmp, &kwargs, arena); | |
| 3969 if (res != 0) goto failed; | |
| 3970 Py_XDECREF(tmp); | |
| 3971 tmp = NULL; | |
| 3972 } else { | |
| 3973 kwargs = NULL; | |
| 3974 } | |
| 3975 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 3976 int res; | |
| 3977 Py_ssize_t len; | |
| 3978 Py_ssize_t i; | |
| 3979 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 3980 if (tmp == NULL) goto failed; | |
| 3981 if (!PyList_Check(tmp)) { | |
| 3982 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3983 goto failed; | |
| 3984 } | |
| 3985 len = PyList_GET_SIZE(tmp); | |
| 3986 body = asdl_seq_new(len, arena); | |
| 3987 if (body == NULL) goto failed; | |
| 3988 for (i = 0; i < len; i++) { | |
| 3989 stmt_ty value; | |
| 3990 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3991 if (res != 0) goto failed; | |
| 3992 asdl_seq_SET(body, i, value); | |
| 3993 } | |
| 3994 Py_XDECREF(tmp); | |
| 3995 tmp = NULL; | |
| 3996 } else { | |
| 3997 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef"); | |
| 3998 return 1; | |
| 3999 } | |
| 4000 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) { | |
| 4001 int res; | |
| 4002 Py_ssize_t len; | |
| 4003 Py_ssize_t i; | |
| 4004 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); | |
| 4005 if (tmp == NULL) goto failed; | |
| 4006 if (!PyList_Check(tmp)) { | |
| 4007 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4008 goto failed; | |
| 4009 } | |
| 4010 len = PyList_GET_SIZE(tmp); | |
| 4011 decorator_list = asdl_seq_new(len, arena); | |
| 4012 if (decorator_list == NULL) goto failed; | |
| 4013 for (i = 0; i < len; i++) { | |
| 4014 expr_ty value; | |
| 4015 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4016 if (res != 0) goto failed; | |
| 4017 asdl_seq_SET(decorator_list, i, value); | |
| 4018 } | |
| 4019 Py_XDECREF(tmp); | |
| 4020 tmp = NULL; | |
| 4021 } else { | |
| 4022 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef"); | |
| 4023 return 1; | |
| 4024 } | |
| 4025 *out = ClassDef(name, bases, keywords, starargs, kwargs, body, | |
| 4026 decorator_list, lineno, col_offset, arena); | |
| 4027 if (*out == NULL) goto failed; | |
| 4028 return 0; | |
| 4029 } | |
| 4030 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); | |
| 4031 if (isinstance == -1) { | |
| 4032 return 1; | |
| 4033 } | |
| 4034 if (isinstance) { | |
| 4035 expr_ty value; | 3908 expr_ty value; |
| 4036 | 3909 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 4037 if (exists_not_none(obj, &PyId_value)) { | 3910 if (res != 0) goto failed; |
| 4038 int res; | 3911 asdl_seq_SET(bases, i, value); |
| 4039 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 3912 } |
| 4040 if (tmp == NULL) goto failed; | 3913 Py_XDECREF(tmp); |
| 4041 res = obj2ast_expr(tmp, &value, arena); | 3914 tmp = NULL; |
| 4042 if (res != 0) goto failed; | 3915 } else { |
| 4043 Py_XDECREF(tmp); | 3916 PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef"); |
| 4044 tmp = NULL; | 3917 return 1; |
| 4045 } else { | 3918 } |
| 4046 value = NULL; | 3919 if (_PyObject_HasAttrId(obj, &PyId_keywords)) { |
| 4047 } | 3920 int res; |
| 4048 *out = Return(value, lineno, col_offset, arena); | 3921 Py_ssize_t len; |
| 4049 if (*out == NULL) goto failed; | 3922 Py_ssize_t i; |
| 4050 return 0; | 3923 tmp = _PyObject_GetAttrId(obj, &PyId_keywords); |
| 4051 } | 3924 if (tmp == NULL) goto failed; |
| 4052 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); | 3925 if (!PyList_Check(tmp)) { |
| 4053 if (isinstance == -1) { | 3926 PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 4054 return 1; | 3927 goto failed; |
| 4055 } | 3928 } |
| 4056 if (isinstance) { | 3929 len = PyList_GET_SIZE(tmp); |
| 4057 asdl_seq* targets; | 3930 keywords = asdl_seq_new(len, arena); |
| 4058 | 3931 if (keywords == NULL) goto failed; |
| 4059 if (_PyObject_HasAttrId(obj, &PyId_targets)) { | 3932 for (i = 0; i < len; i++) { |
| 4060 int res; | 3933 keyword_ty value; |
| 4061 Py_ssize_t len; | 3934 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); |
| 4062 Py_ssize_t i; | 3935 if (res != 0) goto failed; |
| 4063 tmp = _PyObject_GetAttrId(obj, &PyId_targets); | 3936 asdl_seq_SET(keywords, i, value); |
| 4064 if (tmp == NULL) goto failed; | 3937 } |
| 4065 if (!PyList_Check(tmp)) { | 3938 Py_XDECREF(tmp); |
| 4066 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 3939 tmp = NULL; |
| 4067 goto failed; | 3940 } else { |
| 4068 } | 3941 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef"); |
| 4069 len = PyList_GET_SIZE(tmp); | 3942 return 1; |
| 4070 targets = asdl_seq_new(len, arena); | 3943 } |
| 4071 if (targets == NULL) goto failed; | 3944 if (exists_not_none(obj, &PyId_starargs)) { |
| 4072 for (i = 0; i < len; i++) { | 3945 int res; |
| 4073 expr_ty value; | 3946 tmp = _PyObject_GetAttrId(obj, &PyId_starargs); |
| 4074 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | 3947 if (tmp == NULL) goto failed; |
| 4075 if (res != 0) goto failed; | 3948 res = obj2ast_expr(tmp, &starargs, arena); |
| 4076 asdl_seq_SET(targets, i, value); | 3949 if (res != 0) goto failed; |
| 4077 } | 3950 Py_XDECREF(tmp); |
| 4078 Py_XDECREF(tmp); | 3951 tmp = NULL; |
| 4079 tmp = NULL; | 3952 } else { |
| 4080 } else { | 3953 starargs = NULL; |
| 4081 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete"); | 3954 } |
| 4082 return 1; | 3955 if (exists_not_none(obj, &PyId_kwargs)) { |
| 4083 } | 3956 int res; |
| 4084 *out = Delete(targets, lineno, col_offset, arena); | 3957 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs); |
| 4085 if (*out == NULL) goto failed; | 3958 if (tmp == NULL) goto failed; |
| 4086 return 0; | 3959 res = obj2ast_expr(tmp, &kwargs, arena); |
| 4087 } | 3960 if (res != 0) goto failed; |
| 4088 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); | 3961 Py_XDECREF(tmp); |
| 4089 if (isinstance == -1) { | 3962 tmp = NULL; |
| 4090 return 1; | 3963 } else { |
| 4091 } | 3964 kwargs = NULL; |
| 4092 if (isinstance) { | 3965 } |
| 4093 asdl_seq* targets; | 3966 if (_PyObject_HasAttrId(obj, &PyId_body)) { |
| 3967 int res; | |
| 3968 Py_ssize_t len; | |
| 3969 Py_ssize_t i; | |
| 3970 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 3971 if (tmp == NULL) goto failed; | |
| 3972 if (!PyList_Check(tmp)) { | |
| 3973 PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3974 goto failed; | |
| 3975 } | |
| 3976 len = PyList_GET_SIZE(tmp); | |
| 3977 body = asdl_seq_new(len, arena); | |
| 3978 if (body == NULL) goto failed; | |
| 3979 for (i = 0; i < len; i++) { | |
| 3980 stmt_ty value; | |
| 3981 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 3982 if (res != 0) goto failed; | |
| 3983 asdl_seq_SET(body, i, value); | |
| 3984 } | |
| 3985 Py_XDECREF(tmp); | |
| 3986 tmp = NULL; | |
| 3987 } else { | |
| 3988 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef"); | |
| 3989 return 1; | |
| 3990 } | |
| 3991 if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) { | |
| 3992 int res; | |
| 3993 Py_ssize_t len; | |
| 3994 Py_ssize_t i; | |
| 3995 tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); | |
| 3996 if (tmp == NULL) goto failed; | |
| 3997 if (!PyList_Check(tmp)) { | |
| 3998 PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 3999 goto failed; | |
| 4000 } | |
| 4001 len = PyList_GET_SIZE(tmp); | |
| 4002 decorator_list = asdl_seq_new(len, arena); | |
| 4003 if (decorator_list == NULL) goto failed; | |
| 4004 for (i = 0; i < len; i++) { | |
| 4094 expr_ty value; | 4005 expr_ty value; |
| 4095 | 4006 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 4096 if (_PyObject_HasAttrId(obj, &PyId_targets)) { | 4007 if (res != 0) goto failed; |
| 4097 int res; | 4008 asdl_seq_SET(decorator_list, i, value); |
| 4098 Py_ssize_t len; | 4009 } |
| 4099 Py_ssize_t i; | 4010 Py_XDECREF(tmp); |
| 4100 tmp = _PyObject_GetAttrId(obj, &PyId_targets); | 4011 tmp = NULL; |
| 4101 if (tmp == NULL) goto failed; | 4012 } else { |
| 4102 if (!PyList_Check(tmp)) { | 4013 PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef"); |
| 4103 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 4014 return 1; |
| 4104 goto failed; | 4015 } |
| 4105 } | 4016 *out = ClassDef(name, bases, keywords, starargs, kwargs, body, |
| 4106 len = PyList_GET_SIZE(tmp); | 4017 decorator_list, lineno, col_offset, arena); |
| 4107 targets = asdl_seq_new(len, arena); | 4018 if (*out == NULL) goto failed; |
| 4108 if (targets == NULL) goto failed; | 4019 return 0; |
| 4109 for (i = 0; i < len; i++) { | 4020 } |
| 4110 expr_ty value; | 4021 isinstance = PyObject_IsInstance(obj, (PyObject*)Return_type); |
| 4111 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | 4022 if (isinstance == -1) { |
| 4112 if (res != 0) goto failed; | 4023 return 1; |
| 4113 asdl_seq_SET(targets, i, value); | 4024 } |
| 4114 } | 4025 if (isinstance) { |
| 4115 Py_XDECREF(tmp); | 4026 expr_ty value; |
| 4116 tmp = NULL; | 4027 |
| 4117 } else { | 4028 if (exists_not_none(obj, &PyId_value)) { |
| 4118 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign"); | 4029 int res; |
| 4119 return 1; | 4030 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
| 4120 } | 4031 if (tmp == NULL) goto failed; |
| 4121 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 4032 res = obj2ast_expr(tmp, &value, arena); |
| 4122 int res; | 4033 if (res != 0) goto failed; |
| 4123 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 4034 Py_XDECREF(tmp); |
| 4124 if (tmp == NULL) goto failed; | 4035 tmp = NULL; |
| 4125 res = obj2ast_expr(tmp, &value, arena); | 4036 } else { |
| 4126 if (res != 0) goto failed; | 4037 value = NULL; |
| 4127 Py_XDECREF(tmp); | 4038 } |
| 4128 tmp = NULL; | 4039 *out = Return(value, lineno, col_offset, arena); |
| 4129 } else { | 4040 if (*out == NULL) goto failed; |
| 4130 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign"); | 4041 return 0; |
| 4131 return 1; | 4042 } |
| 4132 } | 4043 isinstance = PyObject_IsInstance(obj, (PyObject*)Delete_type); |
| 4133 *out = Assign(targets, value, lineno, col_offset, arena); | 4044 if (isinstance == -1) { |
| 4134 if (*out == NULL) goto failed; | 4045 return 1; |
| 4135 return 0; | 4046 } |
| 4136 } | 4047 if (isinstance) { |
| 4137 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); | 4048 asdl_seq* targets; |
| 4138 if (isinstance == -1) { | 4049 |
| 4139 return 1; | 4050 if (_PyObject_HasAttrId(obj, &PyId_targets)) { |
| 4140 } | 4051 int res; |
| 4141 if (isinstance) { | 4052 Py_ssize_t len; |
| 4142 expr_ty target; | 4053 Py_ssize_t i; |
| 4143 operator_ty op; | 4054 tmp = _PyObject_GetAttrId(obj, &PyId_targets); |
| 4055 if (tmp == NULL) goto failed; | |
| 4056 if (!PyList_Check(tmp)) { | |
| 4057 PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4058 goto failed; | |
| 4059 } | |
| 4060 len = PyList_GET_SIZE(tmp); | |
| 4061 targets = asdl_seq_new(len, arena); | |
| 4062 if (targets == NULL) goto failed; | |
| 4063 for (i = 0; i < len; i++) { | |
| 4144 expr_ty value; | 4064 expr_ty value; |
| 4145 | 4065 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 4146 if (_PyObject_HasAttrId(obj, &PyId_target)) { | 4066 if (res != 0) goto failed; |
| 4147 int res; | 4067 asdl_seq_SET(targets, i, value); |
| 4148 tmp = _PyObject_GetAttrId(obj, &PyId_target); | 4068 } |
| 4149 if (tmp == NULL) goto failed; | 4069 Py_XDECREF(tmp); |
| 4150 res = obj2ast_expr(tmp, &target, arena); | 4070 tmp = NULL; |
| 4151 if (res != 0) goto failed; | 4071 } else { |
| 4152 Py_XDECREF(tmp); | 4072 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete"); |
| 4153 tmp = NULL; | 4073 return 1; |
| 4154 } else { | 4074 } |
| 4155 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign"); | 4075 *out = Delete(targets, lineno, col_offset, arena); |
| 4156 return 1; | 4076 if (*out == NULL) goto failed; |
| 4157 } | 4077 return 0; |
| 4158 if (_PyObject_HasAttrId(obj, &PyId_op)) { | 4078 } |
| 4159 int res; | 4079 isinstance = PyObject_IsInstance(obj, (PyObject*)Assign_type); |
| 4160 tmp = _PyObject_GetAttrId(obj, &PyId_op); | 4080 if (isinstance == -1) { |
| 4161 if (tmp == NULL) goto failed; | 4081 return 1; |
| 4162 res = obj2ast_operator(tmp, &op, arena); | 4082 } |
| 4163 if (res != 0) goto failed; | 4083 if (isinstance) { |
| 4164 Py_XDECREF(tmp); | 4084 asdl_seq* targets; |
| 4165 tmp = NULL; | 4085 expr_ty value; |
| 4166 } else { | 4086 |
| 4167 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); | 4087 if (_PyObject_HasAttrId(obj, &PyId_targets)) { |
| 4168 return 1; | 4088 int res; |
| 4169 } | 4089 Py_ssize_t len; |
| 4170 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 4090 Py_ssize_t i; |
| 4171 int res; | 4091 tmp = _PyObject_GetAttrId(obj, &PyId_targets); |
| 4172 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 4092 if (tmp == NULL) goto failed; |
| 4173 if (tmp == NULL) goto failed; | 4093 if (!PyList_Check(tmp)) { |
| 4174 res = obj2ast_expr(tmp, &value, arena); | 4094 PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 4175 if (res != 0) goto failed; | 4095 goto failed; |
| 4176 Py_XDECREF(tmp); | 4096 } |
| 4177 tmp = NULL; | 4097 len = PyList_GET_SIZE(tmp); |
| 4178 } else { | 4098 targets = asdl_seq_new(len, arena); |
| 4179 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign"); | 4099 if (targets == NULL) goto failed; |
| 4180 return 1; | 4100 for (i = 0; i < len; i++) { |
| 4181 } | |
| 4182 *out = AugAssign(target, op, value, lineno, col_offset, arena); | |
| 4183 if (*out == NULL) goto failed; | |
| 4184 return 0; | |
| 4185 } | |
| 4186 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); | |
| 4187 if (isinstance == -1) { | |
| 4188 return 1; | |
| 4189 } | |
| 4190 if (isinstance) { | |
| 4191 expr_ty target; | |
| 4192 expr_ty iter; | |
| 4193 asdl_seq* body; | |
| 4194 asdl_seq* orelse; | |
| 4195 | |
| 4196 if (_PyObject_HasAttrId(obj, &PyId_target)) { | |
| 4197 int res; | |
| 4198 tmp = _PyObject_GetAttrId(obj, &PyId_target); | |
| 4199 if (tmp == NULL) goto failed; | |
| 4200 res = obj2ast_expr(tmp, &target, arena); | |
| 4201 if (res != 0) goto failed; | |
| 4202 Py_XDECREF(tmp); | |
| 4203 tmp = NULL; | |
| 4204 } else { | |
| 4205 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For"); | |
| 4206 return 1; | |
| 4207 } | |
| 4208 if (_PyObject_HasAttrId(obj, &PyId_iter)) { | |
| 4209 int res; | |
| 4210 tmp = _PyObject_GetAttrId(obj, &PyId_iter); | |
| 4211 if (tmp == NULL) goto failed; | |
| 4212 res = obj2ast_expr(tmp, &iter, arena); | |
| 4213 if (res != 0) goto failed; | |
| 4214 Py_XDECREF(tmp); | |
| 4215 tmp = NULL; | |
| 4216 } else { | |
| 4217 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For"); | |
| 4218 return 1; | |
| 4219 } | |
| 4220 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4221 int res; | |
| 4222 Py_ssize_t len; | |
| 4223 Py_ssize_t i; | |
| 4224 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4225 if (tmp == NULL) goto failed; | |
| 4226 if (!PyList_Check(tmp)) { | |
| 4227 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4228 goto failed; | |
| 4229 } | |
| 4230 len = PyList_GET_SIZE(tmp); | |
| 4231 body = asdl_seq_new(len, arena); | |
| 4232 if (body == NULL) goto failed; | |
| 4233 for (i = 0; i < len; i++) { | |
| 4234 stmt_ty value; | |
| 4235 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4236 if (res != 0) goto failed; | |
| 4237 asdl_seq_SET(body, i, value); | |
| 4238 } | |
| 4239 Py_XDECREF(tmp); | |
| 4240 tmp = NULL; | |
| 4241 } else { | |
| 4242 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For"); | |
| 4243 return 1; | |
| 4244 } | |
| 4245 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4246 int res; | |
| 4247 Py_ssize_t len; | |
| 4248 Py_ssize_t i; | |
| 4249 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4250 if (tmp == NULL) goto failed; | |
| 4251 if (!PyList_Check(tmp)) { | |
| 4252 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4253 goto failed; | |
| 4254 } | |
| 4255 len = PyList_GET_SIZE(tmp); | |
| 4256 orelse = asdl_seq_new(len, arena); | |
| 4257 if (orelse == NULL) goto failed; | |
| 4258 for (i = 0; i < len; i++) { | |
| 4259 stmt_ty value; | |
| 4260 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4261 if (res != 0) goto failed; | |
| 4262 asdl_seq_SET(orelse, i, value); | |
| 4263 } | |
| 4264 Py_XDECREF(tmp); | |
| 4265 tmp = NULL; | |
| 4266 } else { | |
| 4267 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For"); | |
| 4268 return 1; | |
| 4269 } | |
| 4270 *out = For(target, iter, body, orelse, lineno, col_offset, | |
| 4271 arena); | |
| 4272 if (*out == NULL) goto failed; | |
| 4273 return 0; | |
| 4274 } | |
| 4275 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); | |
| 4276 if (isinstance == -1) { | |
| 4277 return 1; | |
| 4278 } | |
| 4279 if (isinstance) { | |
| 4280 expr_ty test; | |
| 4281 asdl_seq* body; | |
| 4282 asdl_seq* orelse; | |
| 4283 | |
| 4284 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 4285 int res; | |
| 4286 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 4287 if (tmp == NULL) goto failed; | |
| 4288 res = obj2ast_expr(tmp, &test, arena); | |
| 4289 if (res != 0) goto failed; | |
| 4290 Py_XDECREF(tmp); | |
| 4291 tmp = NULL; | |
| 4292 } else { | |
| 4293 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While"); | |
| 4294 return 1; | |
| 4295 } | |
| 4296 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4297 int res; | |
| 4298 Py_ssize_t len; | |
| 4299 Py_ssize_t i; | |
| 4300 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4301 if (tmp == NULL) goto failed; | |
| 4302 if (!PyList_Check(tmp)) { | |
| 4303 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4304 goto failed; | |
| 4305 } | |
| 4306 len = PyList_GET_SIZE(tmp); | |
| 4307 body = asdl_seq_new(len, arena); | |
| 4308 if (body == NULL) goto failed; | |
| 4309 for (i = 0; i < len; i++) { | |
| 4310 stmt_ty value; | |
| 4311 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4312 if (res != 0) goto failed; | |
| 4313 asdl_seq_SET(body, i, value); | |
| 4314 } | |
| 4315 Py_XDECREF(tmp); | |
| 4316 tmp = NULL; | |
| 4317 } else { | |
| 4318 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While"); | |
| 4319 return 1; | |
| 4320 } | |
| 4321 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4322 int res; | |
| 4323 Py_ssize_t len; | |
| 4324 Py_ssize_t i; | |
| 4325 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4326 if (tmp == NULL) goto failed; | |
| 4327 if (!PyList_Check(tmp)) { | |
| 4328 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4329 goto failed; | |
| 4330 } | |
| 4331 len = PyList_GET_SIZE(tmp); | |
| 4332 orelse = asdl_seq_new(len, arena); | |
| 4333 if (orelse == NULL) goto failed; | |
| 4334 for (i = 0; i < len; i++) { | |
| 4335 stmt_ty value; | |
| 4336 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4337 if (res != 0) goto failed; | |
| 4338 asdl_seq_SET(orelse, i, value); | |
| 4339 } | |
| 4340 Py_XDECREF(tmp); | |
| 4341 tmp = NULL; | |
| 4342 } else { | |
| 4343 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While"); | |
| 4344 return 1; | |
| 4345 } | |
| 4346 *out = While(test, body, orelse, lineno, col_offset, arena); | |
| 4347 if (*out == NULL) goto failed; | |
| 4348 return 0; | |
| 4349 } | |
| 4350 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); | |
| 4351 if (isinstance == -1) { | |
| 4352 return 1; | |
| 4353 } | |
| 4354 if (isinstance) { | |
| 4355 expr_ty test; | |
| 4356 asdl_seq* body; | |
| 4357 asdl_seq* orelse; | |
| 4358 | |
| 4359 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 4360 int res; | |
| 4361 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 4362 if (tmp == NULL) goto failed; | |
| 4363 res = obj2ast_expr(tmp, &test, arena); | |
| 4364 if (res != 0) goto failed; | |
| 4365 Py_XDECREF(tmp); | |
| 4366 tmp = NULL; | |
| 4367 } else { | |
| 4368 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If"); | |
| 4369 return 1; | |
| 4370 } | |
| 4371 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4372 int res; | |
| 4373 Py_ssize_t len; | |
| 4374 Py_ssize_t i; | |
| 4375 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4376 if (tmp == NULL) goto failed; | |
| 4377 if (!PyList_Check(tmp)) { | |
| 4378 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4379 goto failed; | |
| 4380 } | |
| 4381 len = PyList_GET_SIZE(tmp); | |
| 4382 body = asdl_seq_new(len, arena); | |
| 4383 if (body == NULL) goto failed; | |
| 4384 for (i = 0; i < len; i++) { | |
| 4385 stmt_ty value; | |
| 4386 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4387 if (res != 0) goto failed; | |
| 4388 asdl_seq_SET(body, i, value); | |
| 4389 } | |
| 4390 Py_XDECREF(tmp); | |
| 4391 tmp = NULL; | |
| 4392 } else { | |
| 4393 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If"); | |
| 4394 return 1; | |
| 4395 } | |
| 4396 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4397 int res; | |
| 4398 Py_ssize_t len; | |
| 4399 Py_ssize_t i; | |
| 4400 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4401 if (tmp == NULL) goto failed; | |
| 4402 if (!PyList_Check(tmp)) { | |
| 4403 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4404 goto failed; | |
| 4405 } | |
| 4406 len = PyList_GET_SIZE(tmp); | |
| 4407 orelse = asdl_seq_new(len, arena); | |
| 4408 if (orelse == NULL) goto failed; | |
| 4409 for (i = 0; i < len; i++) { | |
| 4410 stmt_ty value; | |
| 4411 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4412 if (res != 0) goto failed; | |
| 4413 asdl_seq_SET(orelse, i, value); | |
| 4414 } | |
| 4415 Py_XDECREF(tmp); | |
| 4416 tmp = NULL; | |
| 4417 } else { | |
| 4418 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If"); | |
| 4419 return 1; | |
| 4420 } | |
| 4421 *out = If(test, body, orelse, lineno, col_offset, arena); | |
| 4422 if (*out == NULL) goto failed; | |
| 4423 return 0; | |
| 4424 } | |
| 4425 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); | |
| 4426 if (isinstance == -1) { | |
| 4427 return 1; | |
| 4428 } | |
| 4429 if (isinstance) { | |
| 4430 asdl_seq* items; | |
| 4431 asdl_seq* body; | |
| 4432 | |
| 4433 if (_PyObject_HasAttrId(obj, &PyId_items)) { | |
| 4434 int res; | |
| 4435 Py_ssize_t len; | |
| 4436 Py_ssize_t i; | |
| 4437 tmp = _PyObject_GetAttrId(obj, &PyId_items); | |
| 4438 if (tmp == NULL) goto failed; | |
| 4439 if (!PyList_Check(tmp)) { | |
| 4440 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4441 goto failed; | |
| 4442 } | |
| 4443 len = PyList_GET_SIZE(tmp); | |
| 4444 items = asdl_seq_new(len, arena); | |
| 4445 if (items == NULL) goto failed; | |
| 4446 for (i = 0; i < len; i++) { | |
| 4447 withitem_ty value; | |
| 4448 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4449 if (res != 0) goto failed; | |
| 4450 asdl_seq_SET(items, i, value); | |
| 4451 } | |
| 4452 Py_XDECREF(tmp); | |
| 4453 tmp = NULL; | |
| 4454 } else { | |
| 4455 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With"); | |
| 4456 return 1; | |
| 4457 } | |
| 4458 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4459 int res; | |
| 4460 Py_ssize_t len; | |
| 4461 Py_ssize_t i; | |
| 4462 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4463 if (tmp == NULL) goto failed; | |
| 4464 if (!PyList_Check(tmp)) { | |
| 4465 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4466 goto failed; | |
| 4467 } | |
| 4468 len = PyList_GET_SIZE(tmp); | |
| 4469 body = asdl_seq_new(len, arena); | |
| 4470 if (body == NULL) goto failed; | |
| 4471 for (i = 0; i < len; i++) { | |
| 4472 stmt_ty value; | |
| 4473 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4474 if (res != 0) goto failed; | |
| 4475 asdl_seq_SET(body, i, value); | |
| 4476 } | |
| 4477 Py_XDECREF(tmp); | |
| 4478 tmp = NULL; | |
| 4479 } else { | |
| 4480 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With"); | |
| 4481 return 1; | |
| 4482 } | |
| 4483 *out = With(items, body, lineno, col_offset, arena); | |
| 4484 if (*out == NULL) goto failed; | |
| 4485 return 0; | |
| 4486 } | |
| 4487 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); | |
| 4488 if (isinstance == -1) { | |
| 4489 return 1; | |
| 4490 } | |
| 4491 if (isinstance) { | |
| 4492 expr_ty exc; | |
| 4493 expr_ty cause; | |
| 4494 | |
| 4495 if (exists_not_none(obj, &PyId_exc)) { | |
| 4496 int res; | |
| 4497 tmp = _PyObject_GetAttrId(obj, &PyId_exc); | |
| 4498 if (tmp == NULL) goto failed; | |
| 4499 res = obj2ast_expr(tmp, &exc, arena); | |
| 4500 if (res != 0) goto failed; | |
| 4501 Py_XDECREF(tmp); | |
| 4502 tmp = NULL; | |
| 4503 } else { | |
| 4504 exc = NULL; | |
| 4505 } | |
| 4506 if (exists_not_none(obj, &PyId_cause)) { | |
| 4507 int res; | |
| 4508 tmp = _PyObject_GetAttrId(obj, &PyId_cause); | |
| 4509 if (tmp == NULL) goto failed; | |
| 4510 res = obj2ast_expr(tmp, &cause, arena); | |
| 4511 if (res != 0) goto failed; | |
| 4512 Py_XDECREF(tmp); | |
| 4513 tmp = NULL; | |
| 4514 } else { | |
| 4515 cause = NULL; | |
| 4516 } | |
| 4517 *out = Raise(exc, cause, lineno, col_offset, arena); | |
| 4518 if (*out == NULL) goto failed; | |
| 4519 return 0; | |
| 4520 } | |
| 4521 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type); | |
| 4522 if (isinstance == -1) { | |
| 4523 return 1; | |
| 4524 } | |
| 4525 if (isinstance) { | |
| 4526 asdl_seq* body; | |
| 4527 asdl_seq* handlers; | |
| 4528 asdl_seq* orelse; | |
| 4529 asdl_seq* finalbody; | |
| 4530 | |
| 4531 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4532 int res; | |
| 4533 Py_ssize_t len; | |
| 4534 Py_ssize_t i; | |
| 4535 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4536 if (tmp == NULL) goto failed; | |
| 4537 if (!PyList_Check(tmp)) { | |
| 4538 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4539 goto failed; | |
| 4540 } | |
| 4541 len = PyList_GET_SIZE(tmp); | |
| 4542 body = asdl_seq_new(len, arena); | |
| 4543 if (body == NULL) goto failed; | |
| 4544 for (i = 0; i < len; i++) { | |
| 4545 stmt_ty value; | |
| 4546 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4547 if (res != 0) goto failed; | |
| 4548 asdl_seq_SET(body, i, value); | |
| 4549 } | |
| 4550 Py_XDECREF(tmp); | |
| 4551 tmp = NULL; | |
| 4552 } else { | |
| 4553 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try"); | |
| 4554 return 1; | |
| 4555 } | |
| 4556 if (_PyObject_HasAttrId(obj, &PyId_handlers)) { | |
| 4557 int res; | |
| 4558 Py_ssize_t len; | |
| 4559 Py_ssize_t i; | |
| 4560 tmp = _PyObject_GetAttrId(obj, &PyId_handlers); | |
| 4561 if (tmp == NULL) goto failed; | |
| 4562 if (!PyList_Check(tmp)) { | |
| 4563 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4564 goto failed; | |
| 4565 } | |
| 4566 len = PyList_GET_SIZE(tmp); | |
| 4567 handlers = asdl_seq_new(len, arena); | |
| 4568 if (handlers == NULL) goto failed; | |
| 4569 for (i = 0; i < len; i++) { | |
| 4570 excepthandler_ty value; | |
| 4571 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4572 if (res != 0) goto failed; | |
| 4573 asdl_seq_SET(handlers, i, value); | |
| 4574 } | |
| 4575 Py_XDECREF(tmp); | |
| 4576 tmp = NULL; | |
| 4577 } else { | |
| 4578 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try"); | |
| 4579 return 1; | |
| 4580 } | |
| 4581 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4582 int res; | |
| 4583 Py_ssize_t len; | |
| 4584 Py_ssize_t i; | |
| 4585 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4586 if (tmp == NULL) goto failed; | |
| 4587 if (!PyList_Check(tmp)) { | |
| 4588 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4589 goto failed; | |
| 4590 } | |
| 4591 len = PyList_GET_SIZE(tmp); | |
| 4592 orelse = asdl_seq_new(len, arena); | |
| 4593 if (orelse == NULL) goto failed; | |
| 4594 for (i = 0; i < len; i++) { | |
| 4595 stmt_ty value; | |
| 4596 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4597 if (res != 0) goto failed; | |
| 4598 asdl_seq_SET(orelse, i, value); | |
| 4599 } | |
| 4600 Py_XDECREF(tmp); | |
| 4601 tmp = NULL; | |
| 4602 } else { | |
| 4603 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try"); | |
| 4604 return 1; | |
| 4605 } | |
| 4606 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) { | |
| 4607 int res; | |
| 4608 Py_ssize_t len; | |
| 4609 Py_ssize_t i; | |
| 4610 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody); | |
| 4611 if (tmp == NULL) goto failed; | |
| 4612 if (!PyList_Check(tmp)) { | |
| 4613 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4614 goto failed; | |
| 4615 } | |
| 4616 len = PyList_GET_SIZE(tmp); | |
| 4617 finalbody = asdl_seq_new(len, arena); | |
| 4618 if (finalbody == NULL) goto failed; | |
| 4619 for (i = 0; i < len; i++) { | |
| 4620 stmt_ty value; | |
| 4621 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4622 if (res != 0) goto failed; | |
| 4623 asdl_seq_SET(finalbody, i, value); | |
| 4624 } | |
| 4625 Py_XDECREF(tmp); | |
| 4626 tmp = NULL; | |
| 4627 } else { | |
| 4628 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try"); | |
| 4629 return 1; | |
| 4630 } | |
| 4631 *out = Try(body, handlers, orelse, finalbody, lineno, | |
| 4632 col_offset, arena); | |
| 4633 if (*out == NULL) goto failed; | |
| 4634 return 0; | |
| 4635 } | |
| 4636 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); | |
| 4637 if (isinstance == -1) { | |
| 4638 return 1; | |
| 4639 } | |
| 4640 if (isinstance) { | |
| 4641 expr_ty test; | |
| 4642 expr_ty msg; | |
| 4643 | |
| 4644 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 4645 int res; | |
| 4646 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 4647 if (tmp == NULL) goto failed; | |
| 4648 res = obj2ast_expr(tmp, &test, arena); | |
| 4649 if (res != 0) goto failed; | |
| 4650 Py_XDECREF(tmp); | |
| 4651 tmp = NULL; | |
| 4652 } else { | |
| 4653 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert"); | |
| 4654 return 1; | |
| 4655 } | |
| 4656 if (exists_not_none(obj, &PyId_msg)) { | |
| 4657 int res; | |
| 4658 tmp = _PyObject_GetAttrId(obj, &PyId_msg); | |
| 4659 if (tmp == NULL) goto failed; | |
| 4660 res = obj2ast_expr(tmp, &msg, arena); | |
| 4661 if (res != 0) goto failed; | |
| 4662 Py_XDECREF(tmp); | |
| 4663 tmp = NULL; | |
| 4664 } else { | |
| 4665 msg = NULL; | |
| 4666 } | |
| 4667 *out = Assert(test, msg, lineno, col_offset, arena); | |
| 4668 if (*out == NULL) goto failed; | |
| 4669 return 0; | |
| 4670 } | |
| 4671 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); | |
| 4672 if (isinstance == -1) { | |
| 4673 return 1; | |
| 4674 } | |
| 4675 if (isinstance) { | |
| 4676 asdl_seq* names; | |
| 4677 | |
| 4678 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4679 int res; | |
| 4680 Py_ssize_t len; | |
| 4681 Py_ssize_t i; | |
| 4682 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4683 if (tmp == NULL) goto failed; | |
| 4684 if (!PyList_Check(tmp)) { | |
| 4685 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4686 goto failed; | |
| 4687 } | |
| 4688 len = PyList_GET_SIZE(tmp); | |
| 4689 names = asdl_seq_new(len, arena); | |
| 4690 if (names == NULL) goto failed; | |
| 4691 for (i = 0; i < len; i++) { | |
| 4692 alias_ty value; | |
| 4693 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4694 if (res != 0) goto failed; | |
| 4695 asdl_seq_SET(names, i, value); | |
| 4696 } | |
| 4697 Py_XDECREF(tmp); | |
| 4698 tmp = NULL; | |
| 4699 } else { | |
| 4700 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import"); | |
| 4701 return 1; | |
| 4702 } | |
| 4703 *out = Import(names, lineno, col_offset, arena); | |
| 4704 if (*out == NULL) goto failed; | |
| 4705 return 0; | |
| 4706 } | |
| 4707 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); | |
| 4708 if (isinstance == -1) { | |
| 4709 return 1; | |
| 4710 } | |
| 4711 if (isinstance) { | |
| 4712 identifier module; | |
| 4713 asdl_seq* names; | |
| 4714 int level; | |
| 4715 | |
| 4716 if (exists_not_none(obj, &PyId_module)) { | |
| 4717 int res; | |
| 4718 tmp = _PyObject_GetAttrId(obj, &PyId_module); | |
| 4719 if (tmp == NULL) goto failed; | |
| 4720 res = obj2ast_identifier(tmp, &module, arena); | |
| 4721 if (res != 0) goto failed; | |
| 4722 Py_XDECREF(tmp); | |
| 4723 tmp = NULL; | |
| 4724 } else { | |
| 4725 module = NULL; | |
| 4726 } | |
| 4727 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4728 int res; | |
| 4729 Py_ssize_t len; | |
| 4730 Py_ssize_t i; | |
| 4731 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4732 if (tmp == NULL) goto failed; | |
| 4733 if (!PyList_Check(tmp)) { | |
| 4734 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4735 goto failed; | |
| 4736 } | |
| 4737 len = PyList_GET_SIZE(tmp); | |
| 4738 names = asdl_seq_new(len, arena); | |
| 4739 if (names == NULL) goto failed; | |
| 4740 for (i = 0; i < len; i++) { | |
| 4741 alias_ty value; | |
| 4742 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4743 if (res != 0) goto failed; | |
| 4744 asdl_seq_SET(names, i, value); | |
| 4745 } | |
| 4746 Py_XDECREF(tmp); | |
| 4747 tmp = NULL; | |
| 4748 } else { | |
| 4749 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom"); | |
| 4750 return 1; | |
| 4751 } | |
| 4752 if (exists_not_none(obj, &PyId_level)) { | |
| 4753 int res; | |
| 4754 tmp = _PyObject_GetAttrId(obj, &PyId_level); | |
| 4755 if (tmp == NULL) goto failed; | |
| 4756 res = obj2ast_int(tmp, &level, arena); | |
| 4757 if (res != 0) goto failed; | |
| 4758 Py_XDECREF(tmp); | |
| 4759 tmp = NULL; | |
| 4760 } else { | |
| 4761 level = 0; | |
| 4762 } | |
| 4763 *out = ImportFrom(module, names, level, lineno, col_offset, | |
| 4764 arena); | |
| 4765 if (*out == NULL) goto failed; | |
| 4766 return 0; | |
| 4767 } | |
| 4768 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); | |
| 4769 if (isinstance == -1) { | |
| 4770 return 1; | |
| 4771 } | |
| 4772 if (isinstance) { | |
| 4773 asdl_seq* names; | |
| 4774 | |
| 4775 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4776 int res; | |
| 4777 Py_ssize_t len; | |
| 4778 Py_ssize_t i; | |
| 4779 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4780 if (tmp == NULL) goto failed; | |
| 4781 if (!PyList_Check(tmp)) { | |
| 4782 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4783 goto failed; | |
| 4784 } | |
| 4785 len = PyList_GET_SIZE(tmp); | |
| 4786 names = asdl_seq_new(len, arena); | |
| 4787 if (names == NULL) goto failed; | |
| 4788 for (i = 0; i < len; i++) { | |
| 4789 identifier value; | |
| 4790 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4791 if (res != 0) goto failed; | |
| 4792 asdl_seq_SET(names, i, value); | |
| 4793 } | |
| 4794 Py_XDECREF(tmp); | |
| 4795 tmp = NULL; | |
| 4796 } else { | |
| 4797 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global"); | |
| 4798 return 1; | |
| 4799 } | |
| 4800 *out = Global(names, lineno, col_offset, arena); | |
| 4801 if (*out == NULL) goto failed; | |
| 4802 return 0; | |
| 4803 } | |
| 4804 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type); | |
| 4805 if (isinstance == -1) { | |
| 4806 return 1; | |
| 4807 } | |
| 4808 if (isinstance) { | |
| 4809 asdl_seq* names; | |
| 4810 | |
| 4811 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4812 int res; | |
| 4813 Py_ssize_t len; | |
| 4814 Py_ssize_t i; | |
| 4815 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4816 if (tmp == NULL) goto failed; | |
| 4817 if (!PyList_Check(tmp)) { | |
| 4818 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4819 goto failed; | |
| 4820 } | |
| 4821 len = PyList_GET_SIZE(tmp); | |
| 4822 names = asdl_seq_new(len, arena); | |
| 4823 if (names == NULL) goto failed; | |
| 4824 for (i = 0; i < len; i++) { | |
| 4825 identifier value; | |
| 4826 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4827 if (res != 0) goto failed; | |
| 4828 asdl_seq_SET(names, i, value); | |
| 4829 } | |
| 4830 Py_XDECREF(tmp); | |
| 4831 tmp = NULL; | |
| 4832 } else { | |
| 4833 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal"); | |
| 4834 return 1; | |
| 4835 } | |
| 4836 *out = Nonlocal(names, lineno, col_offset, arena); | |
| 4837 if (*out == NULL) goto failed; | |
| 4838 return 0; | |
| 4839 } | |
| 4840 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); | |
| 4841 if (isinstance == -1) { | |
| 4842 return 1; | |
| 4843 } | |
| 4844 if (isinstance) { | |
| 4845 expr_ty value; | 4101 expr_ty value; |
| 4846 | 4102 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 4847 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 4103 if (res != 0) goto failed; |
| 4848 int res; | 4104 asdl_seq_SET(targets, i, value); |
| 4849 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 4105 } |
| 4850 if (tmp == NULL) goto failed; | 4106 Py_XDECREF(tmp); |
| 4851 res = obj2ast_expr(tmp, &value, arena); | 4107 tmp = NULL; |
| 4852 if (res != 0) goto failed; | 4108 } else { |
| 4853 Py_XDECREF(tmp); | 4109 PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign"); |
| 4854 tmp = NULL; | 4110 return 1; |
| 4855 } else { | 4111 } |
| 4856 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr"); | 4112 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
| 4857 return 1; | 4113 int res; |
| 4858 } | 4114 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
| 4859 *out = Expr(value, lineno, col_offset, arena); | 4115 if (tmp == NULL) goto failed; |
| 4860 if (*out == NULL) goto failed; | 4116 res = obj2ast_expr(tmp, &value, arena); |
| 4861 return 0; | 4117 if (res != 0) goto failed; |
| 4862 } | 4118 Py_XDECREF(tmp); |
| 4863 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); | 4119 tmp = NULL; |
| 4864 if (isinstance == -1) { | 4120 } else { |
| 4865 return 1; | 4121 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign"); |
| 4866 } | 4122 return 1; |
| 4867 if (isinstance) { | 4123 } |
| 4868 | 4124 *out = Assign(targets, value, lineno, col_offset, arena); |
| 4869 *out = Pass(lineno, col_offset, arena); | 4125 if (*out == NULL) goto failed; |
| 4870 if (*out == NULL) goto failed; | 4126 return 0; |
| 4871 return 0; | 4127 } |
| 4872 } | 4128 isinstance = PyObject_IsInstance(obj, (PyObject*)AugAssign_type); |
| 4873 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); | 4129 if (isinstance == -1) { |
| 4874 if (isinstance == -1) { | 4130 return 1; |
| 4875 return 1; | 4131 } |
| 4876 } | 4132 if (isinstance) { |
| 4877 if (isinstance) { | 4133 expr_ty target; |
| 4878 | 4134 operator_ty op; |
| 4879 *out = Break(lineno, col_offset, arena); | 4135 expr_ty value; |
| 4880 if (*out == NULL) goto failed; | 4136 |
| 4881 return 0; | 4137 if (_PyObject_HasAttrId(obj, &PyId_target)) { |
| 4882 } | 4138 int res; |
| 4883 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); | 4139 tmp = _PyObject_GetAttrId(obj, &PyId_target); |
| 4884 if (isinstance == -1) { | 4140 if (tmp == NULL) goto failed; |
| 4885 return 1; | 4141 res = obj2ast_expr(tmp, &target, arena); |
| 4886 } | 4142 if (res != 0) goto failed; |
| 4887 if (isinstance) { | 4143 Py_XDECREF(tmp); |
| 4888 | 4144 tmp = NULL; |
| 4889 *out = Continue(lineno, col_offset, arena); | 4145 } else { |
| 4890 if (*out == NULL) goto failed; | 4146 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign"); |
| 4891 return 0; | 4147 return 1; |
| 4892 } | 4148 } |
| 4893 | 4149 if (_PyObject_HasAttrId(obj, &PyId_op)) { |
| 4894 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj); | 4150 int res; |
| 4895 failed: | 4151 tmp = _PyObject_GetAttrId(obj, &PyId_op); |
| 4896 Py_XDECREF(tmp); | 4152 if (tmp == NULL) goto failed; |
| 4897 return 1; | 4153 res = obj2ast_operator(tmp, &op, arena); |
| 4154 if (res != 0) goto failed; | |
| 4155 Py_XDECREF(tmp); | |
| 4156 tmp = NULL; | |
| 4157 } else { | |
| 4158 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign"); | |
| 4159 return 1; | |
| 4160 } | |
| 4161 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 4162 int res; | |
| 4163 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 4164 if (tmp == NULL) goto failed; | |
| 4165 res = obj2ast_expr(tmp, &value, arena); | |
| 4166 if (res != 0) goto failed; | |
| 4167 Py_XDECREF(tmp); | |
| 4168 tmp = NULL; | |
| 4169 } else { | |
| 4170 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign"); | |
| 4171 return 1; | |
| 4172 } | |
| 4173 *out = AugAssign(target, op, value, lineno, col_offset, arena); | |
| 4174 if (*out == NULL) goto failed; | |
| 4175 return 0; | |
| 4176 } | |
| 4177 isinstance = PyObject_IsInstance(obj, (PyObject*)For_type); | |
| 4178 if (isinstance == -1) { | |
| 4179 return 1; | |
| 4180 } | |
| 4181 if (isinstance) { | |
| 4182 expr_ty target; | |
| 4183 expr_ty iter; | |
| 4184 asdl_seq* body; | |
| 4185 asdl_seq* orelse; | |
| 4186 | |
| 4187 if (_PyObject_HasAttrId(obj, &PyId_target)) { | |
| 4188 int res; | |
| 4189 tmp = _PyObject_GetAttrId(obj, &PyId_target); | |
| 4190 if (tmp == NULL) goto failed; | |
| 4191 res = obj2ast_expr(tmp, &target, arena); | |
| 4192 if (res != 0) goto failed; | |
| 4193 Py_XDECREF(tmp); | |
| 4194 tmp = NULL; | |
| 4195 } else { | |
| 4196 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For"); | |
| 4197 return 1; | |
| 4198 } | |
| 4199 if (_PyObject_HasAttrId(obj, &PyId_iter)) { | |
| 4200 int res; | |
| 4201 tmp = _PyObject_GetAttrId(obj, &PyId_iter); | |
| 4202 if (tmp == NULL) goto failed; | |
| 4203 res = obj2ast_expr(tmp, &iter, arena); | |
| 4204 if (res != 0) goto failed; | |
| 4205 Py_XDECREF(tmp); | |
| 4206 tmp = NULL; | |
| 4207 } else { | |
| 4208 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For"); | |
| 4209 return 1; | |
| 4210 } | |
| 4211 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4212 int res; | |
| 4213 Py_ssize_t len; | |
| 4214 Py_ssize_t i; | |
| 4215 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4216 if (tmp == NULL) goto failed; | |
| 4217 if (!PyList_Check(tmp)) { | |
| 4218 PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4219 goto failed; | |
| 4220 } | |
| 4221 len = PyList_GET_SIZE(tmp); | |
| 4222 body = asdl_seq_new(len, arena); | |
| 4223 if (body == NULL) goto failed; | |
| 4224 for (i = 0; i < len; i++) { | |
| 4225 stmt_ty value; | |
| 4226 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4227 if (res != 0) goto failed; | |
| 4228 asdl_seq_SET(body, i, value); | |
| 4229 } | |
| 4230 Py_XDECREF(tmp); | |
| 4231 tmp = NULL; | |
| 4232 } else { | |
| 4233 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For"); | |
| 4234 return 1; | |
| 4235 } | |
| 4236 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4237 int res; | |
| 4238 Py_ssize_t len; | |
| 4239 Py_ssize_t i; | |
| 4240 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4241 if (tmp == NULL) goto failed; | |
| 4242 if (!PyList_Check(tmp)) { | |
| 4243 PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4244 goto failed; | |
| 4245 } | |
| 4246 len = PyList_GET_SIZE(tmp); | |
| 4247 orelse = asdl_seq_new(len, arena); | |
| 4248 if (orelse == NULL) goto failed; | |
| 4249 for (i = 0; i < len; i++) { | |
| 4250 stmt_ty value; | |
| 4251 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4252 if (res != 0) goto failed; | |
| 4253 asdl_seq_SET(orelse, i, value); | |
| 4254 } | |
| 4255 Py_XDECREF(tmp); | |
| 4256 tmp = NULL; | |
| 4257 } else { | |
| 4258 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For"); | |
| 4259 return 1; | |
| 4260 } | |
| 4261 *out = For(target, iter, body, orelse, lineno, col_offset, arena); | |
| 4262 if (*out == NULL) goto failed; | |
| 4263 return 0; | |
| 4264 } | |
| 4265 isinstance = PyObject_IsInstance(obj, (PyObject*)While_type); | |
| 4266 if (isinstance == -1) { | |
| 4267 return 1; | |
| 4268 } | |
| 4269 if (isinstance) { | |
| 4270 expr_ty test; | |
| 4271 asdl_seq* body; | |
| 4272 asdl_seq* orelse; | |
| 4273 | |
| 4274 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 4275 int res; | |
| 4276 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 4277 if (tmp == NULL) goto failed; | |
| 4278 res = obj2ast_expr(tmp, &test, arena); | |
| 4279 if (res != 0) goto failed; | |
| 4280 Py_XDECREF(tmp); | |
| 4281 tmp = NULL; | |
| 4282 } else { | |
| 4283 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While"); | |
| 4284 return 1; | |
| 4285 } | |
| 4286 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4287 int res; | |
| 4288 Py_ssize_t len; | |
| 4289 Py_ssize_t i; | |
| 4290 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4291 if (tmp == NULL) goto failed; | |
| 4292 if (!PyList_Check(tmp)) { | |
| 4293 PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4294 goto failed; | |
| 4295 } | |
| 4296 len = PyList_GET_SIZE(tmp); | |
| 4297 body = asdl_seq_new(len, arena); | |
| 4298 if (body == NULL) goto failed; | |
| 4299 for (i = 0; i < len; i++) { | |
| 4300 stmt_ty value; | |
| 4301 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4302 if (res != 0) goto failed; | |
| 4303 asdl_seq_SET(body, i, value); | |
| 4304 } | |
| 4305 Py_XDECREF(tmp); | |
| 4306 tmp = NULL; | |
| 4307 } else { | |
| 4308 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While"); | |
| 4309 return 1; | |
| 4310 } | |
| 4311 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4312 int res; | |
| 4313 Py_ssize_t len; | |
| 4314 Py_ssize_t i; | |
| 4315 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4316 if (tmp == NULL) goto failed; | |
| 4317 if (!PyList_Check(tmp)) { | |
| 4318 PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4319 goto failed; | |
| 4320 } | |
| 4321 len = PyList_GET_SIZE(tmp); | |
| 4322 orelse = asdl_seq_new(len, arena); | |
| 4323 if (orelse == NULL) goto failed; | |
| 4324 for (i = 0; i < len; i++) { | |
| 4325 stmt_ty value; | |
| 4326 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4327 if (res != 0) goto failed; | |
| 4328 asdl_seq_SET(orelse, i, value); | |
| 4329 } | |
| 4330 Py_XDECREF(tmp); | |
| 4331 tmp = NULL; | |
| 4332 } else { | |
| 4333 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While"); | |
| 4334 return 1; | |
| 4335 } | |
| 4336 *out = While(test, body, orelse, lineno, col_offset, arena); | |
| 4337 if (*out == NULL) goto failed; | |
| 4338 return 0; | |
| 4339 } | |
| 4340 isinstance = PyObject_IsInstance(obj, (PyObject*)If_type); | |
| 4341 if (isinstance == -1) { | |
| 4342 return 1; | |
| 4343 } | |
| 4344 if (isinstance) { | |
| 4345 expr_ty test; | |
| 4346 asdl_seq* body; | |
| 4347 asdl_seq* orelse; | |
| 4348 | |
| 4349 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 4350 int res; | |
| 4351 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 4352 if (tmp == NULL) goto failed; | |
| 4353 res = obj2ast_expr(tmp, &test, arena); | |
| 4354 if (res != 0) goto failed; | |
| 4355 Py_XDECREF(tmp); | |
| 4356 tmp = NULL; | |
| 4357 } else { | |
| 4358 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If"); | |
| 4359 return 1; | |
| 4360 } | |
| 4361 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4362 int res; | |
| 4363 Py_ssize_t len; | |
| 4364 Py_ssize_t i; | |
| 4365 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4366 if (tmp == NULL) goto failed; | |
| 4367 if (!PyList_Check(tmp)) { | |
| 4368 PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4369 goto failed; | |
| 4370 } | |
| 4371 len = PyList_GET_SIZE(tmp); | |
| 4372 body = asdl_seq_new(len, arena); | |
| 4373 if (body == NULL) goto failed; | |
| 4374 for (i = 0; i < len; i++) { | |
| 4375 stmt_ty value; | |
| 4376 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4377 if (res != 0) goto failed; | |
| 4378 asdl_seq_SET(body, i, value); | |
| 4379 } | |
| 4380 Py_XDECREF(tmp); | |
| 4381 tmp = NULL; | |
| 4382 } else { | |
| 4383 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If"); | |
| 4384 return 1; | |
| 4385 } | |
| 4386 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4387 int res; | |
| 4388 Py_ssize_t len; | |
| 4389 Py_ssize_t i; | |
| 4390 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4391 if (tmp == NULL) goto failed; | |
| 4392 if (!PyList_Check(tmp)) { | |
| 4393 PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4394 goto failed; | |
| 4395 } | |
| 4396 len = PyList_GET_SIZE(tmp); | |
| 4397 orelse = asdl_seq_new(len, arena); | |
| 4398 if (orelse == NULL) goto failed; | |
| 4399 for (i = 0; i < len; i++) { | |
| 4400 stmt_ty value; | |
| 4401 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4402 if (res != 0) goto failed; | |
| 4403 asdl_seq_SET(orelse, i, value); | |
| 4404 } | |
| 4405 Py_XDECREF(tmp); | |
| 4406 tmp = NULL; | |
| 4407 } else { | |
| 4408 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If"); | |
| 4409 return 1; | |
| 4410 } | |
| 4411 *out = If(test, body, orelse, lineno, col_offset, arena); | |
| 4412 if (*out == NULL) goto failed; | |
| 4413 return 0; | |
| 4414 } | |
| 4415 isinstance = PyObject_IsInstance(obj, (PyObject*)With_type); | |
| 4416 if (isinstance == -1) { | |
| 4417 return 1; | |
| 4418 } | |
| 4419 if (isinstance) { | |
| 4420 asdl_seq* items; | |
| 4421 asdl_seq* body; | |
| 4422 | |
| 4423 if (_PyObject_HasAttrId(obj, &PyId_items)) { | |
| 4424 int res; | |
| 4425 Py_ssize_t len; | |
| 4426 Py_ssize_t i; | |
| 4427 tmp = _PyObject_GetAttrId(obj, &PyId_items); | |
| 4428 if (tmp == NULL) goto failed; | |
| 4429 if (!PyList_Check(tmp)) { | |
| 4430 PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4431 goto failed; | |
| 4432 } | |
| 4433 len = PyList_GET_SIZE(tmp); | |
| 4434 items = asdl_seq_new(len, arena); | |
| 4435 if (items == NULL) goto failed; | |
| 4436 for (i = 0; i < len; i++) { | |
| 4437 withitem_ty value; | |
| 4438 res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4439 if (res != 0) goto failed; | |
| 4440 asdl_seq_SET(items, i, value); | |
| 4441 } | |
| 4442 Py_XDECREF(tmp); | |
| 4443 tmp = NULL; | |
| 4444 } else { | |
| 4445 PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With"); | |
| 4446 return 1; | |
| 4447 } | |
| 4448 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4449 int res; | |
| 4450 Py_ssize_t len; | |
| 4451 Py_ssize_t i; | |
| 4452 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4453 if (tmp == NULL) goto failed; | |
| 4454 if (!PyList_Check(tmp)) { | |
| 4455 PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4456 goto failed; | |
| 4457 } | |
| 4458 len = PyList_GET_SIZE(tmp); | |
| 4459 body = asdl_seq_new(len, arena); | |
| 4460 if (body == NULL) goto failed; | |
| 4461 for (i = 0; i < len; i++) { | |
| 4462 stmt_ty value; | |
| 4463 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4464 if (res != 0) goto failed; | |
| 4465 asdl_seq_SET(body, i, value); | |
| 4466 } | |
| 4467 Py_XDECREF(tmp); | |
| 4468 tmp = NULL; | |
| 4469 } else { | |
| 4470 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With"); | |
| 4471 return 1; | |
| 4472 } | |
| 4473 *out = With(items, body, lineno, col_offset, arena); | |
| 4474 if (*out == NULL) goto failed; | |
| 4475 return 0; | |
| 4476 } | |
| 4477 isinstance = PyObject_IsInstance(obj, (PyObject*)Raise_type); | |
| 4478 if (isinstance == -1) { | |
| 4479 return 1; | |
| 4480 } | |
| 4481 if (isinstance) { | |
| 4482 expr_ty exc; | |
| 4483 expr_ty cause; | |
| 4484 | |
| 4485 if (exists_not_none(obj, &PyId_exc)) { | |
| 4486 int res; | |
| 4487 tmp = _PyObject_GetAttrId(obj, &PyId_exc); | |
| 4488 if (tmp == NULL) goto failed; | |
| 4489 res = obj2ast_expr(tmp, &exc, arena); | |
| 4490 if (res != 0) goto failed; | |
| 4491 Py_XDECREF(tmp); | |
| 4492 tmp = NULL; | |
| 4493 } else { | |
| 4494 exc = NULL; | |
| 4495 } | |
| 4496 if (exists_not_none(obj, &PyId_cause)) { | |
| 4497 int res; | |
| 4498 tmp = _PyObject_GetAttrId(obj, &PyId_cause); | |
| 4499 if (tmp == NULL) goto failed; | |
| 4500 res = obj2ast_expr(tmp, &cause, arena); | |
| 4501 if (res != 0) goto failed; | |
| 4502 Py_XDECREF(tmp); | |
| 4503 tmp = NULL; | |
| 4504 } else { | |
| 4505 cause = NULL; | |
| 4506 } | |
| 4507 *out = Raise(exc, cause, lineno, col_offset, arena); | |
| 4508 if (*out == NULL) goto failed; | |
| 4509 return 0; | |
| 4510 } | |
| 4511 isinstance = PyObject_IsInstance(obj, (PyObject*)Try_type); | |
| 4512 if (isinstance == -1) { | |
| 4513 return 1; | |
| 4514 } | |
| 4515 if (isinstance) { | |
| 4516 asdl_seq* body; | |
| 4517 asdl_seq* handlers; | |
| 4518 asdl_seq* orelse; | |
| 4519 asdl_seq* finalbody; | |
| 4520 | |
| 4521 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 4522 int res; | |
| 4523 Py_ssize_t len; | |
| 4524 Py_ssize_t i; | |
| 4525 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 4526 if (tmp == NULL) goto failed; | |
| 4527 if (!PyList_Check(tmp)) { | |
| 4528 PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4529 goto failed; | |
| 4530 } | |
| 4531 len = PyList_GET_SIZE(tmp); | |
| 4532 body = asdl_seq_new(len, arena); | |
| 4533 if (body == NULL) goto failed; | |
| 4534 for (i = 0; i < len; i++) { | |
| 4535 stmt_ty value; | |
| 4536 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4537 if (res != 0) goto failed; | |
| 4538 asdl_seq_SET(body, i, value); | |
| 4539 } | |
| 4540 Py_XDECREF(tmp); | |
| 4541 tmp = NULL; | |
| 4542 } else { | |
| 4543 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try"); | |
| 4544 return 1; | |
| 4545 } | |
| 4546 if (_PyObject_HasAttrId(obj, &PyId_handlers)) { | |
| 4547 int res; | |
| 4548 Py_ssize_t len; | |
| 4549 Py_ssize_t i; | |
| 4550 tmp = _PyObject_GetAttrId(obj, &PyId_handlers); | |
| 4551 if (tmp == NULL) goto failed; | |
| 4552 if (!PyList_Check(tmp)) { | |
| 4553 PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4554 goto failed; | |
| 4555 } | |
| 4556 len = PyList_GET_SIZE(tmp); | |
| 4557 handlers = asdl_seq_new(len, arena); | |
| 4558 if (handlers == NULL) goto failed; | |
| 4559 for (i = 0; i < len; i++) { | |
| 4560 excepthandler_ty value; | |
| 4561 res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4562 if (res != 0) goto failed; | |
| 4563 asdl_seq_SET(handlers, i, value); | |
| 4564 } | |
| 4565 Py_XDECREF(tmp); | |
| 4566 tmp = NULL; | |
| 4567 } else { | |
| 4568 PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try"); | |
| 4569 return 1; | |
| 4570 } | |
| 4571 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 4572 int res; | |
| 4573 Py_ssize_t len; | |
| 4574 Py_ssize_t i; | |
| 4575 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 4576 if (tmp == NULL) goto failed; | |
| 4577 if (!PyList_Check(tmp)) { | |
| 4578 PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4579 goto failed; | |
| 4580 } | |
| 4581 len = PyList_GET_SIZE(tmp); | |
| 4582 orelse = asdl_seq_new(len, arena); | |
| 4583 if (orelse == NULL) goto failed; | |
| 4584 for (i = 0; i < len; i++) { | |
| 4585 stmt_ty value; | |
| 4586 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4587 if (res != 0) goto failed; | |
| 4588 asdl_seq_SET(orelse, i, value); | |
| 4589 } | |
| 4590 Py_XDECREF(tmp); | |
| 4591 tmp = NULL; | |
| 4592 } else { | |
| 4593 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try"); | |
| 4594 return 1; | |
| 4595 } | |
| 4596 if (_PyObject_HasAttrId(obj, &PyId_finalbody)) { | |
| 4597 int res; | |
| 4598 Py_ssize_t len; | |
| 4599 Py_ssize_t i; | |
| 4600 tmp = _PyObject_GetAttrId(obj, &PyId_finalbody); | |
| 4601 if (tmp == NULL) goto failed; | |
| 4602 if (!PyList_Check(tmp)) { | |
| 4603 PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4604 goto failed; | |
| 4605 } | |
| 4606 len = PyList_GET_SIZE(tmp); | |
| 4607 finalbody = asdl_seq_new(len, arena); | |
| 4608 if (finalbody == NULL) goto failed; | |
| 4609 for (i = 0; i < len; i++) { | |
| 4610 stmt_ty value; | |
| 4611 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4612 if (res != 0) goto failed; | |
| 4613 asdl_seq_SET(finalbody, i, value); | |
| 4614 } | |
| 4615 Py_XDECREF(tmp); | |
| 4616 tmp = NULL; | |
| 4617 } else { | |
| 4618 PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try"); | |
| 4619 return 1; | |
| 4620 } | |
| 4621 *out = Try(body, handlers, orelse, finalbody, lineno, col_offset, | |
| 4622 arena); | |
| 4623 if (*out == NULL) goto failed; | |
| 4624 return 0; | |
| 4625 } | |
| 4626 isinstance = PyObject_IsInstance(obj, (PyObject*)Assert_type); | |
| 4627 if (isinstance == -1) { | |
| 4628 return 1; | |
| 4629 } | |
| 4630 if (isinstance) { | |
| 4631 expr_ty test; | |
| 4632 expr_ty msg; | |
| 4633 | |
| 4634 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 4635 int res; | |
| 4636 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 4637 if (tmp == NULL) goto failed; | |
| 4638 res = obj2ast_expr(tmp, &test, arena); | |
| 4639 if (res != 0) goto failed; | |
| 4640 Py_XDECREF(tmp); | |
| 4641 tmp = NULL; | |
| 4642 } else { | |
| 4643 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert"); | |
| 4644 return 1; | |
| 4645 } | |
| 4646 if (exists_not_none(obj, &PyId_msg)) { | |
| 4647 int res; | |
| 4648 tmp = _PyObject_GetAttrId(obj, &PyId_msg); | |
| 4649 if (tmp == NULL) goto failed; | |
| 4650 res = obj2ast_expr(tmp, &msg, arena); | |
| 4651 if (res != 0) goto failed; | |
| 4652 Py_XDECREF(tmp); | |
| 4653 tmp = NULL; | |
| 4654 } else { | |
| 4655 msg = NULL; | |
| 4656 } | |
| 4657 *out = Assert(test, msg, lineno, col_offset, arena); | |
| 4658 if (*out == NULL) goto failed; | |
| 4659 return 0; | |
| 4660 } | |
| 4661 isinstance = PyObject_IsInstance(obj, (PyObject*)Import_type); | |
| 4662 if (isinstance == -1) { | |
| 4663 return 1; | |
| 4664 } | |
| 4665 if (isinstance) { | |
| 4666 asdl_seq* names; | |
| 4667 | |
| 4668 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4669 int res; | |
| 4670 Py_ssize_t len; | |
| 4671 Py_ssize_t i; | |
| 4672 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4673 if (tmp == NULL) goto failed; | |
| 4674 if (!PyList_Check(tmp)) { | |
| 4675 PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4676 goto failed; | |
| 4677 } | |
| 4678 len = PyList_GET_SIZE(tmp); | |
| 4679 names = asdl_seq_new(len, arena); | |
| 4680 if (names == NULL) goto failed; | |
| 4681 for (i = 0; i < len; i++) { | |
| 4682 alias_ty value; | |
| 4683 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4684 if (res != 0) goto failed; | |
| 4685 asdl_seq_SET(names, i, value); | |
| 4686 } | |
| 4687 Py_XDECREF(tmp); | |
| 4688 tmp = NULL; | |
| 4689 } else { | |
| 4690 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import"); | |
| 4691 return 1; | |
| 4692 } | |
| 4693 *out = Import(names, lineno, col_offset, arena); | |
| 4694 if (*out == NULL) goto failed; | |
| 4695 return 0; | |
| 4696 } | |
| 4697 isinstance = PyObject_IsInstance(obj, (PyObject*)ImportFrom_type); | |
| 4698 if (isinstance == -1) { | |
| 4699 return 1; | |
| 4700 } | |
| 4701 if (isinstance) { | |
| 4702 identifier module; | |
| 4703 asdl_seq* names; | |
| 4704 int level; | |
| 4705 | |
| 4706 if (exists_not_none(obj, &PyId_module)) { | |
| 4707 int res; | |
| 4708 tmp = _PyObject_GetAttrId(obj, &PyId_module); | |
| 4709 if (tmp == NULL) goto failed; | |
| 4710 res = obj2ast_identifier(tmp, &module, arena); | |
| 4711 if (res != 0) goto failed; | |
| 4712 Py_XDECREF(tmp); | |
| 4713 tmp = NULL; | |
| 4714 } else { | |
| 4715 module = NULL; | |
| 4716 } | |
| 4717 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4718 int res; | |
| 4719 Py_ssize_t len; | |
| 4720 Py_ssize_t i; | |
| 4721 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4722 if (tmp == NULL) goto failed; | |
| 4723 if (!PyList_Check(tmp)) { | |
| 4724 PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4725 goto failed; | |
| 4726 } | |
| 4727 len = PyList_GET_SIZE(tmp); | |
| 4728 names = asdl_seq_new(len, arena); | |
| 4729 if (names == NULL) goto failed; | |
| 4730 for (i = 0; i < len; i++) { | |
| 4731 alias_ty value; | |
| 4732 res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4733 if (res != 0) goto failed; | |
| 4734 asdl_seq_SET(names, i, value); | |
| 4735 } | |
| 4736 Py_XDECREF(tmp); | |
| 4737 tmp = NULL; | |
| 4738 } else { | |
| 4739 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom"); | |
| 4740 return 1; | |
| 4741 } | |
| 4742 if (exists_not_none(obj, &PyId_level)) { | |
| 4743 int res; | |
| 4744 tmp = _PyObject_GetAttrId(obj, &PyId_level); | |
| 4745 if (tmp == NULL) goto failed; | |
| 4746 res = obj2ast_int(tmp, &level, arena); | |
| 4747 if (res != 0) goto failed; | |
| 4748 Py_XDECREF(tmp); | |
| 4749 tmp = NULL; | |
| 4750 } else { | |
| 4751 level = 0; | |
| 4752 } | |
| 4753 *out = ImportFrom(module, names, level, lineno, col_offset, arena); | |
| 4754 if (*out == NULL) goto failed; | |
| 4755 return 0; | |
| 4756 } | |
| 4757 isinstance = PyObject_IsInstance(obj, (PyObject*)Global_type); | |
| 4758 if (isinstance == -1) { | |
| 4759 return 1; | |
| 4760 } | |
| 4761 if (isinstance) { | |
| 4762 asdl_seq* names; | |
| 4763 | |
| 4764 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4765 int res; | |
| 4766 Py_ssize_t len; | |
| 4767 Py_ssize_t i; | |
| 4768 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4769 if (tmp == NULL) goto failed; | |
| 4770 if (!PyList_Check(tmp)) { | |
| 4771 PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4772 goto failed; | |
| 4773 } | |
| 4774 len = PyList_GET_SIZE(tmp); | |
| 4775 names = asdl_seq_new(len, arena); | |
| 4776 if (names == NULL) goto failed; | |
| 4777 for (i = 0; i < len; i++) { | |
| 4778 identifier value; | |
| 4779 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4780 if (res != 0) goto failed; | |
| 4781 asdl_seq_SET(names, i, value); | |
| 4782 } | |
| 4783 Py_XDECREF(tmp); | |
| 4784 tmp = NULL; | |
| 4785 } else { | |
| 4786 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global"); | |
| 4787 return 1; | |
| 4788 } | |
| 4789 *out = Global(names, lineno, col_offset, arena); | |
| 4790 if (*out == NULL) goto failed; | |
| 4791 return 0; | |
| 4792 } | |
| 4793 isinstance = PyObject_IsInstance(obj, (PyObject*)Nonlocal_type); | |
| 4794 if (isinstance == -1) { | |
| 4795 return 1; | |
| 4796 } | |
| 4797 if (isinstance) { | |
| 4798 asdl_seq* names; | |
| 4799 | |
| 4800 if (_PyObject_HasAttrId(obj, &PyId_names)) { | |
| 4801 int res; | |
| 4802 Py_ssize_t len; | |
| 4803 Py_ssize_t i; | |
| 4804 tmp = _PyObject_GetAttrId(obj, &PyId_names); | |
| 4805 if (tmp == NULL) goto failed; | |
| 4806 if (!PyList_Check(tmp)) { | |
| 4807 PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4808 goto failed; | |
| 4809 } | |
| 4810 len = PyList_GET_SIZE(tmp); | |
| 4811 names = asdl_seq_new(len, arena); | |
| 4812 if (names == NULL) goto failed; | |
| 4813 for (i = 0; i < len; i++) { | |
| 4814 identifier value; | |
| 4815 res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4816 if (res != 0) goto failed; | |
| 4817 asdl_seq_SET(names, i, value); | |
| 4818 } | |
| 4819 Py_XDECREF(tmp); | |
| 4820 tmp = NULL; | |
| 4821 } else { | |
| 4822 PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal"); | |
| 4823 return 1; | |
| 4824 } | |
| 4825 *out = Nonlocal(names, lineno, col_offset, arena); | |
| 4826 if (*out == NULL) goto failed; | |
| 4827 return 0; | |
| 4828 } | |
| 4829 isinstance = PyObject_IsInstance(obj, (PyObject*)Expr_type); | |
| 4830 if (isinstance == -1) { | |
| 4831 return 1; | |
| 4832 } | |
| 4833 if (isinstance) { | |
| 4834 expr_ty value; | |
| 4835 | |
| 4836 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 4837 int res; | |
| 4838 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 4839 if (tmp == NULL) goto failed; | |
| 4840 res = obj2ast_expr(tmp, &value, arena); | |
| 4841 if (res != 0) goto failed; | |
| 4842 Py_XDECREF(tmp); | |
| 4843 tmp = NULL; | |
| 4844 } else { | |
| 4845 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr"); | |
| 4846 return 1; | |
| 4847 } | |
| 4848 *out = Expr(value, lineno, col_offset, arena); | |
| 4849 if (*out == NULL) goto failed; | |
| 4850 return 0; | |
| 4851 } | |
| 4852 isinstance = PyObject_IsInstance(obj, (PyObject*)Pass_type); | |
| 4853 if (isinstance == -1) { | |
| 4854 return 1; | |
| 4855 } | |
| 4856 if (isinstance) { | |
| 4857 | |
| 4858 *out = Pass(lineno, col_offset, arena); | |
| 4859 if (*out == NULL) goto failed; | |
| 4860 return 0; | |
| 4861 } | |
| 4862 isinstance = PyObject_IsInstance(obj, (PyObject*)Break_type); | |
| 4863 if (isinstance == -1) { | |
| 4864 return 1; | |
| 4865 } | |
| 4866 if (isinstance) { | |
| 4867 | |
| 4868 *out = Break(lineno, col_offset, arena); | |
| 4869 if (*out == NULL) goto failed; | |
| 4870 return 0; | |
| 4871 } | |
| 4872 isinstance = PyObject_IsInstance(obj, (PyObject*)Continue_type); | |
| 4873 if (isinstance == -1) { | |
| 4874 return 1; | |
| 4875 } | |
| 4876 if (isinstance) { | |
| 4877 | |
| 4878 *out = Continue(lineno, col_offset, arena); | |
| 4879 if (*out == NULL) goto failed; | |
| 4880 return 0; | |
| 4881 } | |
| 4882 | |
| 4883 PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj); | |
| 4884 failed: | |
| 4885 Py_XDECREF(tmp); | |
| 4886 return 1; | |
| 4898 } | 4887 } |
| 4899 | 4888 |
| 4900 int | 4889 int |
| 4901 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) | 4890 obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena) |
| 4902 { | 4891 { |
| 4903 int isinstance; | 4892 int isinstance; |
| 4904 | 4893 |
| 4905 PyObject *tmp = NULL; | 4894 PyObject *tmp = NULL; |
| 4906 int lineno; | 4895 int lineno; |
| 4907 int col_offset; | 4896 int col_offset; |
| 4908 | 4897 |
| 4909 if (obj == Py_None) { | 4898 if (obj == Py_None) { |
| 4910 *out = NULL; | 4899 *out = NULL; |
| 4911 return 0; | 4900 return 0; |
| 4912 } | 4901 } |
| 4913 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { | 4902 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { |
| 4914 int res; | 4903 int res; |
| 4915 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); | 4904 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); |
| 4916 if (tmp == NULL) goto failed; | 4905 if (tmp == NULL) goto failed; |
| 4917 res = obj2ast_int(tmp, &lineno, arena); | 4906 res = obj2ast_int(tmp, &lineno, arena); |
| 4907 if (res != 0) goto failed; | |
| 4908 Py_XDECREF(tmp); | |
| 4909 tmp = NULL; | |
| 4910 } else { | |
| 4911 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr"); | |
| 4912 return 1; | |
| 4913 } | |
| 4914 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { | |
| 4915 int res; | |
| 4916 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); | |
| 4917 if (tmp == NULL) goto failed; | |
| 4918 res = obj2ast_int(tmp, &col_offset, arena); | |
| 4919 if (res != 0) goto failed; | |
| 4920 Py_XDECREF(tmp); | |
| 4921 tmp = NULL; | |
| 4922 } else { | |
| 4923 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); | |
| 4924 return 1; | |
| 4925 } | |
| 4926 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); | |
| 4927 if (isinstance == -1) { | |
| 4928 return 1; | |
| 4929 } | |
| 4930 if (isinstance) { | |
| 4931 boolop_ty op; | |
| 4932 asdl_seq* values; | |
| 4933 | |
| 4934 if (_PyObject_HasAttrId(obj, &PyId_op)) { | |
| 4935 int res; | |
| 4936 tmp = _PyObject_GetAttrId(obj, &PyId_op); | |
| 4937 if (tmp == NULL) goto failed; | |
| 4938 res = obj2ast_boolop(tmp, &op, arena); | |
| 4939 if (res != 0) goto failed; | |
| 4940 Py_XDECREF(tmp); | |
| 4941 tmp = NULL; | |
| 4942 } else { | |
| 4943 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp"); | |
| 4944 return 1; | |
| 4945 } | |
| 4946 if (_PyObject_HasAttrId(obj, &PyId_values)) { | |
| 4947 int res; | |
| 4948 Py_ssize_t len; | |
| 4949 Py_ssize_t i; | |
| 4950 tmp = _PyObject_GetAttrId(obj, &PyId_values); | |
| 4951 if (tmp == NULL) goto failed; | |
| 4952 if (!PyList_Check(tmp)) { | |
| 4953 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4954 goto failed; | |
| 4955 } | |
| 4956 len = PyList_GET_SIZE(tmp); | |
| 4957 values = asdl_seq_new(len, arena); | |
| 4958 if (values == NULL) goto failed; | |
| 4959 for (i = 0; i < len; i++) { | |
| 4960 expr_ty value; | |
| 4961 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4918 if (res != 0) goto failed; | 4962 if (res != 0) goto failed; |
| 4919 Py_XDECREF(tmp); | 4963 asdl_seq_SET(values, i, value); |
| 4920 tmp = NULL; | 4964 } |
| 4921 } else { | 4965 Py_XDECREF(tmp); |
| 4922 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr"); | 4966 tmp = NULL; |
| 4923 return 1; | 4967 } else { |
| 4924 } | 4968 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp"); |
| 4925 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { | 4969 return 1; |
| 4926 int res; | 4970 } |
| 4927 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); | 4971 *out = BoolOp(op, values, lineno, col_offset, arena); |
| 4928 if (tmp == NULL) goto failed; | 4972 if (*out == NULL) goto failed; |
| 4929 res = obj2ast_int(tmp, &col_offset, arena); | 4973 return 0; |
| 4974 } | |
| 4975 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); | |
| 4976 if (isinstance == -1) { | |
| 4977 return 1; | |
| 4978 } | |
| 4979 if (isinstance) { | |
| 4980 expr_ty left; | |
| 4981 operator_ty op; | |
| 4982 expr_ty right; | |
| 4983 | |
| 4984 if (_PyObject_HasAttrId(obj, &PyId_left)) { | |
| 4985 int res; | |
| 4986 tmp = _PyObject_GetAttrId(obj, &PyId_left); | |
| 4987 if (tmp == NULL) goto failed; | |
| 4988 res = obj2ast_expr(tmp, &left, arena); | |
| 4989 if (res != 0) goto failed; | |
| 4990 Py_XDECREF(tmp); | |
| 4991 tmp = NULL; | |
| 4992 } else { | |
| 4993 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp"); | |
| 4994 return 1; | |
| 4995 } | |
| 4996 if (_PyObject_HasAttrId(obj, &PyId_op)) { | |
| 4997 int res; | |
| 4998 tmp = _PyObject_GetAttrId(obj, &PyId_op); | |
| 4999 if (tmp == NULL) goto failed; | |
| 5000 res = obj2ast_operator(tmp, &op, arena); | |
| 5001 if (res != 0) goto failed; | |
| 5002 Py_XDECREF(tmp); | |
| 5003 tmp = NULL; | |
| 5004 } else { | |
| 5005 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp"); | |
| 5006 return 1; | |
| 5007 } | |
| 5008 if (_PyObject_HasAttrId(obj, &PyId_right)) { | |
| 5009 int res; | |
| 5010 tmp = _PyObject_GetAttrId(obj, &PyId_right); | |
| 5011 if (tmp == NULL) goto failed; | |
| 5012 res = obj2ast_expr(tmp, &right, arena); | |
| 5013 if (res != 0) goto failed; | |
| 5014 Py_XDECREF(tmp); | |
| 5015 tmp = NULL; | |
| 5016 } else { | |
| 5017 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp"); | |
| 5018 return 1; | |
| 5019 } | |
| 5020 *out = BinOp(left, op, right, lineno, col_offset, arena); | |
| 5021 if (*out == NULL) goto failed; | |
| 5022 return 0; | |
| 5023 } | |
| 5024 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); | |
| 5025 if (isinstance == -1) { | |
| 5026 return 1; | |
| 5027 } | |
| 5028 if (isinstance) { | |
| 5029 unaryop_ty op; | |
| 5030 expr_ty operand; | |
| 5031 | |
| 5032 if (_PyObject_HasAttrId(obj, &PyId_op)) { | |
| 5033 int res; | |
| 5034 tmp = _PyObject_GetAttrId(obj, &PyId_op); | |
| 5035 if (tmp == NULL) goto failed; | |
| 5036 res = obj2ast_unaryop(tmp, &op, arena); | |
| 5037 if (res != 0) goto failed; | |
| 5038 Py_XDECREF(tmp); | |
| 5039 tmp = NULL; | |
| 5040 } else { | |
| 5041 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp"); | |
| 5042 return 1; | |
| 5043 } | |
| 5044 if (_PyObject_HasAttrId(obj, &PyId_operand)) { | |
| 5045 int res; | |
| 5046 tmp = _PyObject_GetAttrId(obj, &PyId_operand); | |
| 5047 if (tmp == NULL) goto failed; | |
| 5048 res = obj2ast_expr(tmp, &operand, arena); | |
| 5049 if (res != 0) goto failed; | |
| 5050 Py_XDECREF(tmp); | |
| 5051 tmp = NULL; | |
| 5052 } else { | |
| 5053 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp"); | |
| 5054 return 1; | |
| 5055 } | |
| 5056 *out = UnaryOp(op, operand, lineno, col_offset, arena); | |
| 5057 if (*out == NULL) goto failed; | |
| 5058 return 0; | |
| 5059 } | |
| 5060 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); | |
| 5061 if (isinstance == -1) { | |
| 5062 return 1; | |
| 5063 } | |
| 5064 if (isinstance) { | |
| 5065 arguments_ty args; | |
| 5066 expr_ty body; | |
| 5067 | |
| 5068 if (_PyObject_HasAttrId(obj, &PyId_args)) { | |
| 5069 int res; | |
| 5070 tmp = _PyObject_GetAttrId(obj, &PyId_args); | |
| 5071 if (tmp == NULL) goto failed; | |
| 5072 res = obj2ast_arguments(tmp, &args, arena); | |
| 5073 if (res != 0) goto failed; | |
| 5074 Py_XDECREF(tmp); | |
| 5075 tmp = NULL; | |
| 5076 } else { | |
| 5077 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda"); | |
| 5078 return 1; | |
| 5079 } | |
| 5080 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 5081 int res; | |
| 5082 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 5083 if (tmp == NULL) goto failed; | |
| 5084 res = obj2ast_expr(tmp, &body, arena); | |
| 5085 if (res != 0) goto failed; | |
| 5086 Py_XDECREF(tmp); | |
| 5087 tmp = NULL; | |
| 5088 } else { | |
| 5089 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda"); | |
| 5090 return 1; | |
| 5091 } | |
| 5092 *out = Lambda(args, body, lineno, col_offset, arena); | |
| 5093 if (*out == NULL) goto failed; | |
| 5094 return 0; | |
| 5095 } | |
| 5096 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); | |
| 5097 if (isinstance == -1) { | |
| 5098 return 1; | |
| 5099 } | |
| 5100 if (isinstance) { | |
| 5101 expr_ty test; | |
| 5102 expr_ty body; | |
| 5103 expr_ty orelse; | |
| 5104 | |
| 5105 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 5106 int res; | |
| 5107 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 5108 if (tmp == NULL) goto failed; | |
| 5109 res = obj2ast_expr(tmp, &test, arena); | |
| 5110 if (res != 0) goto failed; | |
| 5111 Py_XDECREF(tmp); | |
| 5112 tmp = NULL; | |
| 5113 } else { | |
| 5114 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp"); | |
| 5115 return 1; | |
| 5116 } | |
| 5117 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 5118 int res; | |
| 5119 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 5120 if (tmp == NULL) goto failed; | |
| 5121 res = obj2ast_expr(tmp, &body, arena); | |
| 5122 if (res != 0) goto failed; | |
| 5123 Py_XDECREF(tmp); | |
| 5124 tmp = NULL; | |
| 5125 } else { | |
| 5126 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp"); | |
| 5127 return 1; | |
| 5128 } | |
| 5129 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 5130 int res; | |
| 5131 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 5132 if (tmp == NULL) goto failed; | |
| 5133 res = obj2ast_expr(tmp, &orelse, arena); | |
| 5134 if (res != 0) goto failed; | |
| 5135 Py_XDECREF(tmp); | |
| 5136 tmp = NULL; | |
| 5137 } else { | |
| 5138 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp"); | |
| 5139 return 1; | |
| 5140 } | |
| 5141 *out = IfExp(test, body, orelse, lineno, col_offset, arena); | |
| 5142 if (*out == NULL) goto failed; | |
| 5143 return 0; | |
| 5144 } | |
| 5145 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); | |
| 5146 if (isinstance == -1) { | |
| 5147 return 1; | |
| 5148 } | |
| 5149 if (isinstance) { | |
| 5150 asdl_seq* keys; | |
| 5151 asdl_seq* values; | |
| 5152 | |
| 5153 if (_PyObject_HasAttrId(obj, &PyId_keys)) { | |
| 5154 int res; | |
| 5155 Py_ssize_t len; | |
| 5156 Py_ssize_t i; | |
| 5157 tmp = _PyObject_GetAttrId(obj, &PyId_keys); | |
| 5158 if (tmp == NULL) goto failed; | |
| 5159 if (!PyList_Check(tmp)) { | |
| 5160 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5161 goto failed; | |
| 5162 } | |
| 5163 len = PyList_GET_SIZE(tmp); | |
| 5164 keys = asdl_seq_new(len, arena); | |
| 5165 if (keys == NULL) goto failed; | |
| 5166 for (i = 0; i < len; i++) { | |
| 5167 expr_ty value; | |
| 5168 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4930 if (res != 0) goto failed; | 5169 if (res != 0) goto failed; |
| 4931 Py_XDECREF(tmp); | 5170 asdl_seq_SET(keys, i, value); |
| 4932 tmp = NULL; | 5171 } |
| 4933 } else { | 5172 Py_XDECREF(tmp); |
| 4934 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr"); | 5173 tmp = NULL; |
| 4935 return 1; | 5174 } else { |
| 4936 } | 5175 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict"); |
| 4937 isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type); | 5176 return 1; |
| 4938 if (isinstance == -1) { | 5177 } |
| 4939 return 1; | 5178 if (_PyObject_HasAttrId(obj, &PyId_values)) { |
| 4940 } | 5179 int res; |
| 4941 if (isinstance) { | 5180 Py_ssize_t len; |
| 4942 boolop_ty op; | 5181 Py_ssize_t i; |
| 4943 asdl_seq* values; | 5182 tmp = _PyObject_GetAttrId(obj, &PyId_values); |
| 4944 | 5183 if (tmp == NULL) goto failed; |
| 4945 if (_PyObject_HasAttrId(obj, &PyId_op)) { | 5184 if (!PyList_Check(tmp)) { |
| 4946 int res; | 5185 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 4947 tmp = _PyObject_GetAttrId(obj, &PyId_op); | 5186 goto failed; |
| 4948 if (tmp == NULL) goto failed; | 5187 } |
| 4949 res = obj2ast_boolop(tmp, &op, arena); | 5188 len = PyList_GET_SIZE(tmp); |
| 4950 if (res != 0) goto failed; | 5189 values = asdl_seq_new(len, arena); |
| 4951 Py_XDECREF(tmp); | 5190 if (values == NULL) goto failed; |
| 4952 tmp = NULL; | 5191 for (i = 0; i < len; i++) { |
| 4953 } else { | |
| 4954 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp"); | |
| 4955 return 1; | |
| 4956 } | |
| 4957 if (_PyObject_HasAttrId(obj, &PyId_values)) { | |
| 4958 int res; | |
| 4959 Py_ssize_t len; | |
| 4960 Py_ssize_t i; | |
| 4961 tmp = _PyObject_GetAttrId(obj, &PyId_values); | |
| 4962 if (tmp == NULL) goto failed; | |
| 4963 if (!PyList_Check(tmp)) { | |
| 4964 PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 4965 goto failed; | |
| 4966 } | |
| 4967 len = PyList_GET_SIZE(tmp); | |
| 4968 values = asdl_seq_new(len, arena); | |
| 4969 if (values == NULL) goto failed; | |
| 4970 for (i = 0; i < len; i++) { | |
| 4971 expr_ty value; | |
| 4972 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 4973 if (res != 0) goto failed; | |
| 4974 asdl_seq_SET(values, i, value); | |
| 4975 } | |
| 4976 Py_XDECREF(tmp); | |
| 4977 tmp = NULL; | |
| 4978 } else { | |
| 4979 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp"); | |
| 4980 return 1; | |
| 4981 } | |
| 4982 *out = BoolOp(op, values, lineno, col_offset, arena); | |
| 4983 if (*out == NULL) goto failed; | |
| 4984 return 0; | |
| 4985 } | |
| 4986 isinstance = PyObject_IsInstance(obj, (PyObject*)BinOp_type); | |
| 4987 if (isinstance == -1) { | |
| 4988 return 1; | |
| 4989 } | |
| 4990 if (isinstance) { | |
| 4991 expr_ty left; | |
| 4992 operator_ty op; | |
| 4993 expr_ty right; | |
| 4994 | |
| 4995 if (_PyObject_HasAttrId(obj, &PyId_left)) { | |
| 4996 int res; | |
| 4997 tmp = _PyObject_GetAttrId(obj, &PyId_left); | |
| 4998 if (tmp == NULL) goto failed; | |
| 4999 res = obj2ast_expr(tmp, &left, arena); | |
| 5000 if (res != 0) goto failed; | |
| 5001 Py_XDECREF(tmp); | |
| 5002 tmp = NULL; | |
| 5003 } else { | |
| 5004 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp"); | |
| 5005 return 1; | |
| 5006 } | |
| 5007 if (_PyObject_HasAttrId(obj, &PyId_op)) { | |
| 5008 int res; | |
| 5009 tmp = _PyObject_GetAttrId(obj, &PyId_op); | |
| 5010 if (tmp == NULL) goto failed; | |
| 5011 res = obj2ast_operator(tmp, &op, arena); | |
| 5012 if (res != 0) goto failed; | |
| 5013 Py_XDECREF(tmp); | |
| 5014 tmp = NULL; | |
| 5015 } else { | |
| 5016 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp"); | |
| 5017 return 1; | |
| 5018 } | |
| 5019 if (_PyObject_HasAttrId(obj, &PyId_right)) { | |
| 5020 int res; | |
| 5021 tmp = _PyObject_GetAttrId(obj, &PyId_right); | |
| 5022 if (tmp == NULL) goto failed; | |
| 5023 res = obj2ast_expr(tmp, &right, arena); | |
| 5024 if (res != 0) goto failed; | |
| 5025 Py_XDECREF(tmp); | |
| 5026 tmp = NULL; | |
| 5027 } else { | |
| 5028 PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp"); | |
| 5029 return 1; | |
| 5030 } | |
| 5031 *out = BinOp(left, op, right, lineno, col_offset, arena); | |
| 5032 if (*out == NULL) goto failed; | |
| 5033 return 0; | |
| 5034 } | |
| 5035 isinstance = PyObject_IsInstance(obj, (PyObject*)UnaryOp_type); | |
| 5036 if (isinstance == -1) { | |
| 5037 return 1; | |
| 5038 } | |
| 5039 if (isinstance) { | |
| 5040 unaryop_ty op; | |
| 5041 expr_ty operand; | |
| 5042 | |
| 5043 if (_PyObject_HasAttrId(obj, &PyId_op)) { | |
| 5044 int res; | |
| 5045 tmp = _PyObject_GetAttrId(obj, &PyId_op); | |
| 5046 if (tmp == NULL) goto failed; | |
| 5047 res = obj2ast_unaryop(tmp, &op, arena); | |
| 5048 if (res != 0) goto failed; | |
| 5049 Py_XDECREF(tmp); | |
| 5050 tmp = NULL; | |
| 5051 } else { | |
| 5052 PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp"); | |
| 5053 return 1; | |
| 5054 } | |
| 5055 if (_PyObject_HasAttrId(obj, &PyId_operand)) { | |
| 5056 int res; | |
| 5057 tmp = _PyObject_GetAttrId(obj, &PyId_operand); | |
| 5058 if (tmp == NULL) goto failed; | |
| 5059 res = obj2ast_expr(tmp, &operand, arena); | |
| 5060 if (res != 0) goto failed; | |
| 5061 Py_XDECREF(tmp); | |
| 5062 tmp = NULL; | |
| 5063 } else { | |
| 5064 PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp"); | |
| 5065 return 1; | |
| 5066 } | |
| 5067 *out = UnaryOp(op, operand, lineno, col_offset, arena); | |
| 5068 if (*out == NULL) goto failed; | |
| 5069 return 0; | |
| 5070 } | |
| 5071 isinstance = PyObject_IsInstance(obj, (PyObject*)Lambda_type); | |
| 5072 if (isinstance == -1) { | |
| 5073 return 1; | |
| 5074 } | |
| 5075 if (isinstance) { | |
| 5076 arguments_ty args; | |
| 5077 expr_ty body; | |
| 5078 | |
| 5079 if (_PyObject_HasAttrId(obj, &PyId_args)) { | |
| 5080 int res; | |
| 5081 tmp = _PyObject_GetAttrId(obj, &PyId_args); | |
| 5082 if (tmp == NULL) goto failed; | |
| 5083 res = obj2ast_arguments(tmp, &args, arena); | |
| 5084 if (res != 0) goto failed; | |
| 5085 Py_XDECREF(tmp); | |
| 5086 tmp = NULL; | |
| 5087 } else { | |
| 5088 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda"); | |
| 5089 return 1; | |
| 5090 } | |
| 5091 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 5092 int res; | |
| 5093 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 5094 if (tmp == NULL) goto failed; | |
| 5095 res = obj2ast_expr(tmp, &body, arena); | |
| 5096 if (res != 0) goto failed; | |
| 5097 Py_XDECREF(tmp); | |
| 5098 tmp = NULL; | |
| 5099 } else { | |
| 5100 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda"); | |
| 5101 return 1; | |
| 5102 } | |
| 5103 *out = Lambda(args, body, lineno, col_offset, arena); | |
| 5104 if (*out == NULL) goto failed; | |
| 5105 return 0; | |
| 5106 } | |
| 5107 isinstance = PyObject_IsInstance(obj, (PyObject*)IfExp_type); | |
| 5108 if (isinstance == -1) { | |
| 5109 return 1; | |
| 5110 } | |
| 5111 if (isinstance) { | |
| 5112 expr_ty test; | |
| 5113 expr_ty body; | |
| 5114 expr_ty orelse; | |
| 5115 | |
| 5116 if (_PyObject_HasAttrId(obj, &PyId_test)) { | |
| 5117 int res; | |
| 5118 tmp = _PyObject_GetAttrId(obj, &PyId_test); | |
| 5119 if (tmp == NULL) goto failed; | |
| 5120 res = obj2ast_expr(tmp, &test, arena); | |
| 5121 if (res != 0) goto failed; | |
| 5122 Py_XDECREF(tmp); | |
| 5123 tmp = NULL; | |
| 5124 } else { | |
| 5125 PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp"); | |
| 5126 return 1; | |
| 5127 } | |
| 5128 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 5129 int res; | |
| 5130 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 5131 if (tmp == NULL) goto failed; | |
| 5132 res = obj2ast_expr(tmp, &body, arena); | |
| 5133 if (res != 0) goto failed; | |
| 5134 Py_XDECREF(tmp); | |
| 5135 tmp = NULL; | |
| 5136 } else { | |
| 5137 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp"); | |
| 5138 return 1; | |
| 5139 } | |
| 5140 if (_PyObject_HasAttrId(obj, &PyId_orelse)) { | |
| 5141 int res; | |
| 5142 tmp = _PyObject_GetAttrId(obj, &PyId_orelse); | |
| 5143 if (tmp == NULL) goto failed; | |
| 5144 res = obj2ast_expr(tmp, &orelse, arena); | |
| 5145 if (res != 0) goto failed; | |
| 5146 Py_XDECREF(tmp); | |
| 5147 tmp = NULL; | |
| 5148 } else { | |
| 5149 PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp"); | |
| 5150 return 1; | |
| 5151 } | |
| 5152 *out = IfExp(test, body, orelse, lineno, col_offset, arena); | |
| 5153 if (*out == NULL) goto failed; | |
| 5154 return 0; | |
| 5155 } | |
| 5156 isinstance = PyObject_IsInstance(obj, (PyObject*)Dict_type); | |
| 5157 if (isinstance == -1) { | |
| 5158 return 1; | |
| 5159 } | |
| 5160 if (isinstance) { | |
| 5161 asdl_seq* keys; | |
| 5162 asdl_seq* values; | |
| 5163 | |
| 5164 if (_PyObject_HasAttrId(obj, &PyId_keys)) { | |
| 5165 int res; | |
| 5166 Py_ssize_t len; | |
| 5167 Py_ssize_t i; | |
| 5168 tmp = _PyObject_GetAttrId(obj, &PyId_keys); | |
| 5169 if (tmp == NULL) goto failed; | |
| 5170 if (!PyList_Check(tmp)) { | |
| 5171 PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5172 goto failed; | |
| 5173 } | |
| 5174 len = PyList_GET_SIZE(tmp); | |
| 5175 keys = asdl_seq_new(len, arena); | |
| 5176 if (keys == NULL) goto failed; | |
| 5177 for (i = 0; i < len; i++) { | |
| 5178 expr_ty value; | |
| 5179 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5180 if (res != 0) goto failed; | |
| 5181 asdl_seq_SET(keys, i, value); | |
| 5182 } | |
| 5183 Py_XDECREF(tmp); | |
| 5184 tmp = NULL; | |
| 5185 } else { | |
| 5186 PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict"); | |
| 5187 return 1; | |
| 5188 } | |
| 5189 if (_PyObject_HasAttrId(obj, &PyId_values)) { | |
| 5190 int res; | |
| 5191 Py_ssize_t len; | |
| 5192 Py_ssize_t i; | |
| 5193 tmp = _PyObject_GetAttrId(obj, &PyId_values); | |
| 5194 if (tmp == NULL) goto failed; | |
| 5195 if (!PyList_Check(tmp)) { | |
| 5196 PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5197 goto failed; | |
| 5198 } | |
| 5199 len = PyList_GET_SIZE(tmp); | |
| 5200 values = asdl_seq_new(len, arena); | |
| 5201 if (values == NULL) goto failed; | |
| 5202 for (i = 0; i < len; i++) { | |
| 5203 expr_ty value; | |
| 5204 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5205 if (res != 0) goto failed; | |
| 5206 asdl_seq_SET(values, i, value); | |
| 5207 } | |
| 5208 Py_XDECREF(tmp); | |
| 5209 tmp = NULL; | |
| 5210 } else { | |
| 5211 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict"); | |
| 5212 return 1; | |
| 5213 } | |
| 5214 *out = Dict(keys, values, lineno, col_offset, arena); | |
| 5215 if (*out == NULL) goto failed; | |
| 5216 return 0; | |
| 5217 } | |
| 5218 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type); | |
| 5219 if (isinstance == -1) { | |
| 5220 return 1; | |
| 5221 } | |
| 5222 if (isinstance) { | |
| 5223 asdl_seq* elts; | |
| 5224 | |
| 5225 if (_PyObject_HasAttrId(obj, &PyId_elts)) { | |
| 5226 int res; | |
| 5227 Py_ssize_t len; | |
| 5228 Py_ssize_t i; | |
| 5229 tmp = _PyObject_GetAttrId(obj, &PyId_elts); | |
| 5230 if (tmp == NULL) goto failed; | |
| 5231 if (!PyList_Check(tmp)) { | |
| 5232 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5233 goto failed; | |
| 5234 } | |
| 5235 len = PyList_GET_SIZE(tmp); | |
| 5236 elts = asdl_seq_new(len, arena); | |
| 5237 if (elts == NULL) goto failed; | |
| 5238 for (i = 0; i < len; i++) { | |
| 5239 expr_ty value; | |
| 5240 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5241 if (res != 0) goto failed; | |
| 5242 asdl_seq_SET(elts, i, value); | |
| 5243 } | |
| 5244 Py_XDECREF(tmp); | |
| 5245 tmp = NULL; | |
| 5246 } else { | |
| 5247 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set"); | |
| 5248 return 1; | |
| 5249 } | |
| 5250 *out = Set(elts, lineno, col_offset, arena); | |
| 5251 if (*out == NULL) goto failed; | |
| 5252 return 0; | |
| 5253 } | |
| 5254 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type); | |
| 5255 if (isinstance == -1) { | |
| 5256 return 1; | |
| 5257 } | |
| 5258 if (isinstance) { | |
| 5259 expr_ty elt; | |
| 5260 asdl_seq* generators; | |
| 5261 | |
| 5262 if (_PyObject_HasAttrId(obj, &PyId_elt)) { | |
| 5263 int res; | |
| 5264 tmp = _PyObject_GetAttrId(obj, &PyId_elt); | |
| 5265 if (tmp == NULL) goto failed; | |
| 5266 res = obj2ast_expr(tmp, &elt, arena); | |
| 5267 if (res != 0) goto failed; | |
| 5268 Py_XDECREF(tmp); | |
| 5269 tmp = NULL; | |
| 5270 } else { | |
| 5271 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp"); | |
| 5272 return 1; | |
| 5273 } | |
| 5274 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5275 int res; | |
| 5276 Py_ssize_t len; | |
| 5277 Py_ssize_t i; | |
| 5278 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5279 if (tmp == NULL) goto failed; | |
| 5280 if (!PyList_Check(tmp)) { | |
| 5281 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5282 goto failed; | |
| 5283 } | |
| 5284 len = PyList_GET_SIZE(tmp); | |
| 5285 generators = asdl_seq_new(len, arena); | |
| 5286 if (generators == NULL) goto failed; | |
| 5287 for (i = 0; i < len; i++) { | |
| 5288 comprehension_ty value; | |
| 5289 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5290 if (res != 0) goto failed; | |
| 5291 asdl_seq_SET(generators, i, value); | |
| 5292 } | |
| 5293 Py_XDECREF(tmp); | |
| 5294 tmp = NULL; | |
| 5295 } else { | |
| 5296 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp"); | |
| 5297 return 1; | |
| 5298 } | |
| 5299 *out = ListComp(elt, generators, lineno, col_offset, arena); | |
| 5300 if (*out == NULL) goto failed; | |
| 5301 return 0; | |
| 5302 } | |
| 5303 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type); | |
| 5304 if (isinstance == -1) { | |
| 5305 return 1; | |
| 5306 } | |
| 5307 if (isinstance) { | |
| 5308 expr_ty elt; | |
| 5309 asdl_seq* generators; | |
| 5310 | |
| 5311 if (_PyObject_HasAttrId(obj, &PyId_elt)) { | |
| 5312 int res; | |
| 5313 tmp = _PyObject_GetAttrId(obj, &PyId_elt); | |
| 5314 if (tmp == NULL) goto failed; | |
| 5315 res = obj2ast_expr(tmp, &elt, arena); | |
| 5316 if (res != 0) goto failed; | |
| 5317 Py_XDECREF(tmp); | |
| 5318 tmp = NULL; | |
| 5319 } else { | |
| 5320 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp"); | |
| 5321 return 1; | |
| 5322 } | |
| 5323 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5324 int res; | |
| 5325 Py_ssize_t len; | |
| 5326 Py_ssize_t i; | |
| 5327 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5328 if (tmp == NULL) goto failed; | |
| 5329 if (!PyList_Check(tmp)) { | |
| 5330 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5331 goto failed; | |
| 5332 } | |
| 5333 len = PyList_GET_SIZE(tmp); | |
| 5334 generators = asdl_seq_new(len, arena); | |
| 5335 if (generators == NULL) goto failed; | |
| 5336 for (i = 0; i < len; i++) { | |
| 5337 comprehension_ty value; | |
| 5338 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5339 if (res != 0) goto failed; | |
| 5340 asdl_seq_SET(generators, i, value); | |
| 5341 } | |
| 5342 Py_XDECREF(tmp); | |
| 5343 tmp = NULL; | |
| 5344 } else { | |
| 5345 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp"); | |
| 5346 return 1; | |
| 5347 } | |
| 5348 *out = SetComp(elt, generators, lineno, col_offset, arena); | |
| 5349 if (*out == NULL) goto failed; | |
| 5350 return 0; | |
| 5351 } | |
| 5352 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type); | |
| 5353 if (isinstance == -1) { | |
| 5354 return 1; | |
| 5355 } | |
| 5356 if (isinstance) { | |
| 5357 expr_ty key; | |
| 5358 expr_ty value; | 5192 expr_ty value; |
| 5359 asdl_seq* generators; | 5193 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5360 | 5194 if (res != 0) goto failed; |
| 5361 if (_PyObject_HasAttrId(obj, &PyId_key)) { | 5195 asdl_seq_SET(values, i, value); |
| 5362 int res; | 5196 } |
| 5363 tmp = _PyObject_GetAttrId(obj, &PyId_key); | 5197 Py_XDECREF(tmp); |
| 5364 if (tmp == NULL) goto failed; | 5198 tmp = NULL; |
| 5365 res = obj2ast_expr(tmp, &key, arena); | 5199 } else { |
| 5366 if (res != 0) goto failed; | 5200 PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict"); |
| 5367 Py_XDECREF(tmp); | 5201 return 1; |
| 5368 tmp = NULL; | 5202 } |
| 5369 } else { | 5203 *out = Dict(keys, values, lineno, col_offset, arena); |
| 5370 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp"); | 5204 if (*out == NULL) goto failed; |
| 5371 return 1; | 5205 return 0; |
| 5372 } | 5206 } |
| 5373 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 5207 isinstance = PyObject_IsInstance(obj, (PyObject*)Set_type); |
| 5374 int res; | 5208 if (isinstance == -1) { |
| 5375 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 5209 return 1; |
| 5376 if (tmp == NULL) goto failed; | 5210 } |
| 5377 res = obj2ast_expr(tmp, &value, arena); | 5211 if (isinstance) { |
| 5378 if (res != 0) goto failed; | 5212 asdl_seq* elts; |
| 5379 Py_XDECREF(tmp); | 5213 |
| 5380 tmp = NULL; | 5214 if (_PyObject_HasAttrId(obj, &PyId_elts)) { |
| 5381 } else { | 5215 int res; |
| 5382 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp"); | 5216 Py_ssize_t len; |
| 5383 return 1; | 5217 Py_ssize_t i; |
| 5384 } | 5218 tmp = _PyObject_GetAttrId(obj, &PyId_elts); |
| 5385 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | 5219 if (tmp == NULL) goto failed; |
| 5386 int res; | 5220 if (!PyList_Check(tmp)) { |
| 5387 Py_ssize_t len; | 5221 PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 5388 Py_ssize_t i; | 5222 goto failed; |
| 5389 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | 5223 } |
| 5390 if (tmp == NULL) goto failed; | 5224 len = PyList_GET_SIZE(tmp); |
| 5391 if (!PyList_Check(tmp)) { | 5225 elts = asdl_seq_new(len, arena); |
| 5392 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 5226 if (elts == NULL) goto failed; |
| 5393 goto failed; | 5227 for (i = 0; i < len; i++) { |
| 5394 } | |
| 5395 len = PyList_GET_SIZE(tmp); | |
| 5396 generators = asdl_seq_new(len, arena); | |
| 5397 if (generators == NULL) goto failed; | |
| 5398 for (i = 0; i < len; i++) { | |
| 5399 comprehension_ty value; | |
| 5400 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5401 if (res != 0) goto failed; | |
| 5402 asdl_seq_SET(generators, i, value); | |
| 5403 } | |
| 5404 Py_XDECREF(tmp); | |
| 5405 tmp = NULL; | |
| 5406 } else { | |
| 5407 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp"); | |
| 5408 return 1; | |
| 5409 } | |
| 5410 *out = DictComp(key, value, generators, lineno, col_offset, | |
| 5411 arena); | |
| 5412 if (*out == NULL) goto failed; | |
| 5413 return 0; | |
| 5414 } | |
| 5415 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type); | |
| 5416 if (isinstance == -1) { | |
| 5417 return 1; | |
| 5418 } | |
| 5419 if (isinstance) { | |
| 5420 expr_ty elt; | |
| 5421 asdl_seq* generators; | |
| 5422 | |
| 5423 if (_PyObject_HasAttrId(obj, &PyId_elt)) { | |
| 5424 int res; | |
| 5425 tmp = _PyObject_GetAttrId(obj, &PyId_elt); | |
| 5426 if (tmp == NULL) goto failed; | |
| 5427 res = obj2ast_expr(tmp, &elt, arena); | |
| 5428 if (res != 0) goto failed; | |
| 5429 Py_XDECREF(tmp); | |
| 5430 tmp = NULL; | |
| 5431 } else { | |
| 5432 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp"); | |
| 5433 return 1; | |
| 5434 } | |
| 5435 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5436 int res; | |
| 5437 Py_ssize_t len; | |
| 5438 Py_ssize_t i; | |
| 5439 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5440 if (tmp == NULL) goto failed; | |
| 5441 if (!PyList_Check(tmp)) { | |
| 5442 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5443 goto failed; | |
| 5444 } | |
| 5445 len = PyList_GET_SIZE(tmp); | |
| 5446 generators = asdl_seq_new(len, arena); | |
| 5447 if (generators == NULL) goto failed; | |
| 5448 for (i = 0; i < len; i++) { | |
| 5449 comprehension_ty value; | |
| 5450 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5451 if (res != 0) goto failed; | |
| 5452 asdl_seq_SET(generators, i, value); | |
| 5453 } | |
| 5454 Py_XDECREF(tmp); | |
| 5455 tmp = NULL; | |
| 5456 } else { | |
| 5457 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp"); | |
| 5458 return 1; | |
| 5459 } | |
| 5460 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); | |
| 5461 if (*out == NULL) goto failed; | |
| 5462 return 0; | |
| 5463 } | |
| 5464 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type); | |
| 5465 if (isinstance == -1) { | |
| 5466 return 1; | |
| 5467 } | |
| 5468 if (isinstance) { | |
| 5469 expr_ty value; | 5228 expr_ty value; |
| 5470 | 5229 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5471 if (exists_not_none(obj, &PyId_value)) { | 5230 if (res != 0) goto failed; |
| 5472 int res; | 5231 asdl_seq_SET(elts, i, value); |
| 5473 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 5232 } |
| 5474 if (tmp == NULL) goto failed; | 5233 Py_XDECREF(tmp); |
| 5475 res = obj2ast_expr(tmp, &value, arena); | 5234 tmp = NULL; |
| 5476 if (res != 0) goto failed; | 5235 } else { |
| 5477 Py_XDECREF(tmp); | 5236 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set"); |
| 5478 tmp = NULL; | 5237 return 1; |
| 5479 } else { | 5238 } |
| 5480 value = NULL; | 5239 *out = Set(elts, lineno, col_offset, arena); |
| 5481 } | 5240 if (*out == NULL) goto failed; |
| 5482 *out = Yield(value, lineno, col_offset, arena); | 5241 return 0; |
| 5483 if (*out == NULL) goto failed; | 5242 } |
| 5484 return 0; | 5243 isinstance = PyObject_IsInstance(obj, (PyObject*)ListComp_type); |
| 5485 } | 5244 if (isinstance == -1) { |
| 5486 isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type); | 5245 return 1; |
| 5487 if (isinstance == -1) { | 5246 } |
| 5488 return 1; | 5247 if (isinstance) { |
| 5489 } | 5248 expr_ty elt; |
| 5490 if (isinstance) { | 5249 asdl_seq* generators; |
| 5250 | |
| 5251 if (_PyObject_HasAttrId(obj, &PyId_elt)) { | |
| 5252 int res; | |
| 5253 tmp = _PyObject_GetAttrId(obj, &PyId_elt); | |
| 5254 if (tmp == NULL) goto failed; | |
| 5255 res = obj2ast_expr(tmp, &elt, arena); | |
| 5256 if (res != 0) goto failed; | |
| 5257 Py_XDECREF(tmp); | |
| 5258 tmp = NULL; | |
| 5259 } else { | |
| 5260 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp"); | |
| 5261 return 1; | |
| 5262 } | |
| 5263 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5264 int res; | |
| 5265 Py_ssize_t len; | |
| 5266 Py_ssize_t i; | |
| 5267 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5268 if (tmp == NULL) goto failed; | |
| 5269 if (!PyList_Check(tmp)) { | |
| 5270 PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5271 goto failed; | |
| 5272 } | |
| 5273 len = PyList_GET_SIZE(tmp); | |
| 5274 generators = asdl_seq_new(len, arena); | |
| 5275 if (generators == NULL) goto failed; | |
| 5276 for (i = 0; i < len; i++) { | |
| 5277 comprehension_ty value; | |
| 5278 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5279 if (res != 0) goto failed; | |
| 5280 asdl_seq_SET(generators, i, value); | |
| 5281 } | |
| 5282 Py_XDECREF(tmp); | |
| 5283 tmp = NULL; | |
| 5284 } else { | |
| 5285 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp"); | |
| 5286 return 1; | |
| 5287 } | |
| 5288 *out = ListComp(elt, generators, lineno, col_offset, arena); | |
| 5289 if (*out == NULL) goto failed; | |
| 5290 return 0; | |
| 5291 } | |
| 5292 isinstance = PyObject_IsInstance(obj, (PyObject*)SetComp_type); | |
| 5293 if (isinstance == -1) { | |
| 5294 return 1; | |
| 5295 } | |
| 5296 if (isinstance) { | |
| 5297 expr_ty elt; | |
| 5298 asdl_seq* generators; | |
| 5299 | |
| 5300 if (_PyObject_HasAttrId(obj, &PyId_elt)) { | |
| 5301 int res; | |
| 5302 tmp = _PyObject_GetAttrId(obj, &PyId_elt); | |
| 5303 if (tmp == NULL) goto failed; | |
| 5304 res = obj2ast_expr(tmp, &elt, arena); | |
| 5305 if (res != 0) goto failed; | |
| 5306 Py_XDECREF(tmp); | |
| 5307 tmp = NULL; | |
| 5308 } else { | |
| 5309 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp"); | |
| 5310 return 1; | |
| 5311 } | |
| 5312 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5313 int res; | |
| 5314 Py_ssize_t len; | |
| 5315 Py_ssize_t i; | |
| 5316 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5317 if (tmp == NULL) goto failed; | |
| 5318 if (!PyList_Check(tmp)) { | |
| 5319 PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5320 goto failed; | |
| 5321 } | |
| 5322 len = PyList_GET_SIZE(tmp); | |
| 5323 generators = asdl_seq_new(len, arena); | |
| 5324 if (generators == NULL) goto failed; | |
| 5325 for (i = 0; i < len; i++) { | |
| 5326 comprehension_ty value; | |
| 5327 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5328 if (res != 0) goto failed; | |
| 5329 asdl_seq_SET(generators, i, value); | |
| 5330 } | |
| 5331 Py_XDECREF(tmp); | |
| 5332 tmp = NULL; | |
| 5333 } else { | |
| 5334 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp"); | |
| 5335 return 1; | |
| 5336 } | |
| 5337 *out = SetComp(elt, generators, lineno, col_offset, arena); | |
| 5338 if (*out == NULL) goto failed; | |
| 5339 return 0; | |
| 5340 } | |
| 5341 isinstance = PyObject_IsInstance(obj, (PyObject*)DictComp_type); | |
| 5342 if (isinstance == -1) { | |
| 5343 return 1; | |
| 5344 } | |
| 5345 if (isinstance) { | |
| 5346 expr_ty key; | |
| 5347 expr_ty value; | |
| 5348 asdl_seq* generators; | |
| 5349 | |
| 5350 if (_PyObject_HasAttrId(obj, &PyId_key)) { | |
| 5351 int res; | |
| 5352 tmp = _PyObject_GetAttrId(obj, &PyId_key); | |
| 5353 if (tmp == NULL) goto failed; | |
| 5354 res = obj2ast_expr(tmp, &key, arena); | |
| 5355 if (res != 0) goto failed; | |
| 5356 Py_XDECREF(tmp); | |
| 5357 tmp = NULL; | |
| 5358 } else { | |
| 5359 PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp"); | |
| 5360 return 1; | |
| 5361 } | |
| 5362 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5363 int res; | |
| 5364 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5365 if (tmp == NULL) goto failed; | |
| 5366 res = obj2ast_expr(tmp, &value, arena); | |
| 5367 if (res != 0) goto failed; | |
| 5368 Py_XDECREF(tmp); | |
| 5369 tmp = NULL; | |
| 5370 } else { | |
| 5371 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp"); | |
| 5372 return 1; | |
| 5373 } | |
| 5374 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5375 int res; | |
| 5376 Py_ssize_t len; | |
| 5377 Py_ssize_t i; | |
| 5378 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5379 if (tmp == NULL) goto failed; | |
| 5380 if (!PyList_Check(tmp)) { | |
| 5381 PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5382 goto failed; | |
| 5383 } | |
| 5384 len = PyList_GET_SIZE(tmp); | |
| 5385 generators = asdl_seq_new(len, arena); | |
| 5386 if (generators == NULL) goto failed; | |
| 5387 for (i = 0; i < len; i++) { | |
| 5388 comprehension_ty value; | |
| 5389 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5390 if (res != 0) goto failed; | |
| 5391 asdl_seq_SET(generators, i, value); | |
| 5392 } | |
| 5393 Py_XDECREF(tmp); | |
| 5394 tmp = NULL; | |
| 5395 } else { | |
| 5396 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp"); | |
| 5397 return 1; | |
| 5398 } | |
| 5399 *out = DictComp(key, value, generators, lineno, col_offset, arena); | |
| 5400 if (*out == NULL) goto failed; | |
| 5401 return 0; | |
| 5402 } | |
| 5403 isinstance = PyObject_IsInstance(obj, (PyObject*)GeneratorExp_type); | |
| 5404 if (isinstance == -1) { | |
| 5405 return 1; | |
| 5406 } | |
| 5407 if (isinstance) { | |
| 5408 expr_ty elt; | |
| 5409 asdl_seq* generators; | |
| 5410 | |
| 5411 if (_PyObject_HasAttrId(obj, &PyId_elt)) { | |
| 5412 int res; | |
| 5413 tmp = _PyObject_GetAttrId(obj, &PyId_elt); | |
| 5414 if (tmp == NULL) goto failed; | |
| 5415 res = obj2ast_expr(tmp, &elt, arena); | |
| 5416 if (res != 0) goto failed; | |
| 5417 Py_XDECREF(tmp); | |
| 5418 tmp = NULL; | |
| 5419 } else { | |
| 5420 PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp"); | |
| 5421 return 1; | |
| 5422 } | |
| 5423 if (_PyObject_HasAttrId(obj, &PyId_generators)) { | |
| 5424 int res; | |
| 5425 Py_ssize_t len; | |
| 5426 Py_ssize_t i; | |
| 5427 tmp = _PyObject_GetAttrId(obj, &PyId_generators); | |
| 5428 if (tmp == NULL) goto failed; | |
| 5429 if (!PyList_Check(tmp)) { | |
| 5430 PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5431 goto failed; | |
| 5432 } | |
| 5433 len = PyList_GET_SIZE(tmp); | |
| 5434 generators = asdl_seq_new(len, arena); | |
| 5435 if (generators == NULL) goto failed; | |
| 5436 for (i = 0; i < len; i++) { | |
| 5437 comprehension_ty value; | |
| 5438 res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5439 if (res != 0) goto failed; | |
| 5440 asdl_seq_SET(generators, i, value); | |
| 5441 } | |
| 5442 Py_XDECREF(tmp); | |
| 5443 tmp = NULL; | |
| 5444 } else { | |
| 5445 PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp"); | |
| 5446 return 1; | |
| 5447 } | |
| 5448 *out = GeneratorExp(elt, generators, lineno, col_offset, arena); | |
| 5449 if (*out == NULL) goto failed; | |
| 5450 return 0; | |
| 5451 } | |
| 5452 isinstance = PyObject_IsInstance(obj, (PyObject*)Yield_type); | |
| 5453 if (isinstance == -1) { | |
| 5454 return 1; | |
| 5455 } | |
| 5456 if (isinstance) { | |
| 5457 expr_ty value; | |
| 5458 | |
| 5459 if (exists_not_none(obj, &PyId_value)) { | |
| 5460 int res; | |
| 5461 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5462 if (tmp == NULL) goto failed; | |
| 5463 res = obj2ast_expr(tmp, &value, arena); | |
| 5464 if (res != 0) goto failed; | |
| 5465 Py_XDECREF(tmp); | |
| 5466 tmp = NULL; | |
| 5467 } else { | |
| 5468 value = NULL; | |
| 5469 } | |
| 5470 *out = Yield(value, lineno, col_offset, arena); | |
| 5471 if (*out == NULL) goto failed; | |
| 5472 return 0; | |
| 5473 } | |
| 5474 isinstance = PyObject_IsInstance(obj, (PyObject*)YieldFrom_type); | |
| 5475 if (isinstance == -1) { | |
| 5476 return 1; | |
| 5477 } | |
| 5478 if (isinstance) { | |
| 5479 expr_ty value; | |
| 5480 | |
| 5481 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5482 int res; | |
| 5483 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5484 if (tmp == NULL) goto failed; | |
| 5485 res = obj2ast_expr(tmp, &value, arena); | |
| 5486 if (res != 0) goto failed; | |
| 5487 Py_XDECREF(tmp); | |
| 5488 tmp = NULL; | |
| 5489 } else { | |
| 5490 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom"); | |
| 5491 return 1; | |
| 5492 } | |
| 5493 *out = YieldFrom(value, lineno, col_offset, arena); | |
| 5494 if (*out == NULL) goto failed; | |
| 5495 return 0; | |
| 5496 } | |
| 5497 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); | |
| 5498 if (isinstance == -1) { | |
| 5499 return 1; | |
| 5500 } | |
| 5501 if (isinstance) { | |
| 5502 expr_ty left; | |
| 5503 asdl_int_seq* ops; | |
| 5504 asdl_seq* comparators; | |
| 5505 | |
| 5506 if (_PyObject_HasAttrId(obj, &PyId_left)) { | |
| 5507 int res; | |
| 5508 tmp = _PyObject_GetAttrId(obj, &PyId_left); | |
| 5509 if (tmp == NULL) goto failed; | |
| 5510 res = obj2ast_expr(tmp, &left, arena); | |
| 5511 if (res != 0) goto failed; | |
| 5512 Py_XDECREF(tmp); | |
| 5513 tmp = NULL; | |
| 5514 } else { | |
| 5515 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare"); | |
| 5516 return 1; | |
| 5517 } | |
| 5518 if (_PyObject_HasAttrId(obj, &PyId_ops)) { | |
| 5519 int res; | |
| 5520 Py_ssize_t len; | |
| 5521 Py_ssize_t i; | |
| 5522 tmp = _PyObject_GetAttrId(obj, &PyId_ops); | |
| 5523 if (tmp == NULL) goto failed; | |
| 5524 if (!PyList_Check(tmp)) { | |
| 5525 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5526 goto failed; | |
| 5527 } | |
| 5528 len = PyList_GET_SIZE(tmp); | |
| 5529 ops = asdl_int_seq_new(len, arena); | |
| 5530 if (ops == NULL) goto failed; | |
| 5531 for (i = 0; i < len; i++) { | |
| 5532 cmpop_ty value; | |
| 5533 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5534 if (res != 0) goto failed; | |
| 5535 asdl_seq_SET(ops, i, value); | |
| 5536 } | |
| 5537 Py_XDECREF(tmp); | |
| 5538 tmp = NULL; | |
| 5539 } else { | |
| 5540 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare"); | |
| 5541 return 1; | |
| 5542 } | |
| 5543 if (_PyObject_HasAttrId(obj, &PyId_comparators)) { | |
| 5544 int res; | |
| 5545 Py_ssize_t len; | |
| 5546 Py_ssize_t i; | |
| 5547 tmp = _PyObject_GetAttrId(obj, &PyId_comparators); | |
| 5548 if (tmp == NULL) goto failed; | |
| 5549 if (!PyList_Check(tmp)) { | |
| 5550 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5551 goto failed; | |
| 5552 } | |
| 5553 len = PyList_GET_SIZE(tmp); | |
| 5554 comparators = asdl_seq_new(len, arena); | |
| 5555 if (comparators == NULL) goto failed; | |
| 5556 for (i = 0; i < len; i++) { | |
| 5491 expr_ty value; | 5557 expr_ty value; |
| 5492 | 5558 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5493 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 5559 if (res != 0) goto failed; |
| 5494 int res; | 5560 asdl_seq_SET(comparators, i, value); |
| 5495 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 5561 } |
| 5496 if (tmp == NULL) goto failed; | 5562 Py_XDECREF(tmp); |
| 5497 res = obj2ast_expr(tmp, &value, arena); | 5563 tmp = NULL; |
| 5498 if (res != 0) goto failed; | 5564 } else { |
| 5499 Py_XDECREF(tmp); | 5565 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare"); |
| 5500 tmp = NULL; | 5566 return 1; |
| 5501 } else { | 5567 } |
| 5502 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom"); | 5568 *out = Compare(left, ops, comparators, lineno, col_offset, arena); |
| 5503 return 1; | 5569 if (*out == NULL) goto failed; |
| 5504 } | 5570 return 0; |
| 5505 *out = YieldFrom(value, lineno, col_offset, arena); | 5571 } |
| 5506 if (*out == NULL) goto failed; | 5572 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type); |
| 5507 return 0; | 5573 if (isinstance == -1) { |
| 5508 } | 5574 return 1; |
| 5509 isinstance = PyObject_IsInstance(obj, (PyObject*)Compare_type); | 5575 } |
| 5510 if (isinstance == -1) { | 5576 if (isinstance) { |
| 5511 return 1; | 5577 expr_ty func; |
| 5512 } | 5578 asdl_seq* args; |
| 5513 if (isinstance) { | 5579 asdl_seq* keywords; |
| 5514 expr_ty left; | 5580 expr_ty starargs; |
| 5515 asdl_int_seq* ops; | 5581 expr_ty kwargs; |
| 5516 asdl_seq* comparators; | 5582 |
| 5517 | 5583 if (_PyObject_HasAttrId(obj, &PyId_func)) { |
| 5518 if (_PyObject_HasAttrId(obj, &PyId_left)) { | 5584 int res; |
| 5519 int res; | 5585 tmp = _PyObject_GetAttrId(obj, &PyId_func); |
| 5520 tmp = _PyObject_GetAttrId(obj, &PyId_left); | 5586 if (tmp == NULL) goto failed; |
| 5521 if (tmp == NULL) goto failed; | 5587 res = obj2ast_expr(tmp, &func, arena); |
| 5522 res = obj2ast_expr(tmp, &left, arena); | 5588 if (res != 0) goto failed; |
| 5523 if (res != 0) goto failed; | 5589 Py_XDECREF(tmp); |
| 5524 Py_XDECREF(tmp); | 5590 tmp = NULL; |
| 5525 tmp = NULL; | 5591 } else { |
| 5526 } else { | 5592 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call"); |
| 5527 PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare"); | 5593 return 1; |
| 5528 return 1; | 5594 } |
| 5529 } | 5595 if (_PyObject_HasAttrId(obj, &PyId_args)) { |
| 5530 if (_PyObject_HasAttrId(obj, &PyId_ops)) { | 5596 int res; |
| 5531 int res; | 5597 Py_ssize_t len; |
| 5532 Py_ssize_t len; | 5598 Py_ssize_t i; |
| 5533 Py_ssize_t i; | 5599 tmp = _PyObject_GetAttrId(obj, &PyId_args); |
| 5534 tmp = _PyObject_GetAttrId(obj, &PyId_ops); | 5600 if (tmp == NULL) goto failed; |
| 5535 if (tmp == NULL) goto failed; | 5601 if (!PyList_Check(tmp)) { |
| 5536 if (!PyList_Check(tmp)) { | 5602 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 5537 PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 5603 goto failed; |
| 5538 goto failed; | 5604 } |
| 5539 } | 5605 len = PyList_GET_SIZE(tmp); |
| 5540 len = PyList_GET_SIZE(tmp); | 5606 args = asdl_seq_new(len, arena); |
| 5541 ops = asdl_int_seq_new(len, arena); | 5607 if (args == NULL) goto failed; |
| 5542 if (ops == NULL) goto failed; | 5608 for (i = 0; i < len; i++) { |
| 5543 for (i = 0; i < len; i++) { | |
| 5544 cmpop_ty value; | |
| 5545 res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5546 if (res != 0) goto failed; | |
| 5547 asdl_seq_SET(ops, i, value); | |
| 5548 } | |
| 5549 Py_XDECREF(tmp); | |
| 5550 tmp = NULL; | |
| 5551 } else { | |
| 5552 PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare"); | |
| 5553 return 1; | |
| 5554 } | |
| 5555 if (_PyObject_HasAttrId(obj, &PyId_comparators)) { | |
| 5556 int res; | |
| 5557 Py_ssize_t len; | |
| 5558 Py_ssize_t i; | |
| 5559 tmp = _PyObject_GetAttrId(obj, &PyId_comparators); | |
| 5560 if (tmp == NULL) goto failed; | |
| 5561 if (!PyList_Check(tmp)) { | |
| 5562 PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5563 goto failed; | |
| 5564 } | |
| 5565 len = PyList_GET_SIZE(tmp); | |
| 5566 comparators = asdl_seq_new(len, arena); | |
| 5567 if (comparators == NULL) goto failed; | |
| 5568 for (i = 0; i < len; i++) { | |
| 5569 expr_ty value; | |
| 5570 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5571 if (res != 0) goto failed; | |
| 5572 asdl_seq_SET(comparators, i, value); | |
| 5573 } | |
| 5574 Py_XDECREF(tmp); | |
| 5575 tmp = NULL; | |
| 5576 } else { | |
| 5577 PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare"); | |
| 5578 return 1; | |
| 5579 } | |
| 5580 *out = Compare(left, ops, comparators, lineno, col_offset, | |
| 5581 arena); | |
| 5582 if (*out == NULL) goto failed; | |
| 5583 return 0; | |
| 5584 } | |
| 5585 isinstance = PyObject_IsInstance(obj, (PyObject*)Call_type); | |
| 5586 if (isinstance == -1) { | |
| 5587 return 1; | |
| 5588 } | |
| 5589 if (isinstance) { | |
| 5590 expr_ty func; | |
| 5591 asdl_seq* args; | |
| 5592 asdl_seq* keywords; | |
| 5593 expr_ty starargs; | |
| 5594 expr_ty kwargs; | |
| 5595 | |
| 5596 if (_PyObject_HasAttrId(obj, &PyId_func)) { | |
| 5597 int res; | |
| 5598 tmp = _PyObject_GetAttrId(obj, &PyId_func); | |
| 5599 if (tmp == NULL) goto failed; | |
| 5600 res = obj2ast_expr(tmp, &func, arena); | |
| 5601 if (res != 0) goto failed; | |
| 5602 Py_XDECREF(tmp); | |
| 5603 tmp = NULL; | |
| 5604 } else { | |
| 5605 PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call"); | |
| 5606 return 1; | |
| 5607 } | |
| 5608 if (_PyObject_HasAttrId(obj, &PyId_args)) { | |
| 5609 int res; | |
| 5610 Py_ssize_t len; | |
| 5611 Py_ssize_t i; | |
| 5612 tmp = _PyObject_GetAttrId(obj, &PyId_args); | |
| 5613 if (tmp == NULL) goto failed; | |
| 5614 if (!PyList_Check(tmp)) { | |
| 5615 PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5616 goto failed; | |
| 5617 } | |
| 5618 len = PyList_GET_SIZE(tmp); | |
| 5619 args = asdl_seq_new(len, arena); | |
| 5620 if (args == NULL) goto failed; | |
| 5621 for (i = 0; i < len; i++) { | |
| 5622 expr_ty value; | |
| 5623 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5624 if (res != 0) goto failed; | |
| 5625 asdl_seq_SET(args, i, value); | |
| 5626 } | |
| 5627 Py_XDECREF(tmp); | |
| 5628 tmp = NULL; | |
| 5629 } else { | |
| 5630 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call"); | |
| 5631 return 1; | |
| 5632 } | |
| 5633 if (_PyObject_HasAttrId(obj, &PyId_keywords)) { | |
| 5634 int res; | |
| 5635 Py_ssize_t len; | |
| 5636 Py_ssize_t i; | |
| 5637 tmp = _PyObject_GetAttrId(obj, &PyId_keywords); | |
| 5638 if (tmp == NULL) goto failed; | |
| 5639 if (!PyList_Check(tmp)) { | |
| 5640 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5641 goto failed; | |
| 5642 } | |
| 5643 len = PyList_GET_SIZE(tmp); | |
| 5644 keywords = asdl_seq_new(len, arena); | |
| 5645 if (keywords == NULL) goto failed; | |
| 5646 for (i = 0; i < len; i++) { | |
| 5647 keyword_ty value; | |
| 5648 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5649 if (res != 0) goto failed; | |
| 5650 asdl_seq_SET(keywords, i, value); | |
| 5651 } | |
| 5652 Py_XDECREF(tmp); | |
| 5653 tmp = NULL; | |
| 5654 } else { | |
| 5655 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call"); | |
| 5656 return 1; | |
| 5657 } | |
| 5658 if (exists_not_none(obj, &PyId_starargs)) { | |
| 5659 int res; | |
| 5660 tmp = _PyObject_GetAttrId(obj, &PyId_starargs); | |
| 5661 if (tmp == NULL) goto failed; | |
| 5662 res = obj2ast_expr(tmp, &starargs, arena); | |
| 5663 if (res != 0) goto failed; | |
| 5664 Py_XDECREF(tmp); | |
| 5665 tmp = NULL; | |
| 5666 } else { | |
| 5667 starargs = NULL; | |
| 5668 } | |
| 5669 if (exists_not_none(obj, &PyId_kwargs)) { | |
| 5670 int res; | |
| 5671 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs); | |
| 5672 if (tmp == NULL) goto failed; | |
| 5673 res = obj2ast_expr(tmp, &kwargs, arena); | |
| 5674 if (res != 0) goto failed; | |
| 5675 Py_XDECREF(tmp); | |
| 5676 tmp = NULL; | |
| 5677 } else { | |
| 5678 kwargs = NULL; | |
| 5679 } | |
| 5680 *out = Call(func, args, keywords, starargs, kwargs, lineno, | |
| 5681 col_offset, arena); | |
| 5682 if (*out == NULL) goto failed; | |
| 5683 return 0; | |
| 5684 } | |
| 5685 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type); | |
| 5686 if (isinstance == -1) { | |
| 5687 return 1; | |
| 5688 } | |
| 5689 if (isinstance) { | |
| 5690 object n; | |
| 5691 | |
| 5692 if (_PyObject_HasAttrId(obj, &PyId_n)) { | |
| 5693 int res; | |
| 5694 tmp = _PyObject_GetAttrId(obj, &PyId_n); | |
| 5695 if (tmp == NULL) goto failed; | |
| 5696 res = obj2ast_object(tmp, &n, arena); | |
| 5697 if (res != 0) goto failed; | |
| 5698 Py_XDECREF(tmp); | |
| 5699 tmp = NULL; | |
| 5700 } else { | |
| 5701 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num"); | |
| 5702 return 1; | |
| 5703 } | |
| 5704 *out = Num(n, lineno, col_offset, arena); | |
| 5705 if (*out == NULL) goto failed; | |
| 5706 return 0; | |
| 5707 } | |
| 5708 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type); | |
| 5709 if (isinstance == -1) { | |
| 5710 return 1; | |
| 5711 } | |
| 5712 if (isinstance) { | |
| 5713 string s; | |
| 5714 | |
| 5715 if (_PyObject_HasAttrId(obj, &PyId_s)) { | |
| 5716 int res; | |
| 5717 tmp = _PyObject_GetAttrId(obj, &PyId_s); | |
| 5718 if (tmp == NULL) goto failed; | |
| 5719 res = obj2ast_string(tmp, &s, arena); | |
| 5720 if (res != 0) goto failed; | |
| 5721 Py_XDECREF(tmp); | |
| 5722 tmp = NULL; | |
| 5723 } else { | |
| 5724 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str"); | |
| 5725 return 1; | |
| 5726 } | |
| 5727 *out = Str(s, lineno, col_offset, arena); | |
| 5728 if (*out == NULL) goto failed; | |
| 5729 return 0; | |
| 5730 } | |
| 5731 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type); | |
| 5732 if (isinstance == -1) { | |
| 5733 return 1; | |
| 5734 } | |
| 5735 if (isinstance) { | |
| 5736 bytes s; | |
| 5737 | |
| 5738 if (_PyObject_HasAttrId(obj, &PyId_s)) { | |
| 5739 int res; | |
| 5740 tmp = _PyObject_GetAttrId(obj, &PyId_s); | |
| 5741 if (tmp == NULL) goto failed; | |
| 5742 res = obj2ast_bytes(tmp, &s, arena); | |
| 5743 if (res != 0) goto failed; | |
| 5744 Py_XDECREF(tmp); | |
| 5745 tmp = NULL; | |
| 5746 } else { | |
| 5747 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes"); | |
| 5748 return 1; | |
| 5749 } | |
| 5750 *out = Bytes(s, lineno, col_offset, arena); | |
| 5751 if (*out == NULL) goto failed; | |
| 5752 return 0; | |
| 5753 } | |
| 5754 isinstance = PyObject_IsInstance(obj, (PyObject*)NameConstant_type); | |
| 5755 if (isinstance == -1) { | |
| 5756 return 1; | |
| 5757 } | |
| 5758 if (isinstance) { | |
| 5759 singleton value; | |
| 5760 | |
| 5761 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5762 int res; | |
| 5763 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5764 if (tmp == NULL) goto failed; | |
| 5765 res = obj2ast_singleton(tmp, &value, arena); | |
| 5766 if (res != 0) goto failed; | |
| 5767 Py_XDECREF(tmp); | |
| 5768 tmp = NULL; | |
| 5769 } else { | |
| 5770 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NameConstant"); | |
| 5771 return 1; | |
| 5772 } | |
| 5773 *out = NameConstant(value, lineno, col_offset, arena); | |
| 5774 if (*out == NULL) goto failed; | |
| 5775 return 0; | |
| 5776 } | |
| 5777 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type); | |
| 5778 if (isinstance == -1) { | |
| 5779 return 1; | |
| 5780 } | |
| 5781 if (isinstance) { | |
| 5782 | |
| 5783 *out = Ellipsis(lineno, col_offset, arena); | |
| 5784 if (*out == NULL) goto failed; | |
| 5785 return 0; | |
| 5786 } | |
| 5787 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type); | |
| 5788 if (isinstance == -1) { | |
| 5789 return 1; | |
| 5790 } | |
| 5791 if (isinstance) { | |
| 5792 expr_ty value; | 5609 expr_ty value; |
| 5793 identifier attr; | 5610 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5794 expr_context_ty ctx; | 5611 if (res != 0) goto failed; |
| 5795 | 5612 asdl_seq_SET(args, i, value); |
| 5796 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 5613 } |
| 5797 int res; | 5614 Py_XDECREF(tmp); |
| 5798 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 5615 tmp = NULL; |
| 5799 if (tmp == NULL) goto failed; | 5616 } else { |
| 5800 res = obj2ast_expr(tmp, &value, arena); | 5617 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call"); |
| 5801 if (res != 0) goto failed; | 5618 return 1; |
| 5802 Py_XDECREF(tmp); | 5619 } |
| 5803 tmp = NULL; | 5620 if (_PyObject_HasAttrId(obj, &PyId_keywords)) { |
| 5804 } else { | 5621 int res; |
| 5805 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute"); | 5622 Py_ssize_t len; |
| 5806 return 1; | 5623 Py_ssize_t i; |
| 5807 } | 5624 tmp = _PyObject_GetAttrId(obj, &PyId_keywords); |
| 5808 if (_PyObject_HasAttrId(obj, &PyId_attr)) { | 5625 if (tmp == NULL) goto failed; |
| 5809 int res; | 5626 if (!PyList_Check(tmp)) { |
| 5810 tmp = _PyObject_GetAttrId(obj, &PyId_attr); | 5627 PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 5811 if (tmp == NULL) goto failed; | 5628 goto failed; |
| 5812 res = obj2ast_identifier(tmp, &attr, arena); | 5629 } |
| 5813 if (res != 0) goto failed; | 5630 len = PyList_GET_SIZE(tmp); |
| 5814 Py_XDECREF(tmp); | 5631 keywords = asdl_seq_new(len, arena); |
| 5815 tmp = NULL; | 5632 if (keywords == NULL) goto failed; |
| 5816 } else { | 5633 for (i = 0; i < len; i++) { |
| 5817 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute"); | 5634 keyword_ty value; |
| 5818 return 1; | 5635 res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5819 } | 5636 if (res != 0) goto failed; |
| 5820 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | 5637 asdl_seq_SET(keywords, i, value); |
| 5821 int res; | 5638 } |
| 5822 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | 5639 Py_XDECREF(tmp); |
| 5823 if (tmp == NULL) goto failed; | 5640 tmp = NULL; |
| 5824 res = obj2ast_expr_context(tmp, &ctx, arena); | 5641 } else { |
| 5825 if (res != 0) goto failed; | 5642 PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call"); |
| 5826 Py_XDECREF(tmp); | 5643 return 1; |
| 5827 tmp = NULL; | 5644 } |
| 5828 } else { | 5645 if (exists_not_none(obj, &PyId_starargs)) { |
| 5829 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute"); | 5646 int res; |
| 5830 return 1; | 5647 tmp = _PyObject_GetAttrId(obj, &PyId_starargs); |
| 5831 } | 5648 if (tmp == NULL) goto failed; |
| 5832 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); | 5649 res = obj2ast_expr(tmp, &starargs, arena); |
| 5833 if (*out == NULL) goto failed; | 5650 if (res != 0) goto failed; |
| 5834 return 0; | 5651 Py_XDECREF(tmp); |
| 5835 } | 5652 tmp = NULL; |
| 5836 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); | 5653 } else { |
| 5837 if (isinstance == -1) { | 5654 starargs = NULL; |
| 5838 return 1; | 5655 } |
| 5839 } | 5656 if (exists_not_none(obj, &PyId_kwargs)) { |
| 5840 if (isinstance) { | 5657 int res; |
| 5658 tmp = _PyObject_GetAttrId(obj, &PyId_kwargs); | |
| 5659 if (tmp == NULL) goto failed; | |
| 5660 res = obj2ast_expr(tmp, &kwargs, arena); | |
| 5661 if (res != 0) goto failed; | |
| 5662 Py_XDECREF(tmp); | |
| 5663 tmp = NULL; | |
| 5664 } else { | |
| 5665 kwargs = NULL; | |
| 5666 } | |
| 5667 *out = Call(func, args, keywords, starargs, kwargs, lineno, col_offset, | |
| 5668 arena); | |
| 5669 if (*out == NULL) goto failed; | |
| 5670 return 0; | |
| 5671 } | |
| 5672 isinstance = PyObject_IsInstance(obj, (PyObject*)Num_type); | |
| 5673 if (isinstance == -1) { | |
| 5674 return 1; | |
| 5675 } | |
| 5676 if (isinstance) { | |
| 5677 object n; | |
| 5678 | |
| 5679 if (_PyObject_HasAttrId(obj, &PyId_n)) { | |
| 5680 int res; | |
| 5681 tmp = _PyObject_GetAttrId(obj, &PyId_n); | |
| 5682 if (tmp == NULL) goto failed; | |
| 5683 res = obj2ast_object(tmp, &n, arena); | |
| 5684 if (res != 0) goto failed; | |
| 5685 Py_XDECREF(tmp); | |
| 5686 tmp = NULL; | |
| 5687 } else { | |
| 5688 PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num"); | |
| 5689 return 1; | |
| 5690 } | |
| 5691 *out = Num(n, lineno, col_offset, arena); | |
| 5692 if (*out == NULL) goto failed; | |
| 5693 return 0; | |
| 5694 } | |
| 5695 isinstance = PyObject_IsInstance(obj, (PyObject*)Str_type); | |
| 5696 if (isinstance == -1) { | |
| 5697 return 1; | |
| 5698 } | |
| 5699 if (isinstance) { | |
| 5700 string s; | |
| 5701 | |
| 5702 if (_PyObject_HasAttrId(obj, &PyId_s)) { | |
| 5703 int res; | |
| 5704 tmp = _PyObject_GetAttrId(obj, &PyId_s); | |
| 5705 if (tmp == NULL) goto failed; | |
| 5706 res = obj2ast_string(tmp, &s, arena); | |
| 5707 if (res != 0) goto failed; | |
| 5708 Py_XDECREF(tmp); | |
| 5709 tmp = NULL; | |
| 5710 } else { | |
| 5711 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str"); | |
| 5712 return 1; | |
| 5713 } | |
| 5714 *out = Str(s, lineno, col_offset, arena); | |
| 5715 if (*out == NULL) goto failed; | |
| 5716 return 0; | |
| 5717 } | |
| 5718 isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type); | |
| 5719 if (isinstance == -1) { | |
| 5720 return 1; | |
| 5721 } | |
| 5722 if (isinstance) { | |
| 5723 bytes s; | |
| 5724 | |
| 5725 if (_PyObject_HasAttrId(obj, &PyId_s)) { | |
| 5726 int res; | |
| 5727 tmp = _PyObject_GetAttrId(obj, &PyId_s); | |
| 5728 if (tmp == NULL) goto failed; | |
| 5729 res = obj2ast_bytes(tmp, &s, arena); | |
| 5730 if (res != 0) goto failed; | |
| 5731 Py_XDECREF(tmp); | |
| 5732 tmp = NULL; | |
| 5733 } else { | |
| 5734 PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes"); | |
| 5735 return 1; | |
| 5736 } | |
| 5737 *out = Bytes(s, lineno, col_offset, arena); | |
| 5738 if (*out == NULL) goto failed; | |
| 5739 return 0; | |
| 5740 } | |
| 5741 isinstance = PyObject_IsInstance(obj, (PyObject*)NameConstant_type); | |
| 5742 if (isinstance == -1) { | |
| 5743 return 1; | |
| 5744 } | |
| 5745 if (isinstance) { | |
| 5746 singleton value; | |
| 5747 | |
| 5748 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5749 int res; | |
| 5750 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5751 if (tmp == NULL) goto failed; | |
| 5752 res = obj2ast_singleton(tmp, &value, arena); | |
| 5753 if (res != 0) goto failed; | |
| 5754 Py_XDECREF(tmp); | |
| 5755 tmp = NULL; | |
| 5756 } else { | |
| 5757 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NameConstant"); | |
| 5758 return 1; | |
| 5759 } | |
| 5760 *out = NameConstant(value, lineno, col_offset, arena); | |
| 5761 if (*out == NULL) goto failed; | |
| 5762 return 0; | |
| 5763 } | |
| 5764 isinstance = PyObject_IsInstance(obj, (PyObject*)Ellipsis_type); | |
| 5765 if (isinstance == -1) { | |
| 5766 return 1; | |
| 5767 } | |
| 5768 if (isinstance) { | |
| 5769 | |
| 5770 *out = Ellipsis(lineno, col_offset, arena); | |
| 5771 if (*out == NULL) goto failed; | |
| 5772 return 0; | |
| 5773 } | |
| 5774 isinstance = PyObject_IsInstance(obj, (PyObject*)Attribute_type); | |
| 5775 if (isinstance == -1) { | |
| 5776 return 1; | |
| 5777 } | |
| 5778 if (isinstance) { | |
| 5779 expr_ty value; | |
| 5780 identifier attr; | |
| 5781 expr_context_ty ctx; | |
| 5782 | |
| 5783 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5784 int res; | |
| 5785 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5786 if (tmp == NULL) goto failed; | |
| 5787 res = obj2ast_expr(tmp, &value, arena); | |
| 5788 if (res != 0) goto failed; | |
| 5789 Py_XDECREF(tmp); | |
| 5790 tmp = NULL; | |
| 5791 } else { | |
| 5792 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute"); | |
| 5793 return 1; | |
| 5794 } | |
| 5795 if (_PyObject_HasAttrId(obj, &PyId_attr)) { | |
| 5796 int res; | |
| 5797 tmp = _PyObject_GetAttrId(obj, &PyId_attr); | |
| 5798 if (tmp == NULL) goto failed; | |
| 5799 res = obj2ast_identifier(tmp, &attr, arena); | |
| 5800 if (res != 0) goto failed; | |
| 5801 Py_XDECREF(tmp); | |
| 5802 tmp = NULL; | |
| 5803 } else { | |
| 5804 PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute"); | |
| 5805 return 1; | |
| 5806 } | |
| 5807 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 5808 int res; | |
| 5809 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 5810 if (tmp == NULL) goto failed; | |
| 5811 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 5812 if (res != 0) goto failed; | |
| 5813 Py_XDECREF(tmp); | |
| 5814 tmp = NULL; | |
| 5815 } else { | |
| 5816 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute"); | |
| 5817 return 1; | |
| 5818 } | |
| 5819 *out = Attribute(value, attr, ctx, lineno, col_offset, arena); | |
| 5820 if (*out == NULL) goto failed; | |
| 5821 return 0; | |
| 5822 } | |
| 5823 isinstance = PyObject_IsInstance(obj, (PyObject*)Subscript_type); | |
| 5824 if (isinstance == -1) { | |
| 5825 return 1; | |
| 5826 } | |
| 5827 if (isinstance) { | |
| 5828 expr_ty value; | |
| 5829 slice_ty slice; | |
| 5830 expr_context_ty ctx; | |
| 5831 | |
| 5832 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5833 int res; | |
| 5834 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5835 if (tmp == NULL) goto failed; | |
| 5836 res = obj2ast_expr(tmp, &value, arena); | |
| 5837 if (res != 0) goto failed; | |
| 5838 Py_XDECREF(tmp); | |
| 5839 tmp = NULL; | |
| 5840 } else { | |
| 5841 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript"); | |
| 5842 return 1; | |
| 5843 } | |
| 5844 if (_PyObject_HasAttrId(obj, &PyId_slice)) { | |
| 5845 int res; | |
| 5846 tmp = _PyObject_GetAttrId(obj, &PyId_slice); | |
| 5847 if (tmp == NULL) goto failed; | |
| 5848 res = obj2ast_slice(tmp, &slice, arena); | |
| 5849 if (res != 0) goto failed; | |
| 5850 Py_XDECREF(tmp); | |
| 5851 tmp = NULL; | |
| 5852 } else { | |
| 5853 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript"); | |
| 5854 return 1; | |
| 5855 } | |
| 5856 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 5857 int res; | |
| 5858 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 5859 if (tmp == NULL) goto failed; | |
| 5860 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 5861 if (res != 0) goto failed; | |
| 5862 Py_XDECREF(tmp); | |
| 5863 tmp = NULL; | |
| 5864 } else { | |
| 5865 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript"); | |
| 5866 return 1; | |
| 5867 } | |
| 5868 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); | |
| 5869 if (*out == NULL) goto failed; | |
| 5870 return 0; | |
| 5871 } | |
| 5872 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type); | |
| 5873 if (isinstance == -1) { | |
| 5874 return 1; | |
| 5875 } | |
| 5876 if (isinstance) { | |
| 5877 expr_ty value; | |
| 5878 expr_context_ty ctx; | |
| 5879 | |
| 5880 if (_PyObject_HasAttrId(obj, &PyId_value)) { | |
| 5881 int res; | |
| 5882 tmp = _PyObject_GetAttrId(obj, &PyId_value); | |
| 5883 if (tmp == NULL) goto failed; | |
| 5884 res = obj2ast_expr(tmp, &value, arena); | |
| 5885 if (res != 0) goto failed; | |
| 5886 Py_XDECREF(tmp); | |
| 5887 tmp = NULL; | |
| 5888 } else { | |
| 5889 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred"); | |
| 5890 return 1; | |
| 5891 } | |
| 5892 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 5893 int res; | |
| 5894 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 5895 if (tmp == NULL) goto failed; | |
| 5896 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 5897 if (res != 0) goto failed; | |
| 5898 Py_XDECREF(tmp); | |
| 5899 tmp = NULL; | |
| 5900 } else { | |
| 5901 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred"); | |
| 5902 return 1; | |
| 5903 } | |
| 5904 *out = Starred(value, ctx, lineno, col_offset, arena); | |
| 5905 if (*out == NULL) goto failed; | |
| 5906 return 0; | |
| 5907 } | |
| 5908 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); | |
| 5909 if (isinstance == -1) { | |
| 5910 return 1; | |
| 5911 } | |
| 5912 if (isinstance) { | |
| 5913 identifier id; | |
| 5914 expr_context_ty ctx; | |
| 5915 | |
| 5916 if (_PyObject_HasAttrId(obj, &PyId_id)) { | |
| 5917 int res; | |
| 5918 tmp = _PyObject_GetAttrId(obj, &PyId_id); | |
| 5919 if (tmp == NULL) goto failed; | |
| 5920 res = obj2ast_identifier(tmp, &id, arena); | |
| 5921 if (res != 0) goto failed; | |
| 5922 Py_XDECREF(tmp); | |
| 5923 tmp = NULL; | |
| 5924 } else { | |
| 5925 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name"); | |
| 5926 return 1; | |
| 5927 } | |
| 5928 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 5929 int res; | |
| 5930 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 5931 if (tmp == NULL) goto failed; | |
| 5932 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 5933 if (res != 0) goto failed; | |
| 5934 Py_XDECREF(tmp); | |
| 5935 tmp = NULL; | |
| 5936 } else { | |
| 5937 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name"); | |
| 5938 return 1; | |
| 5939 } | |
| 5940 *out = Name(id, ctx, lineno, col_offset, arena); | |
| 5941 if (*out == NULL) goto failed; | |
| 5942 return 0; | |
| 5943 } | |
| 5944 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type); | |
| 5945 if (isinstance == -1) { | |
| 5946 return 1; | |
| 5947 } | |
| 5948 if (isinstance) { | |
| 5949 asdl_seq* elts; | |
| 5950 expr_context_ty ctx; | |
| 5951 | |
| 5952 if (_PyObject_HasAttrId(obj, &PyId_elts)) { | |
| 5953 int res; | |
| 5954 Py_ssize_t len; | |
| 5955 Py_ssize_t i; | |
| 5956 tmp = _PyObject_GetAttrId(obj, &PyId_elts); | |
| 5957 if (tmp == NULL) goto failed; | |
| 5958 if (!PyList_Check(tmp)) { | |
| 5959 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5960 goto failed; | |
| 5961 } | |
| 5962 len = PyList_GET_SIZE(tmp); | |
| 5963 elts = asdl_seq_new(len, arena); | |
| 5964 if (elts == NULL) goto failed; | |
| 5965 for (i = 0; i < len; i++) { | |
| 5841 expr_ty value; | 5966 expr_ty value; |
| 5842 slice_ty slice; | 5967 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5843 expr_context_ty ctx; | 5968 if (res != 0) goto failed; |
| 5844 | 5969 asdl_seq_SET(elts, i, value); |
| 5845 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 5970 } |
| 5846 int res; | 5971 Py_XDECREF(tmp); |
| 5847 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 5972 tmp = NULL; |
| 5848 if (tmp == NULL) goto failed; | 5973 } else { |
| 5849 res = obj2ast_expr(tmp, &value, arena); | 5974 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List"); |
| 5850 if (res != 0) goto failed; | 5975 return 1; |
| 5851 Py_XDECREF(tmp); | 5976 } |
| 5852 tmp = NULL; | 5977 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
| 5853 } else { | 5978 int res; |
| 5854 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript"); | 5979 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
| 5855 return 1; | 5980 if (tmp == NULL) goto failed; |
| 5856 } | 5981 res = obj2ast_expr_context(tmp, &ctx, arena); |
| 5857 if (_PyObject_HasAttrId(obj, &PyId_slice)) { | 5982 if (res != 0) goto failed; |
| 5858 int res; | 5983 Py_XDECREF(tmp); |
| 5859 tmp = _PyObject_GetAttrId(obj, &PyId_slice); | 5984 tmp = NULL; |
| 5860 if (tmp == NULL) goto failed; | 5985 } else { |
| 5861 res = obj2ast_slice(tmp, &slice, arena); | 5986 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List"); |
| 5862 if (res != 0) goto failed; | 5987 return 1; |
| 5863 Py_XDECREF(tmp); | 5988 } |
| 5864 tmp = NULL; | 5989 *out = List(elts, ctx, lineno, col_offset, arena); |
| 5865 } else { | 5990 if (*out == NULL) goto failed; |
| 5866 PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript"); | 5991 return 0; |
| 5867 return 1; | 5992 } |
| 5868 } | 5993 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type); |
| 5869 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | 5994 if (isinstance == -1) { |
| 5870 int res; | 5995 return 1; |
| 5871 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | 5996 } |
| 5872 if (tmp == NULL) goto failed; | 5997 if (isinstance) { |
| 5873 res = obj2ast_expr_context(tmp, &ctx, arena); | 5998 asdl_seq* elts; |
| 5874 if (res != 0) goto failed; | 5999 expr_context_ty ctx; |
| 5875 Py_XDECREF(tmp); | 6000 |
| 5876 tmp = NULL; | 6001 if (_PyObject_HasAttrId(obj, &PyId_elts)) { |
| 5877 } else { | 6002 int res; |
| 5878 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript"); | 6003 Py_ssize_t len; |
| 5879 return 1; | 6004 Py_ssize_t i; |
| 5880 } | 6005 tmp = _PyObject_GetAttrId(obj, &PyId_elts); |
| 5881 *out = Subscript(value, slice, ctx, lineno, col_offset, arena); | 6006 if (tmp == NULL) goto failed; |
| 5882 if (*out == NULL) goto failed; | 6007 if (!PyList_Check(tmp)) { |
| 5883 return 0; | 6008 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 5884 } | 6009 goto failed; |
| 5885 isinstance = PyObject_IsInstance(obj, (PyObject*)Starred_type); | 6010 } |
| 5886 if (isinstance == -1) { | 6011 len = PyList_GET_SIZE(tmp); |
| 5887 return 1; | 6012 elts = asdl_seq_new(len, arena); |
| 5888 } | 6013 if (elts == NULL) goto failed; |
| 5889 if (isinstance) { | 6014 for (i = 0; i < len; i++) { |
| 5890 expr_ty value; | 6015 expr_ty value; |
| 5891 expr_context_ty ctx; | 6016 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 5892 | 6017 if (res != 0) goto failed; |
| 5893 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 6018 asdl_seq_SET(elts, i, value); |
| 5894 int res; | 6019 } |
| 5895 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 6020 Py_XDECREF(tmp); |
| 5896 if (tmp == NULL) goto failed; | 6021 tmp = NULL; |
| 5897 res = obj2ast_expr(tmp, &value, arena); | 6022 } else { |
| 5898 if (res != 0) goto failed; | 6023 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple"); |
| 5899 Py_XDECREF(tmp); | 6024 return 1; |
| 5900 tmp = NULL; | 6025 } |
| 5901 } else { | 6026 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { |
| 5902 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred"); | 6027 int res; |
| 5903 return 1; | 6028 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); |
| 5904 } | 6029 if (tmp == NULL) goto failed; |
| 5905 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | 6030 res = obj2ast_expr_context(tmp, &ctx, arena); |
| 5906 int res; | 6031 if (res != 0) goto failed; |
| 5907 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | 6032 Py_XDECREF(tmp); |
| 5908 if (tmp == NULL) goto failed; | 6033 tmp = NULL; |
| 5909 res = obj2ast_expr_context(tmp, &ctx, arena); | 6034 } else { |
| 5910 if (res != 0) goto failed; | 6035 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple"); |
| 5911 Py_XDECREF(tmp); | 6036 return 1; |
| 5912 tmp = NULL; | 6037 } |
| 5913 } else { | 6038 *out = Tuple(elts, ctx, lineno, col_offset, arena); |
| 5914 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred"); | 6039 if (*out == NULL) goto failed; |
| 5915 return 1; | 6040 return 0; |
| 5916 } | 6041 } |
| 5917 *out = Starred(value, ctx, lineno, col_offset, arena); | 6042 |
| 5918 if (*out == NULL) goto failed; | 6043 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj); |
| 5919 return 0; | 6044 failed: |
| 5920 } | 6045 Py_XDECREF(tmp); |
| 5921 isinstance = PyObject_IsInstance(obj, (PyObject*)Name_type); | 6046 return 1; |
| 5922 if (isinstance == -1) { | |
| 5923 return 1; | |
| 5924 } | |
| 5925 if (isinstance) { | |
| 5926 identifier id; | |
| 5927 expr_context_ty ctx; | |
| 5928 | |
| 5929 if (_PyObject_HasAttrId(obj, &PyId_id)) { | |
| 5930 int res; | |
| 5931 tmp = _PyObject_GetAttrId(obj, &PyId_id); | |
| 5932 if (tmp == NULL) goto failed; | |
| 5933 res = obj2ast_identifier(tmp, &id, arena); | |
| 5934 if (res != 0) goto failed; | |
| 5935 Py_XDECREF(tmp); | |
| 5936 tmp = NULL; | |
| 5937 } else { | |
| 5938 PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name"); | |
| 5939 return 1; | |
| 5940 } | |
| 5941 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 5942 int res; | |
| 5943 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 5944 if (tmp == NULL) goto failed; | |
| 5945 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 5946 if (res != 0) goto failed; | |
| 5947 Py_XDECREF(tmp); | |
| 5948 tmp = NULL; | |
| 5949 } else { | |
| 5950 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name"); | |
| 5951 return 1; | |
| 5952 } | |
| 5953 *out = Name(id, ctx, lineno, col_offset, arena); | |
| 5954 if (*out == NULL) goto failed; | |
| 5955 return 0; | |
| 5956 } | |
| 5957 isinstance = PyObject_IsInstance(obj, (PyObject*)List_type); | |
| 5958 if (isinstance == -1) { | |
| 5959 return 1; | |
| 5960 } | |
| 5961 if (isinstance) { | |
| 5962 asdl_seq* elts; | |
| 5963 expr_context_ty ctx; | |
| 5964 | |
| 5965 if (_PyObject_HasAttrId(obj, &PyId_elts)) { | |
| 5966 int res; | |
| 5967 Py_ssize_t len; | |
| 5968 Py_ssize_t i; | |
| 5969 tmp = _PyObject_GetAttrId(obj, &PyId_elts); | |
| 5970 if (tmp == NULL) goto failed; | |
| 5971 if (!PyList_Check(tmp)) { | |
| 5972 PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 5973 goto failed; | |
| 5974 } | |
| 5975 len = PyList_GET_SIZE(tmp); | |
| 5976 elts = asdl_seq_new(len, arena); | |
| 5977 if (elts == NULL) goto failed; | |
| 5978 for (i = 0; i < len; i++) { | |
| 5979 expr_ty value; | |
| 5980 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 5981 if (res != 0) goto failed; | |
| 5982 asdl_seq_SET(elts, i, value); | |
| 5983 } | |
| 5984 Py_XDECREF(tmp); | |
| 5985 tmp = NULL; | |
| 5986 } else { | |
| 5987 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List"); | |
| 5988 return 1; | |
| 5989 } | |
| 5990 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 5991 int res; | |
| 5992 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 5993 if (tmp == NULL) goto failed; | |
| 5994 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 5995 if (res != 0) goto failed; | |
| 5996 Py_XDECREF(tmp); | |
| 5997 tmp = NULL; | |
| 5998 } else { | |
| 5999 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List"); | |
| 6000 return 1; | |
| 6001 } | |
| 6002 *out = List(elts, ctx, lineno, col_offset, arena); | |
| 6003 if (*out == NULL) goto failed; | |
| 6004 return 0; | |
| 6005 } | |
| 6006 isinstance = PyObject_IsInstance(obj, (PyObject*)Tuple_type); | |
| 6007 if (isinstance == -1) { | |
| 6008 return 1; | |
| 6009 } | |
| 6010 if (isinstance) { | |
| 6011 asdl_seq* elts; | |
| 6012 expr_context_ty ctx; | |
| 6013 | |
| 6014 if (_PyObject_HasAttrId(obj, &PyId_elts)) { | |
| 6015 int res; | |
| 6016 Py_ssize_t len; | |
| 6017 Py_ssize_t i; | |
| 6018 tmp = _PyObject_GetAttrId(obj, &PyId_elts); | |
| 6019 if (tmp == NULL) goto failed; | |
| 6020 if (!PyList_Check(tmp)) { | |
| 6021 PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 6022 goto failed; | |
| 6023 } | |
| 6024 len = PyList_GET_SIZE(tmp); | |
| 6025 elts = asdl_seq_new(len, arena); | |
| 6026 if (elts == NULL) goto failed; | |
| 6027 for (i = 0; i < len; i++) { | |
| 6028 expr_ty value; | |
| 6029 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 6030 if (res != 0) goto failed; | |
| 6031 asdl_seq_SET(elts, i, value); | |
| 6032 } | |
| 6033 Py_XDECREF(tmp); | |
| 6034 tmp = NULL; | |
| 6035 } else { | |
| 6036 PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple"); | |
| 6037 return 1; | |
| 6038 } | |
| 6039 if (_PyObject_HasAttrId(obj, &PyId_ctx)) { | |
| 6040 int res; | |
| 6041 tmp = _PyObject_GetAttrId(obj, &PyId_ctx); | |
| 6042 if (tmp == NULL) goto failed; | |
| 6043 res = obj2ast_expr_context(tmp, &ctx, arena); | |
| 6044 if (res != 0) goto failed; | |
| 6045 Py_XDECREF(tmp); | |
| 6046 tmp = NULL; | |
| 6047 } else { | |
| 6048 PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple"); | |
| 6049 return 1; | |
| 6050 } | |
| 6051 *out = Tuple(elts, ctx, lineno, col_offset, arena); | |
| 6052 if (*out == NULL) goto failed; | |
| 6053 return 0; | |
| 6054 } | |
| 6055 | |
| 6056 PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj); | |
| 6057 failed: | |
| 6058 Py_XDECREF(tmp); | |
| 6059 return 1; | |
| 6060 } | 6047 } |
| 6061 | 6048 |
| 6062 int | 6049 int |
| 6063 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) | 6050 obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena) |
| 6064 { | 6051 { |
| 6065 int isinstance; | 6052 int isinstance; |
| 6066 | 6053 |
| 6067 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); | 6054 isinstance = PyObject_IsInstance(obj, (PyObject *)Load_type); |
| 6068 if (isinstance == -1) { | 6055 if (isinstance == -1) { |
| 6069 return 1; | 6056 return 1; |
| 6070 } | 6057 } |
| 6071 if (isinstance) { | 6058 if (isinstance) { |
| 6072 *out = Load; | 6059 *out = Load; |
| 6073 return 0; | 6060 return 0; |
| 6074 } | 6061 } |
| 6075 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); | 6062 isinstance = PyObject_IsInstance(obj, (PyObject *)Store_type); |
| 6076 if (isinstance == -1) { | 6063 if (isinstance == -1) { |
| 6077 return 1; | 6064 return 1; |
| 6078 } | 6065 } |
| 6079 if (isinstance) { | 6066 if (isinstance) { |
| 6080 *out = Store; | 6067 *out = Store; |
| 6081 return 0; | 6068 return 0; |
| 6082 } | 6069 } |
| 6083 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); | 6070 isinstance = PyObject_IsInstance(obj, (PyObject *)Del_type); |
| 6084 if (isinstance == -1) { | 6071 if (isinstance == -1) { |
| 6085 return 1; | 6072 return 1; |
| 6086 } | 6073 } |
| 6087 if (isinstance) { | 6074 if (isinstance) { |
| 6088 *out = Del; | 6075 *out = Del; |
| 6089 return 0; | 6076 return 0; |
| 6090 } | 6077 } |
| 6091 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); | 6078 isinstance = PyObject_IsInstance(obj, (PyObject *)AugLoad_type); |
| 6092 if (isinstance == -1) { | 6079 if (isinstance == -1) { |
| 6093 return 1; | 6080 return 1; |
| 6094 } | 6081 } |
| 6095 if (isinstance) { | 6082 if (isinstance) { |
| 6096 *out = AugLoad; | 6083 *out = AugLoad; |
| 6097 return 0; | 6084 return 0; |
| 6098 } | 6085 } |
| 6099 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); | 6086 isinstance = PyObject_IsInstance(obj, (PyObject *)AugStore_type); |
| 6100 if (isinstance == -1) { | 6087 if (isinstance == -1) { |
| 6101 return 1; | 6088 return 1; |
| 6102 } | 6089 } |
| 6103 if (isinstance) { | 6090 if (isinstance) { |
| 6104 *out = AugStore; | 6091 *out = AugStore; |
| 6105 return 0; | 6092 return 0; |
| 6106 } | 6093 } |
| 6107 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); | 6094 isinstance = PyObject_IsInstance(obj, (PyObject *)Param_type); |
| 6108 if (isinstance == -1) { | 6095 if (isinstance == -1) { |
| 6109 return 1; | 6096 return 1; |
| 6110 } | 6097 } |
| 6111 if (isinstance) { | 6098 if (isinstance) { |
| 6112 *out = Param; | 6099 *out = Param; |
| 6113 return 0; | 6100 return 0; |
| 6114 } | 6101 } |
| 6115 | 6102 |
| 6116 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj); | 6103 PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj); |
| 6117 return 1; | 6104 return 1; |
| 6118 } | 6105 } |
| 6119 | 6106 |
| 6120 int | 6107 int |
| 6121 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) | 6108 obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena) |
| 6122 { | 6109 { |
| 6123 int isinstance; | 6110 int isinstance; |
| 6124 | 6111 |
| 6125 PyObject *tmp = NULL; | 6112 PyObject *tmp = NULL; |
| 6126 | 6113 |
| 6127 if (obj == Py_None) { | 6114 if (obj == Py_None) { |
| 6128 *out = NULL; | 6115 *out = NULL; |
| 6129 return 0; | 6116 return 0; |
| 6130 } | 6117 } |
| 6131 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); | 6118 isinstance = PyObject_IsInstance(obj, (PyObject*)Slice_type); |
| 6132 if (isinstance == -1) { | 6119 if (isinstance == -1) { |
| 6133 return 1; | 6120 return 1; |
| 6134 } | 6121 } |
| 6135 if (isinstance) { | 6122 if (isinstance) { |
| 6136 expr_ty lower; | 6123 expr_ty lower; |
| 6137 expr_ty upper; | 6124 expr_ty upper; |
| 6138 expr_ty step; | 6125 expr_ty step; |
| 6139 | 6126 |
| 6140 if (exists_not_none(obj, &PyId_lower)) { | 6127 if (exists_not_none(obj, &PyId_lower)) { |
| 6141 int res; | 6128 int res; |
| 6142 tmp = _PyObject_GetAttrId(obj, &PyId_lower); | 6129 tmp = _PyObject_GetAttrId(obj, &PyId_lower); |
| 6143 if (tmp == NULL) goto failed; | 6130 if (tmp == NULL) goto failed; |
| 6144 res = obj2ast_expr(tmp, &lower, arena); | 6131 res = obj2ast_expr(tmp, &lower, arena); |
| 6145 if (res != 0) goto failed; | 6132 if (res != 0) goto failed; |
| 6146 Py_XDECREF(tmp); | 6133 Py_XDECREF(tmp); |
| 6147 tmp = NULL; | 6134 tmp = NULL; |
| 6148 } else { | 6135 } else { |
| 6149 lower = NULL; | 6136 lower = NULL; |
| 6150 } | 6137 } |
| 6151 if (exists_not_none(obj, &PyId_upper)) { | 6138 if (exists_not_none(obj, &PyId_upper)) { |
| 6152 int res; | 6139 int res; |
| 6153 tmp = _PyObject_GetAttrId(obj, &PyId_upper); | 6140 tmp = _PyObject_GetAttrId(obj, &PyId_upper); |
| 6154 if (tmp == NULL) goto failed; | 6141 if (tmp == NULL) goto failed; |
| 6155 res = obj2ast_expr(tmp, &upper, arena); | 6142 res = obj2ast_expr(tmp, &upper, arena); |
| 6156 if (res != 0) goto failed; | 6143 if (res != 0) goto failed; |
| 6157 Py_XDECREF(tmp); | 6144 Py_XDECREF(tmp); |
| 6158 tmp = NULL; | 6145 tmp = NULL; |
| 6159 } else { | 6146 } else { |
| 6160 upper = NULL; | 6147 upper = NULL; |
| 6161 } | 6148 } |
| 6162 if (exists_not_none(obj, &PyId_step)) { | 6149 if (exists_not_none(obj, &PyId_step)) { |
| 6163 int res; | 6150 int res; |
| 6164 tmp = _PyObject_GetAttrId(obj, &PyId_step); | 6151 tmp = _PyObject_GetAttrId(obj, &PyId_step); |
| 6165 if (tmp == NULL) goto failed; | 6152 if (tmp == NULL) goto failed; |
| 6166 res = obj2ast_expr(tmp, &step, arena); | 6153 res = obj2ast_expr(tmp, &step, arena); |
| 6167 if (res != 0) goto failed; | 6154 if (res != 0) goto failed; |
| 6168 Py_XDECREF(tmp); | 6155 Py_XDECREF(tmp); |
| 6169 tmp = NULL; | 6156 tmp = NULL; |
| 6170 } else { | 6157 } else { |
| 6171 step = NULL; | 6158 step = NULL; |
| 6172 } | 6159 } |
| 6173 *out = Slice(lower, upper, step, arena); | 6160 *out = Slice(lower, upper, step, arena); |
| 6174 if (*out == NULL) goto failed; | 6161 if (*out == NULL) goto failed; |
| 6175 return 0; | 6162 return 0; |
| 6176 } | 6163 } |
| 6177 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); | 6164 isinstance = PyObject_IsInstance(obj, (PyObject*)ExtSlice_type); |
| 6178 if (isinstance == -1) { | 6165 if (isinstance == -1) { |
| 6179 return 1; | 6166 return 1; |
| 6180 } | 6167 } |
| 6181 if (isinstance) { | 6168 if (isinstance) { |
| 6182 asdl_seq* dims; | 6169 asdl_seq* dims; |
| 6183 | 6170 |
| 6184 if (_PyObject_HasAttrId(obj, &PyId_dims)) { | 6171 if (_PyObject_HasAttrId(obj, &PyId_dims)) { |
| 6185 int res; | 6172 int res; |
| 6186 Py_ssize_t len; | 6173 Py_ssize_t len; |
| 6187 Py_ssize_t i; | 6174 Py_ssize_t i; |
| 6188 tmp = _PyObject_GetAttrId(obj, &PyId_dims); | 6175 tmp = _PyObject_GetAttrId(obj, &PyId_dims); |
| 6189 if (tmp == NULL) goto failed; | 6176 if (tmp == NULL) goto failed; |
| 6190 if (!PyList_Check(tmp)) { | 6177 if (!PyList_Check(tmp)) { |
| 6191 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 6178 PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 6192 goto failed; | 6179 goto failed; |
| 6193 } | 6180 } |
| 6194 len = PyList_GET_SIZE(tmp); | 6181 len = PyList_GET_SIZE(tmp); |
| 6195 dims = asdl_seq_new(len, arena); | 6182 dims = asdl_seq_new(len, arena); |
| 6196 if (dims == NULL) goto failed; | 6183 if (dims == NULL) goto failed; |
| 6197 for (i = 0; i < len; i++) { | 6184 for (i = 0; i < len; i++) { |
| 6198 slice_ty value; | 6185 slice_ty value; |
| 6199 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena); | 6186 res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena); |
| 6200 if (res != 0) goto failed; | 6187 if (res != 0) goto failed; |
| 6201 asdl_seq_SET(dims, i, value); | 6188 asdl_seq_SET(dims, i, value); |
| 6202 } | 6189 } |
| 6203 Py_XDECREF(tmp); | 6190 Py_XDECREF(tmp); |
| 6204 tmp = NULL; | 6191 tmp = NULL; |
| 6205 } else { | 6192 } else { |
| 6206 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice"); | 6193 PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice"); |
| 6207 return 1; | 6194 return 1; |
| 6208 } | 6195 } |
| 6209 *out = ExtSlice(dims, arena); | 6196 *out = ExtSlice(dims, arena); |
| 6210 if (*out == NULL) goto failed; | 6197 if (*out == NULL) goto failed; |
| 6211 return 0; | 6198 return 0; |
| 6212 } | 6199 } |
| 6213 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); | 6200 isinstance = PyObject_IsInstance(obj, (PyObject*)Index_type); |
| 6214 if (isinstance == -1) { | 6201 if (isinstance == -1) { |
| 6215 return 1; | 6202 return 1; |
| 6216 } | 6203 } |
| 6217 if (isinstance) { | 6204 if (isinstance) { |
| 6218 expr_ty value; | 6205 expr_ty value; |
| 6219 | 6206 |
| 6220 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 6207 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
| 6221 int res; | 6208 int res; |
| 6222 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 6209 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
| 6223 if (tmp == NULL) goto failed; | 6210 if (tmp == NULL) goto failed; |
| 6224 res = obj2ast_expr(tmp, &value, arena); | 6211 res = obj2ast_expr(tmp, &value, arena); |
| 6225 if (res != 0) goto failed; | 6212 if (res != 0) goto failed; |
| 6226 Py_XDECREF(tmp); | 6213 Py_XDECREF(tmp); |
| 6227 tmp = NULL; | 6214 tmp = NULL; |
| 6228 } else { | 6215 } else { |
| 6229 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index"); | 6216 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index"); |
| 6230 return 1; | 6217 return 1; |
| 6231 } | 6218 } |
| 6232 *out = Index(value, arena); | 6219 *out = Index(value, arena); |
| 6233 if (*out == NULL) goto failed; | 6220 if (*out == NULL) goto failed; |
| 6234 return 0; | 6221 return 0; |
| 6235 } | 6222 } |
| 6236 | 6223 |
| 6237 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj); | 6224 PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %R", obj); |
| 6238 failed: | 6225 failed: |
| 6239 Py_XDECREF(tmp); | 6226 Py_XDECREF(tmp); |
| 6240 return 1; | 6227 return 1; |
| 6241 } | 6228 } |
| 6242 | 6229 |
| 6243 int | 6230 int |
| 6244 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) | 6231 obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena) |
| 6245 { | 6232 { |
| 6246 int isinstance; | 6233 int isinstance; |
| 6247 | 6234 |
| 6248 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); | 6235 isinstance = PyObject_IsInstance(obj, (PyObject *)And_type); |
| 6249 if (isinstance == -1) { | 6236 if (isinstance == -1) { |
| 6250 return 1; | 6237 return 1; |
| 6251 } | 6238 } |
| 6252 if (isinstance) { | 6239 if (isinstance) { |
| 6253 *out = And; | 6240 *out = And; |
| 6254 return 0; | 6241 return 0; |
| 6255 } | 6242 } |
| 6256 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); | 6243 isinstance = PyObject_IsInstance(obj, (PyObject *)Or_type); |
| 6257 if (isinstance == -1) { | 6244 if (isinstance == -1) { |
| 6258 return 1; | 6245 return 1; |
| 6259 } | 6246 } |
| 6260 if (isinstance) { | 6247 if (isinstance) { |
| 6261 *out = Or; | 6248 *out = Or; |
| 6262 return 0; | 6249 return 0; |
| 6263 } | 6250 } |
| 6264 | 6251 |
| 6265 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj); | 6252 PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj); |
| 6266 return 1; | 6253 return 1; |
| 6267 } | 6254 } |
| 6268 | 6255 |
| 6269 int | 6256 int |
| 6270 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) | 6257 obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena) |
| 6271 { | 6258 { |
| 6272 int isinstance; | 6259 int isinstance; |
| 6273 | 6260 |
| 6274 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); | 6261 isinstance = PyObject_IsInstance(obj, (PyObject *)Add_type); |
| 6275 if (isinstance == -1) { | 6262 if (isinstance == -1) { |
| 6276 return 1; | 6263 return 1; |
| 6277 } | 6264 } |
| 6278 if (isinstance) { | 6265 if (isinstance) { |
| 6279 *out = Add; | 6266 *out = Add; |
| 6280 return 0; | 6267 return 0; |
| 6281 } | 6268 } |
| 6282 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); | 6269 isinstance = PyObject_IsInstance(obj, (PyObject *)Sub_type); |
| 6283 if (isinstance == -1) { | 6270 if (isinstance == -1) { |
| 6284 return 1; | 6271 return 1; |
| 6285 } | 6272 } |
| 6286 if (isinstance) { | 6273 if (isinstance) { |
| 6287 *out = Sub; | 6274 *out = Sub; |
| 6288 return 0; | 6275 return 0; |
| 6289 } | 6276 } |
| 6290 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); | 6277 isinstance = PyObject_IsInstance(obj, (PyObject *)Mult_type); |
| 6291 if (isinstance == -1) { | 6278 if (isinstance == -1) { |
| 6292 return 1; | 6279 return 1; |
| 6293 } | 6280 } |
| 6294 if (isinstance) { | 6281 if (isinstance) { |
| 6295 *out = Mult; | 6282 *out = Mult; |
| 6296 return 0; | 6283 return 0; |
| 6297 } | 6284 } |
| 6298 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); | 6285 isinstance = PyObject_IsInstance(obj, (PyObject *)Div_type); |
| 6299 if (isinstance == -1) { | 6286 if (isinstance == -1) { |
| 6300 return 1; | 6287 return 1; |
| 6301 } | 6288 } |
| 6302 if (isinstance) { | 6289 if (isinstance) { |
| 6303 *out = Div; | 6290 *out = Div; |
| 6304 return 0; | 6291 return 0; |
| 6305 } | 6292 } |
| 6306 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); | 6293 isinstance = PyObject_IsInstance(obj, (PyObject *)Mod_type); |
| 6307 if (isinstance == -1) { | 6294 if (isinstance == -1) { |
| 6308 return 1; | 6295 return 1; |
| 6309 } | 6296 } |
| 6310 if (isinstance) { | 6297 if (isinstance) { |
| 6311 *out = Mod; | 6298 *out = Mod; |
| 6312 return 0; | 6299 return 0; |
| 6313 } | 6300 } |
| 6314 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); | 6301 isinstance = PyObject_IsInstance(obj, (PyObject *)Pow_type); |
| 6315 if (isinstance == -1) { | 6302 if (isinstance == -1) { |
| 6316 return 1; | 6303 return 1; |
| 6317 } | 6304 } |
| 6318 if (isinstance) { | 6305 if (isinstance) { |
| 6319 *out = Pow; | 6306 *out = Pow; |
| 6320 return 0; | 6307 return 0; |
| 6321 } | 6308 } |
| 6322 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); | 6309 isinstance = PyObject_IsInstance(obj, (PyObject *)LShift_type); |
| 6323 if (isinstance == -1) { | 6310 if (isinstance == -1) { |
| 6324 return 1; | 6311 return 1; |
| 6325 } | 6312 } |
| 6326 if (isinstance) { | 6313 if (isinstance) { |
| 6327 *out = LShift; | 6314 *out = LShift; |
| 6328 return 0; | 6315 return 0; |
| 6329 } | 6316 } |
| 6330 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); | 6317 isinstance = PyObject_IsInstance(obj, (PyObject *)RShift_type); |
| 6331 if (isinstance == -1) { | 6318 if (isinstance == -1) { |
| 6332 return 1; | 6319 return 1; |
| 6333 } | 6320 } |
| 6334 if (isinstance) { | 6321 if (isinstance) { |
| 6335 *out = RShift; | 6322 *out = RShift; |
| 6336 return 0; | 6323 return 0; |
| 6337 } | 6324 } |
| 6338 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); | 6325 isinstance = PyObject_IsInstance(obj, (PyObject *)BitOr_type); |
| 6339 if (isinstance == -1) { | 6326 if (isinstance == -1) { |
| 6340 return 1; | 6327 return 1; |
| 6341 } | 6328 } |
| 6342 if (isinstance) { | 6329 if (isinstance) { |
| 6343 *out = BitOr; | 6330 *out = BitOr; |
| 6344 return 0; | 6331 return 0; |
| 6345 } | 6332 } |
| 6346 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); | 6333 isinstance = PyObject_IsInstance(obj, (PyObject *)BitXor_type); |
| 6347 if (isinstance == -1) { | 6334 if (isinstance == -1) { |
| 6348 return 1; | 6335 return 1; |
| 6349 } | 6336 } |
| 6350 if (isinstance) { | 6337 if (isinstance) { |
| 6351 *out = BitXor; | 6338 *out = BitXor; |
| 6352 return 0; | 6339 return 0; |
| 6353 } | 6340 } |
| 6354 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); | 6341 isinstance = PyObject_IsInstance(obj, (PyObject *)BitAnd_type); |
| 6355 if (isinstance == -1) { | 6342 if (isinstance == -1) { |
| 6356 return 1; | 6343 return 1; |
| 6357 } | 6344 } |
| 6358 if (isinstance) { | 6345 if (isinstance) { |
| 6359 *out = BitAnd; | 6346 *out = BitAnd; |
| 6360 return 0; | 6347 return 0; |
| 6361 } | 6348 } |
| 6362 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); | 6349 isinstance = PyObject_IsInstance(obj, (PyObject *)FloorDiv_type); |
| 6363 if (isinstance == -1) { | 6350 if (isinstance == -1) { |
| 6364 return 1; | 6351 return 1; |
| 6365 } | 6352 } |
| 6366 if (isinstance) { | 6353 if (isinstance) { |
| 6367 *out = FloorDiv; | 6354 *out = FloorDiv; |
| 6368 return 0; | 6355 return 0; |
| 6369 } | 6356 } |
| 6370 | 6357 |
| 6371 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj); | 6358 PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj); |
| 6372 return 1; | 6359 return 1; |
| 6373 } | 6360 } |
| 6374 | 6361 |
| 6375 int | 6362 int |
| 6376 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) | 6363 obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena) |
| 6377 { | 6364 { |
| 6378 int isinstance; | 6365 int isinstance; |
| 6379 | 6366 |
| 6380 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); | 6367 isinstance = PyObject_IsInstance(obj, (PyObject *)Invert_type); |
| 6381 if (isinstance == -1) { | 6368 if (isinstance == -1) { |
| 6382 return 1; | 6369 return 1; |
| 6383 } | 6370 } |
| 6384 if (isinstance) { | 6371 if (isinstance) { |
| 6385 *out = Invert; | 6372 *out = Invert; |
| 6386 return 0; | 6373 return 0; |
| 6387 } | 6374 } |
| 6388 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); | 6375 isinstance = PyObject_IsInstance(obj, (PyObject *)Not_type); |
| 6389 if (isinstance == -1) { | 6376 if (isinstance == -1) { |
| 6390 return 1; | 6377 return 1; |
| 6391 } | 6378 } |
| 6392 if (isinstance) { | 6379 if (isinstance) { |
| 6393 *out = Not; | 6380 *out = Not; |
| 6394 return 0; | 6381 return 0; |
| 6395 } | 6382 } |
| 6396 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); | 6383 isinstance = PyObject_IsInstance(obj, (PyObject *)UAdd_type); |
| 6397 if (isinstance == -1) { | 6384 if (isinstance == -1) { |
| 6398 return 1; | 6385 return 1; |
| 6399 } | 6386 } |
| 6400 if (isinstance) { | 6387 if (isinstance) { |
| 6401 *out = UAdd; | 6388 *out = UAdd; |
| 6402 return 0; | 6389 return 0; |
| 6403 } | 6390 } |
| 6404 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); | 6391 isinstance = PyObject_IsInstance(obj, (PyObject *)USub_type); |
| 6405 if (isinstance == -1) { | 6392 if (isinstance == -1) { |
| 6406 return 1; | 6393 return 1; |
| 6407 } | 6394 } |
| 6408 if (isinstance) { | 6395 if (isinstance) { |
| 6409 *out = USub; | 6396 *out = USub; |
| 6410 return 0; | 6397 return 0; |
| 6411 } | 6398 } |
| 6412 | 6399 |
| 6413 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj); | 6400 PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj); |
| 6414 return 1; | 6401 return 1; |
| 6415 } | 6402 } |
| 6416 | 6403 |
| 6417 int | 6404 int |
| 6418 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) | 6405 obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena) |
| 6419 { | 6406 { |
| 6420 int isinstance; | 6407 int isinstance; |
| 6421 | 6408 |
| 6422 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); | 6409 isinstance = PyObject_IsInstance(obj, (PyObject *)Eq_type); |
| 6423 if (isinstance == -1) { | 6410 if (isinstance == -1) { |
| 6424 return 1; | 6411 return 1; |
| 6425 } | 6412 } |
| 6426 if (isinstance) { | 6413 if (isinstance) { |
| 6427 *out = Eq; | 6414 *out = Eq; |
| 6428 return 0; | 6415 return 0; |
| 6429 } | 6416 } |
| 6430 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); | 6417 isinstance = PyObject_IsInstance(obj, (PyObject *)NotEq_type); |
| 6431 if (isinstance == -1) { | 6418 if (isinstance == -1) { |
| 6432 return 1; | 6419 return 1; |
| 6433 } | 6420 } |
| 6434 if (isinstance) { | 6421 if (isinstance) { |
| 6435 *out = NotEq; | 6422 *out = NotEq; |
| 6436 return 0; | 6423 return 0; |
| 6437 } | 6424 } |
| 6438 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); | 6425 isinstance = PyObject_IsInstance(obj, (PyObject *)Lt_type); |
| 6439 if (isinstance == -1) { | 6426 if (isinstance == -1) { |
| 6440 return 1; | 6427 return 1; |
| 6441 } | 6428 } |
| 6442 if (isinstance) { | 6429 if (isinstance) { |
| 6443 *out = Lt; | 6430 *out = Lt; |
| 6444 return 0; | 6431 return 0; |
| 6445 } | 6432 } |
| 6446 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); | 6433 isinstance = PyObject_IsInstance(obj, (PyObject *)LtE_type); |
| 6447 if (isinstance == -1) { | 6434 if (isinstance == -1) { |
| 6448 return 1; | 6435 return 1; |
| 6449 } | 6436 } |
| 6450 if (isinstance) { | 6437 if (isinstance) { |
| 6451 *out = LtE; | 6438 *out = LtE; |
| 6452 return 0; | 6439 return 0; |
| 6453 } | 6440 } |
| 6454 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); | 6441 isinstance = PyObject_IsInstance(obj, (PyObject *)Gt_type); |
| 6455 if (isinstance == -1) { | 6442 if (isinstance == -1) { |
| 6456 return 1; | 6443 return 1; |
| 6457 } | 6444 } |
| 6458 if (isinstance) { | 6445 if (isinstance) { |
| 6459 *out = Gt; | 6446 *out = Gt; |
| 6460 return 0; | 6447 return 0; |
| 6461 } | 6448 } |
| 6462 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); | 6449 isinstance = PyObject_IsInstance(obj, (PyObject *)GtE_type); |
| 6463 if (isinstance == -1) { | 6450 if (isinstance == -1) { |
| 6464 return 1; | 6451 return 1; |
| 6465 } | 6452 } |
| 6466 if (isinstance) { | 6453 if (isinstance) { |
| 6467 *out = GtE; | 6454 *out = GtE; |
| 6468 return 0; | 6455 return 0; |
| 6469 } | 6456 } |
| 6470 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); | 6457 isinstance = PyObject_IsInstance(obj, (PyObject *)Is_type); |
| 6471 if (isinstance == -1) { | 6458 if (isinstance == -1) { |
| 6472 return 1; | 6459 return 1; |
| 6473 } | 6460 } |
| 6474 if (isinstance) { | 6461 if (isinstance) { |
| 6475 *out = Is; | 6462 *out = Is; |
| 6476 return 0; | 6463 return 0; |
| 6477 } | 6464 } |
| 6478 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); | 6465 isinstance = PyObject_IsInstance(obj, (PyObject *)IsNot_type); |
| 6479 if (isinstance == -1) { | 6466 if (isinstance == -1) { |
| 6480 return 1; | 6467 return 1; |
| 6481 } | 6468 } |
| 6482 if (isinstance) { | 6469 if (isinstance) { |
| 6483 *out = IsNot; | 6470 *out = IsNot; |
| 6484 return 0; | 6471 return 0; |
| 6485 } | 6472 } |
| 6486 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); | 6473 isinstance = PyObject_IsInstance(obj, (PyObject *)In_type); |
| 6487 if (isinstance == -1) { | 6474 if (isinstance == -1) { |
| 6488 return 1; | 6475 return 1; |
| 6489 } | 6476 } |
| 6490 if (isinstance) { | 6477 if (isinstance) { |
| 6491 *out = In; | 6478 *out = In; |
| 6492 return 0; | 6479 return 0; |
| 6493 } | 6480 } |
| 6494 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); | 6481 isinstance = PyObject_IsInstance(obj, (PyObject *)NotIn_type); |
| 6495 if (isinstance == -1) { | 6482 if (isinstance == -1) { |
| 6496 return 1; | 6483 return 1; |
| 6497 } | 6484 } |
| 6498 if (isinstance) { | 6485 if (isinstance) { |
| 6499 *out = NotIn; | 6486 *out = NotIn; |
| 6500 return 0; | 6487 return 0; |
| 6501 } | 6488 } |
| 6502 | 6489 |
| 6503 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj); | 6490 PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj); |
| 6504 return 1; | 6491 return 1; |
| 6505 } | 6492 } |
| 6506 | 6493 |
| 6507 int | 6494 int |
| 6508 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena) | 6495 obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena) |
| 6509 { | 6496 { |
| 6510 PyObject* tmp = NULL; | 6497 PyObject* tmp = NULL; |
| 6511 expr_ty target; | 6498 expr_ty target; |
| 6512 expr_ty iter; | 6499 expr_ty iter; |
| 6513 asdl_seq* ifs; | 6500 asdl_seq* ifs; |
| 6514 | 6501 |
| 6515 if (_PyObject_HasAttrId(obj, &PyId_target)) { | 6502 if (_PyObject_HasAttrId(obj, &PyId_target)) { |
| 6516 int res; | 6503 int res; |
| 6517 tmp = _PyObject_GetAttrId(obj, &PyId_target); | 6504 tmp = _PyObject_GetAttrId(obj, &PyId_target); |
| 6518 if (tmp == NULL) goto failed; | 6505 if (tmp == NULL) goto failed; |
| 6519 res = obj2ast_expr(tmp, &target, arena); | 6506 res = obj2ast_expr(tmp, &target, arena); |
| 6520 if (res != 0) goto failed; | 6507 if (res != 0) goto failed; |
| 6521 Py_XDECREF(tmp); | 6508 Py_XDECREF(tmp); |
| 6522 tmp = NULL; | 6509 tmp = NULL; |
| 6523 } else { | 6510 } else { |
| 6524 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension"); | 6511 PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension"); |
| 6525 return 1; | 6512 return 1; |
| 6526 } | 6513 } |
| 6527 if (_PyObject_HasAttrId(obj, &PyId_iter)) { | 6514 if (_PyObject_HasAttrId(obj, &PyId_iter)) { |
| 6528 int res; | 6515 int res; |
| 6529 tmp = _PyObject_GetAttrId(obj, &PyId_iter); | 6516 tmp = _PyObject_GetAttrId(obj, &PyId_iter); |
| 6530 if (tmp == NULL) goto failed; | 6517 if (tmp == NULL) goto failed; |
| 6531 res = obj2ast_expr(tmp, &iter, arena); | 6518 res = obj2ast_expr(tmp, &iter, arena); |
| 6532 if (res != 0) goto failed; | 6519 if (res != 0) goto failed; |
| 6533 Py_XDECREF(tmp); | 6520 Py_XDECREF(tmp); |
| 6534 tmp = NULL; | 6521 tmp = NULL; |
| 6535 } else { | 6522 } else { |
| 6536 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension"); | 6523 PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension"); |
| 6537 return 1; | 6524 return 1; |
| 6538 } | 6525 } |
| 6539 if (_PyObject_HasAttrId(obj, &PyId_ifs)) { | 6526 if (_PyObject_HasAttrId(obj, &PyId_ifs)) { |
| 6540 int res; | 6527 int res; |
| 6541 Py_ssize_t len; | 6528 Py_ssize_t len; |
| 6542 Py_ssize_t i; | 6529 Py_ssize_t i; |
| 6543 tmp = _PyObject_GetAttrId(obj, &PyId_ifs); | 6530 tmp = _PyObject_GetAttrId(obj, &PyId_ifs); |
| 6544 if (tmp == NULL) goto failed; | 6531 if (tmp == NULL) goto failed; |
| 6545 if (!PyList_Check(tmp)) { | 6532 if (!PyList_Check(tmp)) { |
| 6546 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 6533 PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 6547 goto failed; | 6534 goto failed; |
| 6548 } | 6535 } |
| 6549 len = PyList_GET_SIZE(tmp); | 6536 len = PyList_GET_SIZE(tmp); |
| 6550 ifs = asdl_seq_new(len, arena); | 6537 ifs = asdl_seq_new(len, arena); |
| 6551 if (ifs == NULL) goto failed; | 6538 if (ifs == NULL) goto failed; |
| 6552 for (i = 0; i < len; i++) { | 6539 for (i = 0; i < len; i++) { |
| 6553 expr_ty value; | 6540 expr_ty value; |
| 6554 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | 6541 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 6555 if (res != 0) goto failed; | 6542 if (res != 0) goto failed; |
| 6556 asdl_seq_SET(ifs, i, value); | 6543 asdl_seq_SET(ifs, i, value); |
| 6557 } | 6544 } |
| 6558 Py_XDECREF(tmp); | 6545 Py_XDECREF(tmp); |
| 6559 tmp = NULL; | 6546 tmp = NULL; |
| 6560 } else { | 6547 } else { |
| 6561 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension"); | 6548 PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension"); |
| 6562 return 1; | 6549 return 1; |
| 6563 } | 6550 } |
| 6564 *out = comprehension(target, iter, ifs, arena); | 6551 *out = comprehension(target, iter, ifs, arena); |
| 6565 return 0; | 6552 return 0; |
| 6566 failed: | 6553 failed: |
| 6567 Py_XDECREF(tmp); | 6554 Py_XDECREF(tmp); |
| 6568 return 1; | 6555 return 1; |
| 6569 } | 6556 } |
| 6570 | 6557 |
| 6571 int | 6558 int |
| 6572 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) | 6559 obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena) |
| 6573 { | 6560 { |
| 6574 int isinstance; | 6561 int isinstance; |
| 6575 | 6562 |
| 6576 PyObject *tmp = NULL; | 6563 PyObject *tmp = NULL; |
| 6577 int lineno; | 6564 int lineno; |
| 6578 int col_offset; | 6565 int col_offset; |
| 6579 | 6566 |
| 6580 if (obj == Py_None) { | 6567 if (obj == Py_None) { |
| 6581 *out = NULL; | 6568 *out = NULL; |
| 6582 return 0; | 6569 return 0; |
| 6583 } | 6570 } |
| 6584 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { | 6571 if (_PyObject_HasAttrId(obj, &PyId_lineno)) { |
| 6585 int res; | 6572 int res; |
| 6586 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); | 6573 tmp = _PyObject_GetAttrId(obj, &PyId_lineno); |
| 6587 if (tmp == NULL) goto failed; | 6574 if (tmp == NULL) goto failed; |
| 6588 res = obj2ast_int(tmp, &lineno, arena); | 6575 res = obj2ast_int(tmp, &lineno, arena); |
| 6576 if (res != 0) goto failed; | |
| 6577 Py_XDECREF(tmp); | |
| 6578 tmp = NULL; | |
| 6579 } else { | |
| 6580 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler"); | |
| 6581 return 1; | |
| 6582 } | |
| 6583 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { | |
| 6584 int res; | |
| 6585 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); | |
| 6586 if (tmp == NULL) goto failed; | |
| 6587 res = obj2ast_int(tmp, &col_offset, arena); | |
| 6588 if (res != 0) goto failed; | |
| 6589 Py_XDECREF(tmp); | |
| 6590 tmp = NULL; | |
| 6591 } else { | |
| 6592 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); | |
| 6593 return 1; | |
| 6594 } | |
| 6595 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type); | |
| 6596 if (isinstance == -1) { | |
| 6597 return 1; | |
| 6598 } | |
| 6599 if (isinstance) { | |
| 6600 expr_ty type; | |
| 6601 identifier name; | |
| 6602 asdl_seq* body; | |
| 6603 | |
| 6604 if (exists_not_none(obj, &PyId_type)) { | |
| 6605 int res; | |
| 6606 tmp = _PyObject_GetAttrId(obj, &PyId_type); | |
| 6607 if (tmp == NULL) goto failed; | |
| 6608 res = obj2ast_expr(tmp, &type, arena); | |
| 6609 if (res != 0) goto failed; | |
| 6610 Py_XDECREF(tmp); | |
| 6611 tmp = NULL; | |
| 6612 } else { | |
| 6613 type = NULL; | |
| 6614 } | |
| 6615 if (exists_not_none(obj, &PyId_name)) { | |
| 6616 int res; | |
| 6617 tmp = _PyObject_GetAttrId(obj, &PyId_name); | |
| 6618 if (tmp == NULL) goto failed; | |
| 6619 res = obj2ast_identifier(tmp, &name, arena); | |
| 6620 if (res != 0) goto failed; | |
| 6621 Py_XDECREF(tmp); | |
| 6622 tmp = NULL; | |
| 6623 } else { | |
| 6624 name = NULL; | |
| 6625 } | |
| 6626 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 6627 int res; | |
| 6628 Py_ssize_t len; | |
| 6629 Py_ssize_t i; | |
| 6630 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 6631 if (tmp == NULL) goto failed; | |
| 6632 if (!PyList_Check(tmp)) { | |
| 6633 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 6634 goto failed; | |
| 6635 } | |
| 6636 len = PyList_GET_SIZE(tmp); | |
| 6637 body = asdl_seq_new(len, arena); | |
| 6638 if (body == NULL) goto failed; | |
| 6639 for (i = 0; i < len; i++) { | |
| 6640 stmt_ty value; | |
| 6641 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 6589 if (res != 0) goto failed; | 6642 if (res != 0) goto failed; |
| 6590 Py_XDECREF(tmp); | 6643 asdl_seq_SET(body, i, value); |
| 6591 tmp = NULL; | 6644 } |
| 6592 } else { | 6645 Py_XDECREF(tmp); |
| 6593 PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler"); | 6646 tmp = NULL; |
| 6594 return 1; | 6647 } else { |
| 6595 } | 6648 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler"); |
| 6596 if (_PyObject_HasAttrId(obj, &PyId_col_offset)) { | 6649 return 1; |
| 6597 int res; | 6650 } |
| 6598 tmp = _PyObject_GetAttrId(obj, &PyId_col_offset); | 6651 *out = ExceptHandler(type, name, body, lineno, col_offset, arena); |
| 6599 if (tmp == NULL) goto failed; | 6652 if (*out == NULL) goto failed; |
| 6600 res = obj2ast_int(tmp, &col_offset, arena); | 6653 return 0; |
| 6601 if (res != 0) goto failed; | 6654 } |
| 6602 Py_XDECREF(tmp); | 6655 |
| 6603 tmp = NULL; | 6656 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj); |
| 6604 } else { | 6657 failed: |
| 6605 PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler"); | 6658 Py_XDECREF(tmp); |
| 6606 return 1; | 6659 return 1; |
| 6607 } | |
| 6608 isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type); | |
| 6609 if (isinstance == -1) { | |
| 6610 return 1; | |
| 6611 } | |
| 6612 if (isinstance) { | |
| 6613 expr_ty type; | |
| 6614 identifier name; | |
| 6615 asdl_seq* body; | |
| 6616 | |
| 6617 if (exists_not_none(obj, &PyId_type)) { | |
| 6618 int res; | |
| 6619 tmp = _PyObject_GetAttrId(obj, &PyId_type); | |
| 6620 if (tmp == NULL) goto failed; | |
| 6621 res = obj2ast_expr(tmp, &type, arena); | |
| 6622 if (res != 0) goto failed; | |
| 6623 Py_XDECREF(tmp); | |
| 6624 tmp = NULL; | |
| 6625 } else { | |
| 6626 type = NULL; | |
| 6627 } | |
| 6628 if (exists_not_none(obj, &PyId_name)) { | |
| 6629 int res; | |
| 6630 tmp = _PyObject_GetAttrId(obj, &PyId_name); | |
| 6631 if (tmp == NULL) goto failed; | |
| 6632 res = obj2ast_identifier(tmp, &name, arena); | |
| 6633 if (res != 0) goto failed; | |
| 6634 Py_XDECREF(tmp); | |
| 6635 tmp = NULL; | |
| 6636 } else { | |
| 6637 name = NULL; | |
| 6638 } | |
| 6639 if (_PyObject_HasAttrId(obj, &PyId_body)) { | |
| 6640 int res; | |
| 6641 Py_ssize_t len; | |
| 6642 Py_ssize_t i; | |
| 6643 tmp = _PyObject_GetAttrId(obj, &PyId_body); | |
| 6644 if (tmp == NULL) goto failed; | |
| 6645 if (!PyList_Check(tmp)) { | |
| 6646 PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); | |
| 6647 goto failed; | |
| 6648 } | |
| 6649 len = PyList_GET_SIZE(tmp); | |
| 6650 body = asdl_seq_new(len, arena); | |
| 6651 if (body == NULL) goto failed; | |
| 6652 for (i = 0; i < len; i++) { | |
| 6653 stmt_ty value; | |
| 6654 res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); | |
| 6655 if (res != 0) goto failed; | |
| 6656 asdl_seq_SET(body, i, value); | |
| 6657 } | |
| 6658 Py_XDECREF(tmp); | |
| 6659 tmp = NULL; | |
| 6660 } else { | |
| 6661 PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler"); | |
| 6662 return 1; | |
| 6663 } | |
| 6664 *out = ExceptHandler(type, name, body, lineno, col_offset, | |
| 6665 arena); | |
| 6666 if (*out == NULL) goto failed; | |
| 6667 return 0; | |
| 6668 } | |
| 6669 | |
| 6670 PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj); | |
| 6671 failed: | |
| 6672 Py_XDECREF(tmp); | |
| 6673 return 1; | |
| 6674 } | 6660 } |
| 6675 | 6661 |
| 6676 int | 6662 int |
| 6677 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena) | 6663 obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena) |
| 6678 { | 6664 { |
| 6679 PyObject* tmp = NULL; | 6665 PyObject* tmp = NULL; |
| 6680 asdl_seq* args; | 6666 asdl_seq* args; |
| 6681 arg_ty vararg; | 6667 arg_ty vararg; |
| 6682 asdl_seq* kwonlyargs; | 6668 asdl_seq* kwonlyargs; |
| 6683 asdl_seq* kw_defaults; | 6669 asdl_seq* kw_defaults; |
| 6684 arg_ty kwarg; | 6670 arg_ty kwarg; |
| 6685 asdl_seq* defaults; | 6671 asdl_seq* defaults; |
| 6686 | 6672 |
| 6687 if (_PyObject_HasAttrId(obj, &PyId_args)) { | 6673 if (_PyObject_HasAttrId(obj, &PyId_args)) { |
| 6688 int res; | 6674 int res; |
| 6689 Py_ssize_t len; | 6675 Py_ssize_t len; |
| 6690 Py_ssize_t i; | 6676 Py_ssize_t i; |
| 6691 tmp = _PyObject_GetAttrId(obj, &PyId_args); | 6677 tmp = _PyObject_GetAttrId(obj, &PyId_args); |
| 6692 if (tmp == NULL) goto failed; | 6678 if (tmp == NULL) goto failed; |
| 6693 if (!PyList_Check(tmp)) { | 6679 if (!PyList_Check(tmp)) { |
| 6694 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 6680 PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 6695 goto failed; | 6681 goto failed; |
| 6696 } | 6682 } |
| 6697 len = PyList_GET_SIZE(tmp); | 6683 len = PyList_GET_SIZE(tmp); |
| 6698 args = asdl_seq_new(len, arena); | 6684 args = asdl_seq_new(len, arena); |
| 6699 if (args == NULL) goto failed; | 6685 if (args == NULL) goto failed; |
| 6700 for (i = 0; i < len; i++) { | 6686 for (i = 0; i < len; i++) { |
| 6701 arg_ty value; | 6687 arg_ty value; |
| 6702 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); | 6688 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); |
| 6703 if (res != 0) goto failed; | 6689 if (res != 0) goto failed; |
| 6704 asdl_seq_SET(args, i, value); | 6690 asdl_seq_SET(args, i, value); |
| 6705 } | 6691 } |
| 6706 Py_XDECREF(tmp); | 6692 Py_XDECREF(tmp); |
| 6707 tmp = NULL; | 6693 tmp = NULL; |
| 6708 } else { | 6694 } else { |
| 6709 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments"); | 6695 PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments"); |
| 6710 return 1; | 6696 return 1; |
| 6711 } | 6697 } |
| 6712 if (exists_not_none(obj, &PyId_vararg)) { | 6698 if (exists_not_none(obj, &PyId_vararg)) { |
| 6713 int res; | 6699 int res; |
| 6714 tmp = _PyObject_GetAttrId(obj, &PyId_vararg); | 6700 tmp = _PyObject_GetAttrId(obj, &PyId_vararg); |
| 6715 if (tmp == NULL) goto failed; | 6701 if (tmp == NULL) goto failed; |
| 6716 res = obj2ast_arg(tmp, &vararg, arena); | 6702 res = obj2ast_arg(tmp, &vararg, arena); |
| 6717 if (res != 0) goto failed; | 6703 if (res != 0) goto failed; |
| 6718 Py_XDECREF(tmp); | 6704 Py_XDECREF(tmp); |
| 6719 tmp = NULL; | 6705 tmp = NULL; |
| 6720 } else { | 6706 } else { |
| 6721 vararg = NULL; | 6707 vararg = NULL; |
| 6722 } | 6708 } |
| 6723 if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) { | 6709 if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) { |
| 6724 int res; | 6710 int res; |
| 6725 Py_ssize_t len; | 6711 Py_ssize_t len; |
| 6726 Py_ssize_t i; | 6712 Py_ssize_t i; |
| 6727 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs); | 6713 tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs); |
| 6728 if (tmp == NULL) goto failed; | 6714 if (tmp == NULL) goto failed; |
| 6729 if (!PyList_Check(tmp)) { | 6715 if (!PyList_Check(tmp)) { |
| 6730 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 6716 PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 6731 goto failed; | 6717 goto failed; |
| 6732 } | 6718 } |
| 6733 len = PyList_GET_SIZE(tmp); | 6719 len = PyList_GET_SIZE(tmp); |
| 6734 kwonlyargs = asdl_seq_new(len, arena); | 6720 kwonlyargs = asdl_seq_new(len, arena); |
| 6735 if (kwonlyargs == NULL) goto failed; | 6721 if (kwonlyargs == NULL) goto failed; |
| 6736 for (i = 0; i < len; i++) { | 6722 for (i = 0; i < len; i++) { |
| 6737 arg_ty value; | 6723 arg_ty value; |
| 6738 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); | 6724 res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); |
| 6739 if (res != 0) goto failed; | 6725 if (res != 0) goto failed; |
| 6740 asdl_seq_SET(kwonlyargs, i, value); | 6726 asdl_seq_SET(kwonlyargs, i, value); |
| 6741 } | 6727 } |
| 6742 Py_XDECREF(tmp); | 6728 Py_XDECREF(tmp); |
| 6743 tmp = NULL; | 6729 tmp = NULL; |
| 6744 } else { | 6730 } else { |
| 6745 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments"); | 6731 PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments"); |
| 6746 return 1; | 6732 return 1; |
| 6747 } | 6733 } |
| 6748 if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) { | 6734 if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) { |
| 6749 int res; | 6735 int res; |
| 6750 Py_ssize_t len; | 6736 Py_ssize_t len; |
| 6751 Py_ssize_t i; | 6737 Py_ssize_t i; |
| 6752 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults); | 6738 tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults); |
| 6753 if (tmp == NULL) goto failed; | 6739 if (tmp == NULL) goto failed; |
| 6754 if (!PyList_Check(tmp)) { | 6740 if (!PyList_Check(tmp)) { |
| 6755 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 6741 PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 6756 goto failed; | 6742 goto failed; |
| 6757 } | 6743 } |
| 6758 len = PyList_GET_SIZE(tmp); | 6744 len = PyList_GET_SIZE(tmp); |
| 6759 kw_defaults = asdl_seq_new(len, arena); | 6745 kw_defaults = asdl_seq_new(len, arena); |
| 6760 if (kw_defaults == NULL) goto failed; | 6746 if (kw_defaults == NULL) goto failed; |
| 6761 for (i = 0; i < len; i++) { | 6747 for (i = 0; i < len; i++) { |
| 6762 expr_ty value; | 6748 expr_ty value; |
| 6763 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | 6749 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 6764 if (res != 0) goto failed; | 6750 if (res != 0) goto failed; |
| 6765 asdl_seq_SET(kw_defaults, i, value); | 6751 asdl_seq_SET(kw_defaults, i, value); |
| 6766 } | 6752 } |
| 6767 Py_XDECREF(tmp); | 6753 Py_XDECREF(tmp); |
| 6768 tmp = NULL; | 6754 tmp = NULL; |
| 6769 } else { | 6755 } else { |
| 6770 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments"); | 6756 PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments"); |
| 6771 return 1; | 6757 return 1; |
| 6772 } | 6758 } |
| 6773 if (exists_not_none(obj, &PyId_kwarg)) { | 6759 if (exists_not_none(obj, &PyId_kwarg)) { |
| 6774 int res; | 6760 int res; |
| 6775 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg); | 6761 tmp = _PyObject_GetAttrId(obj, &PyId_kwarg); |
| 6776 if (tmp == NULL) goto failed; | 6762 if (tmp == NULL) goto failed; |
| 6777 res = obj2ast_arg(tmp, &kwarg, arena); | 6763 res = obj2ast_arg(tmp, &kwarg, arena); |
| 6778 if (res != 0) goto failed; | 6764 if (res != 0) goto failed; |
| 6779 Py_XDECREF(tmp); | 6765 Py_XDECREF(tmp); |
| 6780 tmp = NULL; | 6766 tmp = NULL; |
| 6781 } else { | 6767 } else { |
| 6782 kwarg = NULL; | 6768 kwarg = NULL; |
| 6783 } | 6769 } |
| 6784 if (_PyObject_HasAttrId(obj, &PyId_defaults)) { | 6770 if (_PyObject_HasAttrId(obj, &PyId_defaults)) { |
| 6785 int res; | 6771 int res; |
| 6786 Py_ssize_t len; | 6772 Py_ssize_t len; |
| 6787 Py_ssize_t i; | 6773 Py_ssize_t i; |
| 6788 tmp = _PyObject_GetAttrId(obj, &PyId_defaults); | 6774 tmp = _PyObject_GetAttrId(obj, &PyId_defaults); |
| 6789 if (tmp == NULL) goto failed; | 6775 if (tmp == NULL) goto failed; |
| 6790 if (!PyList_Check(tmp)) { | 6776 if (!PyList_Check(tmp)) { |
| 6791 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); | 6777 PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); |
| 6792 goto failed; | 6778 goto failed; |
| 6793 } | 6779 } |
| 6794 len = PyList_GET_SIZE(tmp); | 6780 len = PyList_GET_SIZE(tmp); |
| 6795 defaults = asdl_seq_new(len, arena); | 6781 defaults = asdl_seq_new(len, arena); |
| 6796 if (defaults == NULL) goto failed; | 6782 if (defaults == NULL) goto failed; |
| 6797 for (i = 0; i < len; i++) { | 6783 for (i = 0; i < len; i++) { |
| 6798 expr_ty value; | 6784 expr_ty value; |
| 6799 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); | 6785 res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); |
| 6800 if (res != 0) goto failed; | 6786 if (res != 0) goto failed; |
| 6801 asdl_seq_SET(defaults, i, value); | 6787 asdl_seq_SET(defaults, i, value); |
| 6802 } | 6788 } |
| 6803 Py_XDECREF(tmp); | 6789 Py_XDECREF(tmp); |
| 6804 tmp = NULL; | 6790 tmp = NULL; |
| 6805 } else { | 6791 } else { |
| 6806 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); | 6792 PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments"); |
| 6807 return 1; | 6793 return 1; |
| 6808 } | 6794 } |
| 6809 *out = arguments(args, vararg, kwonlyargs, kw_defaults, kwarg, | 6795 *out = arguments(args, vararg, kwonlyargs, kw_defaults, kwarg, defaults, |
| 6810 defaults, arena); | 6796 arena); |
| 6811 return 0; | 6797 return 0; |
| 6812 failed: | 6798 failed: |
| 6813 Py_XDECREF(tmp); | 6799 Py_XDECREF(tmp); |
| 6814 return 1; | 6800 return 1; |
| 6815 } | 6801 } |
| 6816 | 6802 |
| 6817 int | 6803 int |
| 6818 obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena) | 6804 obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena) |
| 6819 { | 6805 { |
| 6820 PyObject* tmp = NULL; | 6806 PyObject* tmp = NULL; |
| 6821 identifier arg; | 6807 identifier arg; |
| 6822 expr_ty annotation; | 6808 expr_ty annotation; |
| 6823 | 6809 |
| 6824 if (_PyObject_HasAttrId(obj, &PyId_arg)) { | 6810 if (_PyObject_HasAttrId(obj, &PyId_arg)) { |
| 6825 int res; | 6811 int res; |
| 6826 tmp = _PyObject_GetAttrId(obj, &PyId_arg); | 6812 tmp = _PyObject_GetAttrId(obj, &PyId_arg); |
| 6827 if (tmp == NULL) goto failed; | 6813 if (tmp == NULL) goto failed; |
| 6828 res = obj2ast_identifier(tmp, &arg, arena); | 6814 res = obj2ast_identifier(tmp, &arg, arena); |
| 6829 if (res != 0) goto failed; | 6815 if (res != 0) goto failed; |
| 6830 Py_XDECREF(tmp); | 6816 Py_XDECREF(tmp); |
| 6831 tmp = NULL; | 6817 tmp = NULL; |
| 6832 } else { | 6818 } else { |
| 6833 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg"); | 6819 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg"); |
| 6834 return 1; | 6820 return 1; |
| 6835 } | 6821 } |
| 6836 if (exists_not_none(obj, &PyId_annotation)) { | 6822 if (exists_not_none(obj, &PyId_annotation)) { |
| 6837 int res; | 6823 int res; |
| 6838 tmp = _PyObject_GetAttrId(obj, &PyId_annotation); | 6824 tmp = _PyObject_GetAttrId(obj, &PyId_annotation); |
| 6839 if (tmp == NULL) goto failed; | 6825 if (tmp == NULL) goto failed; |
| 6840 res = obj2ast_expr(tmp, &annotation, arena); | 6826 res = obj2ast_expr(tmp, &annotation, arena); |
| 6841 if (res != 0) goto failed; | 6827 if (res != 0) goto failed; |
| 6842 Py_XDECREF(tmp); | 6828 Py_XDECREF(tmp); |
| 6843 tmp = NULL; | 6829 tmp = NULL; |
| 6844 } else { | 6830 } else { |
| 6845 annotation = NULL; | 6831 annotation = NULL; |
| 6846 } | 6832 } |
| 6847 *out = arg(arg, annotation, arena); | 6833 *out = arg(arg, annotation, arena); |
| 6848 return 0; | 6834 return 0; |
| 6849 failed: | 6835 failed: |
| 6850 Py_XDECREF(tmp); | 6836 Py_XDECREF(tmp); |
| 6851 return 1; | 6837 return 1; |
| 6852 } | 6838 } |
| 6853 | 6839 |
| 6854 int | 6840 int |
| 6855 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena) | 6841 obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena) |
| 6856 { | 6842 { |
| 6857 PyObject* tmp = NULL; | 6843 PyObject* tmp = NULL; |
| 6858 identifier arg; | 6844 identifier arg; |
| 6859 expr_ty value; | 6845 expr_ty value; |
| 6860 | 6846 |
| 6861 if (_PyObject_HasAttrId(obj, &PyId_arg)) { | 6847 if (_PyObject_HasAttrId(obj, &PyId_arg)) { |
| 6862 int res; | 6848 int res; |
| 6863 tmp = _PyObject_GetAttrId(obj, &PyId_arg); | 6849 tmp = _PyObject_GetAttrId(obj, &PyId_arg); |
| 6864 if (tmp == NULL) goto failed; | 6850 if (tmp == NULL) goto failed; |
| 6865 res = obj2ast_identifier(tmp, &arg, arena); | 6851 res = obj2ast_identifier(tmp, &arg, arena); |
| 6866 if (res != 0) goto failed; | 6852 if (res != 0) goto failed; |
| 6867 Py_XDECREF(tmp); | 6853 Py_XDECREF(tmp); |
| 6868 tmp = NULL; | 6854 tmp = NULL; |
| 6869 } else { | 6855 } else { |
| 6870 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword"); | 6856 PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword"); |
| 6871 return 1; | 6857 return 1; |
| 6872 } | 6858 } |
| 6873 if (_PyObject_HasAttrId(obj, &PyId_value)) { | 6859 if (_PyObject_HasAttrId(obj, &PyId_value)) { |
| 6874 int res; | 6860 int res; |
| 6875 tmp = _PyObject_GetAttrId(obj, &PyId_value); | 6861 tmp = _PyObject_GetAttrId(obj, &PyId_value); |
| 6876 if (tmp == NULL) goto failed; | 6862 if (tmp == NULL) goto failed; |
| 6877 res = obj2ast_expr(tmp, &value, arena); | 6863 res = obj2ast_expr(tmp, &value, arena); |
| 6878 if (res != 0) goto failed; | 6864 if (res != 0) goto failed; |
| 6879 Py_XDECREF(tmp); | 6865 Py_XDECREF(tmp); |
| 6880 tmp = NULL; | 6866 tmp = NULL; |
| 6881 } else { | 6867 } else { |
| 6882 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword"); | 6868 PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword"); |
| 6883 return 1; | 6869 return 1; |
| 6884 } | 6870 } |
| 6885 *out = keyword(arg, value, arena); | 6871 *out = keyword(arg, value, arena); |
| 6886 return 0; | 6872 return 0; |
| 6887 failed: | 6873 failed: |
| 6888 Py_XDECREF(tmp); | 6874 Py_XDECREF(tmp); |
| 6889 return 1; | 6875 return 1; |
| 6890 } | 6876 } |
| 6891 | 6877 |
| 6892 int | 6878 int |
| 6893 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena) | 6879 obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena) |
| 6894 { | 6880 { |
| 6895 PyObject* tmp = NULL; | 6881 PyObject* tmp = NULL; |
| 6896 identifier name; | 6882 identifier name; |
| 6897 identifier asname; | 6883 identifier asname; |
| 6898 | 6884 |
| 6899 if (_PyObject_HasAttrId(obj, &PyId_name)) { | 6885 if (_PyObject_HasAttrId(obj, &PyId_name)) { |
| 6900 int res; | 6886 int res; |
| 6901 tmp = _PyObject_GetAttrId(obj, &PyId_name); | 6887 tmp = _PyObject_GetAttrId(obj, &PyId_name); |
| 6902 if (tmp == NULL) goto failed; | 6888 if (tmp == NULL) goto failed; |
| 6903 res = obj2ast_identifier(tmp, &name, arena); | 6889 res = obj2ast_identifier(tmp, &name, arena); |
| 6904 if (res != 0) goto failed; | 6890 if (res != 0) goto failed; |
| 6905 Py_XDECREF(tmp); | 6891 Py_XDECREF(tmp); |
| 6906 tmp = NULL; | 6892 tmp = NULL; |
| 6907 } else { | 6893 } else { |
| 6908 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias"); | 6894 PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias"); |
| 6909 return 1; | 6895 return 1; |
| 6910 } | 6896 } |
| 6911 if (exists_not_none(obj, &PyId_asname)) { | 6897 if (exists_not_none(obj, &PyId_asname)) { |
| 6912 int res; | 6898 int res; |
| 6913 tmp = _PyObject_GetAttrId(obj, &PyId_asname); | 6899 tmp = _PyObject_GetAttrId(obj, &PyId_asname); |
| 6914 if (tmp == NULL) goto failed; | 6900 if (tmp == NULL) goto failed; |
| 6915 res = obj2ast_identifier(tmp, &asname, arena); | 6901 res = obj2ast_identifier(tmp, &asname, arena); |
| 6916 if (res != 0) goto failed; | 6902 if (res != 0) goto failed; |
| 6917 Py_XDECREF(tmp); | 6903 Py_XDECREF(tmp); |
| 6918 tmp = NULL; | 6904 tmp = NULL; |
| 6919 } else { | 6905 } else { |
| 6920 asname = NULL; | 6906 asname = NULL; |
| 6921 } | 6907 } |
| 6922 *out = alias(name, asname, arena); | 6908 *out = alias(name, asname, arena); |
| 6923 return 0; | 6909 return 0; |
| 6924 failed: | 6910 failed: |
| 6925 Py_XDECREF(tmp); | 6911 Py_XDECREF(tmp); |
| 6926 return 1; | 6912 return 1; |
| 6927 } | 6913 } |
| 6928 | 6914 |
| 6929 int | 6915 int |
| 6930 obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena) | 6916 obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena) |
| 6931 { | 6917 { |
| 6932 PyObject* tmp = NULL; | 6918 PyObject* tmp = NULL; |
| 6933 expr_ty context_expr; | 6919 expr_ty context_expr; |
| 6934 expr_ty optional_vars; | 6920 expr_ty optional_vars; |
| 6935 | 6921 |
| 6936 if (_PyObject_HasAttrId(obj, &PyId_context_expr)) { | 6922 if (_PyObject_HasAttrId(obj, &PyId_context_expr)) { |
| 6937 int res; | 6923 int res; |
| 6938 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr); | 6924 tmp = _PyObject_GetAttrId(obj, &PyId_context_expr); |
| 6939 if (tmp == NULL) goto failed; | 6925 if (tmp == NULL) goto failed; |
| 6940 res = obj2ast_expr(tmp, &context_expr, arena); | 6926 res = obj2ast_expr(tmp, &context_expr, arena); |
| 6941 if (res != 0) goto failed; | 6927 if (res != 0) goto failed; |
| 6942 Py_XDECREF(tmp); | 6928 Py_XDECREF(tmp); |
| 6943 tmp = NULL; | 6929 tmp = NULL; |
| 6944 } else { | 6930 } else { |
| 6945 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem"); | 6931 PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem"); |
| 6946 return 1; | 6932 return 1; |
| 6947 } | 6933 } |
| 6948 if (exists_not_none(obj, &PyId_optional_vars)) { | 6934 if (exists_not_none(obj, &PyId_optional_vars)) { |
| 6949 int res; | 6935 int res; |
| 6950 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars); | 6936 tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars); |
| 6951 if (tmp == NULL) goto failed; | 6937 if (tmp == NULL) goto failed; |
| 6952 res = obj2ast_expr(tmp, &optional_vars, arena); | 6938 res = obj2ast_expr(tmp, &optional_vars, arena); |
| 6953 if (res != 0) goto failed; | 6939 if (res != 0) goto failed; |
| 6954 Py_XDECREF(tmp); | 6940 Py_XDECREF(tmp); |
| 6955 tmp = NULL; | 6941 tmp = NULL; |
| 6956 } else { | 6942 } else { |
| 6957 optional_vars = NULL; | 6943 optional_vars = NULL; |
| 6958 } | 6944 } |
| 6959 *out = withitem(context_expr, optional_vars, arena); | 6945 *out = withitem(context_expr, optional_vars, arena); |
| 6960 return 0; | 6946 return 0; |
| 6961 failed: | 6947 failed: |
| 6962 Py_XDECREF(tmp); | 6948 Py_XDECREF(tmp); |
| 6963 return 1; | 6949 return 1; |
| 6964 } | 6950 } |
| 6965 | 6951 |
| 6966 | 6952 |
| 6967 static struct PyModuleDef _astmodule = { | 6953 static struct PyModuleDef _astmodule = { |
| 6968 PyModuleDef_HEAD_INIT, "_ast" | 6954 PyModuleDef_HEAD_INIT, "_ast" |
| 6969 }; | 6955 }; |
| 6970 PyMODINIT_FUNC | 6956 PyMODINIT_FUNC |
| 6971 PyInit__ast(void) | 6957 PyInit__ast(void) |
| 6972 { | 6958 { |
| 6973 PyObject *m, *d; | 6959 PyObject *m, *d; |
| 6974 if (!init_types()) return NULL; | 6960 if (!init_types()) return NULL; |
| 6975 m = PyModule_Create(&_astmodule); | 6961 m = PyModule_Create(&_astmodule); |
| 6976 if (!m) return NULL; | 6962 if (!m) return NULL; |
| 6977 d = PyModule_GetDict(m); | 6963 d = PyModule_GetDict(m); |
| 6978 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return | 6964 if (PyDict_SetItemString(d, "AST", (PyObject*)&AST_type) < 0) return NULL; |
| 6979 NULL; | 6965 if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) |
| 6980 if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) | 6966 return NULL; |
| 6981 return NULL; | 6967 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return NULL; |
| 6982 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return | 6968 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) return |
| 6983 NULL; | 6969 NULL; |
| 6984 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) | 6970 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) < |
| 6985 return NULL; | 6971 0) return NULL; |
| 6986 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) | 6972 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < 0) |
| 6987 < 0) return NULL; | 6973 return NULL; |
| 6988 if (PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < | 6974 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return |
| 6989 0) return NULL; | 6975 NULL; |
| 6990 if (PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return | 6976 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return NULL; |
| 6991 NULL; | 6977 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) < |
| 6992 if (PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return | 6978 0) return NULL; |
| 6993 NULL; | 6979 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0) |
| 6994 if (PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) | 6980 return NULL; |
| 6995 < 0) return NULL; | 6981 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) return |
| 6996 if (PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0) | 6982 NULL; |
| 6997 return NULL; | 6983 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) return |
| 6998 if (PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) | 6984 NULL; |
| 6999 return NULL; | 6985 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) return |
| 7000 if (PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) | 6986 NULL; |
| 7001 return NULL; | 6987 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 0) |
| 7002 if (PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) | 6988 return NULL; |
| 7003 return NULL; | 6989 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return NULL; |
| 7004 if (PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < | 6990 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return |
| 7005 0) return NULL; | 6991 NULL; |
| 7006 if (PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return | 6992 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL; |
| 7007 NULL; | 6993 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return NULL; |
| 7008 if (PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return | 6994 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return |
| 7009 NULL; | 6995 NULL; |
| 7010 if (PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return NULL; | 6996 if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return NULL; |
| 7011 if (PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return | 6997 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) return |
| 7012 NULL; | 6998 NULL; |
| 7013 if (PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return | 6999 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) return |
| 7014 NULL; | 7000 NULL; |
| 7015 if (PyDict_SetItemString(d, "Try", (PyObject*)Try_type) < 0) return | 7001 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < 0) |
| 7016 NULL; | 7002 return NULL; |
| 7017 if (PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) | 7003 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) return |
| 7018 return NULL; | 7004 NULL; |
| 7019 if (PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) | 7005 if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0) |
| 7020 return NULL; | 7006 return NULL; |
| 7021 if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < | 7007 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return NULL; |
| 7022 0) return NULL; | 7008 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return NULL; |
| 7023 if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) | 7009 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return |
| 7024 return NULL; | 7010 NULL; |
| 7025 if (PyDict_SetItemString(d, "Nonlocal", (PyObject*)Nonlocal_type) < 0) | 7011 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0) |
| 7026 return NULL; | 7012 return NULL; |
| 7027 if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return | 7013 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return NULL; |
| 7028 NULL; | 7014 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) return |
| 7029 if (PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return | 7015 NULL; |
| 7030 NULL; | 7016 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return |
| 7031 if (PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return | 7017 NULL; |
| 7032 NULL; | 7018 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) return |
| 7033 if (PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0) | 7019 NULL; |
| 7034 return NULL; | 7020 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) return |
| 7035 if (PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return | 7021 NULL; |
| 7036 NULL; | 7022 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return |
| 7037 if (PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) | 7023 NULL; |
| 7038 return NULL; | 7024 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return NULL; |
| 7039 if (PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return | 7025 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return NULL; |
| 7040 NULL; | 7026 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) |
| 7041 if (PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) | 7027 return NULL; |
| 7042 return NULL; | 7028 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) return |
| 7043 if (PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) | 7029 NULL; |
| 7044 return NULL; | 7030 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0) |
| 7045 if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return | 7031 return NULL; |
| 7046 NULL; | 7032 if (PyDict_SetItemString(d, "GeneratorExp", (PyObject*)GeneratorExp_type) < |
| 7047 if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return | 7033 0) return NULL; |
| 7048 NULL; | 7034 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return |
| 7049 if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return | 7035 NULL; |
| 7050 NULL; | 7036 if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) < 0) |
| 7051 if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) | 7037 return NULL; |
| 7052 return NULL; | 7038 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) return |
| 7053 if (PyDict_SetItemString(d, "SetComp", (PyObject*)SetComp_type) < 0) | 7039 NULL; |
| 7054 return NULL; | 7040 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return NULL; |
| 7055 if (PyDict_SetItemString(d, "DictComp", (PyObject*)DictComp_type) < 0) | 7041 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return NULL; |
| 7056 return NULL; | 7042 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return NULL; |
| 7057 if (PyDict_SetItemString(d, "GeneratorExp", | 7043 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return |
| 7058 (PyObject*)GeneratorExp_type) < 0) return NULL; | 7044 NULL; |
| 7059 if (PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return | 7045 if (PyDict_SetItemString(d, "NameConstant", (PyObject*)NameConstant_type) < |
| 7060 NULL; | 7046 0) return NULL; |
| 7061 if (PyDict_SetItemString(d, "YieldFrom", (PyObject*)YieldFrom_type) < | 7047 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) |
| 7062 0) return NULL; | 7048 return NULL; |
| 7063 if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) | 7049 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0) |
| 7064 return NULL; | 7050 return NULL; |
| 7065 if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return | 7051 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0) |
| 7066 NULL; | 7052 return NULL; |
| 7067 if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return | 7053 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0) return |
| 7068 NULL; | 7054 NULL; |
| 7069 if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return | 7055 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return NULL; |
| 7070 NULL; | 7056 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return NULL; |
| 7071 if (PyDict_SetItemString(d, "Bytes", (PyObject*)Bytes_type) < 0) return | 7057 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return |
| 7072 NULL; | 7058 NULL; |
| 7073 if (PyDict_SetItemString(d, "NameConstant", | 7059 if (PyDict_SetItemString(d, "expr_context", (PyObject*)expr_context_type) < |
| 7074 (PyObject*)NameConstant_type) < 0) return NULL; | 7060 0) return NULL; |
| 7075 if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) | 7061 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return NULL; |
| 7076 return NULL; | 7062 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return |
| 7077 if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < | 7063 NULL; |
| 7078 0) return NULL; | 7064 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return NULL; |
| 7079 if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < | 7065 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) return |
| 7080 0) return NULL; | 7066 NULL; |
| 7081 if (PyDict_SetItemString(d, "Starred", (PyObject*)Starred_type) < 0) | 7067 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0) |
| 7082 return NULL; | 7068 return NULL; |
| 7083 if (PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return | 7069 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return |
| 7084 NULL; | 7070 NULL; |
| 7085 if (PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return | 7071 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return |
| 7086 NULL; | 7072 NULL; |
| 7087 if (PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return | 7073 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return |
| 7088 NULL; | 7074 NULL; |
| 7089 if (PyDict_SetItemString(d, "expr_context", | 7075 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) |
| 7090 (PyObject*)expr_context_type) < 0) return NULL; | 7076 return NULL; |
| 7091 if (PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return | 7077 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return |
| 7092 NULL; | 7078 NULL; |
| 7093 if (PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return | 7079 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) return |
| 7094 NULL; | 7080 NULL; |
| 7095 if (PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return | 7081 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return NULL; |
| 7096 NULL; | 7082 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL; |
| 7097 if (PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) | 7083 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0) |
| 7098 return NULL; | 7084 return NULL; |
| 7099 if (PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0) | 7085 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return NULL; |
| 7100 return NULL; | 7086 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return NULL; |
| 7101 if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return | 7087 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return NULL; |
| 7102 NULL; | 7088 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return NULL; |
| 7103 if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return | 7089 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return NULL; |
| 7104 NULL; | 7090 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return NULL; |
| 7105 if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return | 7091 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) return |
| 7106 NULL; | 7092 NULL; |
| 7107 if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) | 7093 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) return |
| 7108 return NULL; | 7094 NULL; |
| 7109 if (PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return | 7095 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return |
| 7110 NULL; | 7096 NULL; |
| 7111 if (PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) | 7097 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) return |
| 7112 return NULL; | 7098 NULL; |
| 7113 if (PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return | 7099 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) return |
| 7114 NULL; | 7100 NULL; |
| 7115 if (PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return NULL; | 7101 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0) |
| 7116 if (PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0) | 7102 return NULL; |
| 7117 return NULL; | 7103 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) return |
| 7118 if (PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return | 7104 NULL; |
| 7119 NULL; | 7105 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) return |
| 7120 if (PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return | 7106 NULL; |
| 7121 NULL; | 7107 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return NULL; |
| 7122 if (PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return | 7108 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return NULL; |
| 7123 NULL; | 7109 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return NULL; |
| 7124 if (PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return | 7110 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return |
| 7125 NULL; | 7111 NULL; |
| 7126 if (PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return | 7112 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL; |
| 7127 NULL; | 7113 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return |
| 7128 if (PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return | 7114 NULL; |
| 7129 NULL; | 7115 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL; |
| 7130 if (PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) | 7116 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return NULL; |
| 7131 return NULL; | 7117 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL; |
| 7132 if (PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) | 7118 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return NULL; |
| 7133 return NULL; | 7119 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL; |
| 7134 if (PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return | 7120 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return |
| 7135 NULL; | 7121 NULL; |
| 7136 if (PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) | 7122 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL; |
| 7137 return NULL; | 7123 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return |
| 7138 if (PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) | 7124 NULL; |
| 7139 return NULL; | 7125 if (PyDict_SetItemString(d, "comprehension", (PyObject*)comprehension_type) |
| 7140 if (PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0) | 7126 < 0) return NULL; |
| 7141 return NULL; | 7127 if (PyDict_SetItemString(d, "excepthandler", (PyObject*)excepthandler_type) |
| 7142 if (PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) | 7128 < 0) return NULL; |
| 7143 return NULL; | 7129 if (PyDict_SetItemString(d, "ExceptHandler", (PyObject*)ExceptHandler_type) |
| 7144 if (PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) | 7130 < 0) return NULL; |
| 7145 return NULL; | 7131 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 0) |
| 7146 if (PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return | 7132 return NULL; |
| 7147 NULL; | 7133 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return NULL; |
| 7148 if (PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return | 7134 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) return |
| 7149 NULL; | 7135 NULL; |
| 7150 if (PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return | 7136 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return |
| 7151 NULL; | 7137 NULL; |
| 7152 if (PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return | 7138 if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0) |
| 7153 NULL; | 7139 return NULL; |
| 7154 if (PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return NULL; | 7140 return m; |
| 7155 if (PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return | |
| 7156 NULL; | |
| 7157 if (PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return NULL; | |
| 7158 if (PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return | |
| 7159 NULL; | |
| 7160 if (PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return NULL; | |
| 7161 if (PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return | |
| 7162 NULL; | |
| 7163 if (PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return NULL; | |
| 7164 if (PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return | |
| 7165 NULL; | |
| 7166 if (PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return NULL; | |
| 7167 if (PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return | |
| 7168 NULL; | |
| 7169 if (PyDict_SetItemString(d, "comprehension", | |
| 7170 (PyObject*)comprehension_type) < 0) return NULL; | |
| 7171 if (PyDict_SetItemString(d, "excepthandler", | |
| 7172 (PyObject*)excepthandler_type) < 0) return NULL; | |
| 7173 if (PyDict_SetItemString(d, "ExceptHandler", | |
| 7174 (PyObject*)ExceptHandler_type) < 0) return NULL; | |
| 7175 if (PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < | |
| 7176 0) return NULL; | |
| 7177 if (PyDict_SetItemString(d, "arg", (PyObject*)arg_type) < 0) return | |
| 7178 NULL; | |
| 7179 if (PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) | |
| 7180 return NULL; | |
| 7181 if (PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return | |
| 7182 NULL; | |
| 7183 if (PyDict_SetItemString(d, "withitem", (PyObject*)withitem_type) < 0) | |
| 7184 return NULL; | |
| 7185 return m; | |
| 7186 } | 7141 } |
| 7187 | 7142 |
| 7188 | 7143 |
| 7189 PyObject* PyAST_mod2obj(mod_ty t) | 7144 PyObject* PyAST_mod2obj(mod_ty t) |
| 7190 { | 7145 { |
