p->col_offset = col_offset; return p;} expr_tyCompare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!left) { PyErr_SetString(PyExc_ValueError, "field left is required for Compare"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Compare_kind; p->v.Compare.left = left; p->v.Compare.ops = ops; p->v.Compare.comparators = comparators; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyCall(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, expr_ty kwargs, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!func) { PyErr_SetString(PyExc_ValueError, "field func is required for Call"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Call_kind; p->v.Call.func = func; p->v.Call.args = args; p->v.Call.keywords = keywords; p->v.Call.starargs = starargs; p->v.Call.kwargs = kwargs; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyRepr(expr_ty value, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Repr"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Repr_kind; p->v.Repr.value = value; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyNum(object n, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!n) { PyErr_SetString(PyExc_ValueError, "field n is required for Num"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Num_kind; p->v.Num.n = n; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyStr(string s, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!s) { PyErr_SetString(PyExc_ValueError, "field s is required for Str"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Str_kind; p->v.Str.s = s; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyAttribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Attribute"); return NULL; } if (!attr) { PyErr_SetString(PyExc_ValueError, "field attr is required for Attribute"); return NULL; } if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Attribute"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Attribute_kind; p->v.Attribute.value = value; p->v.Attribute.attr = attr; p->v.Attribute.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tySubscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Subscript"); return NULL; } if (!slice) { PyErr_SetString(PyExc_ValueError, "field slice is required for Subscript"); return NULL; } if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Subscript"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Subscript_kind; p->v.Subscript.value = value; p->v.Subscript.slice = slice; p->v.Subscript.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyName(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!id) { PyErr_SetString(PyExc_ValueError, "field id is required for Name"); return NULL; } if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Name"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Name_kind; p->v.Name.id = id; p->v.Name.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyList(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for List"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = List_kind; p->v.List.elts = elts; p->v.List.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p;} expr_tyTuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena){ expr_ty p; if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Tuple"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Tuple_kind; p->v.Tuple.elts = elts; p->v.Tuple.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p;} slice_tyEllipsis(PyArena *arena){ slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Ellipsis_kind; return p;} slice_tySlice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena){ slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Slice_kind; p->v.Slice.lower = lower; p->v.Slice.upper = upper; p->v.Slice.step = step; return p;} slice_tyExtSlice(asdl_seq * dims, PyArena *arena){ slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = ExtSlice_kind; p->v.ExtSlice.dims = dims; return p;} slice_tyIndex(expr_ty value, PyArena *arena){ slice_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Index"); return NULL; } p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Index_kind; p->v.Index.value = value; return p;} comprehension_tycomprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena){ comprehension_ty p; if (!target) { PyErr_SetString(PyExc_ValueError, "field target is required for comprehension"); return NULL; } if (!iter) { PyErr_SetString(PyExc_ValueError, "field iter is required for comprehension"); return NULL; } p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->target = target; p->iter = iter; p->ifs = ifs; return p;} excepthandler_tyexcepthandler(expr_ty type, expr_ty name, asdl_seq * body, int lineno, int col_offset, PyArena *arena){ excepthandler_ty p; p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->type = type; p->name = name; p->body = body; p->lineno = lineno; p->col_offset = col_offset; return p;} arguments_tyarguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * defaults, PyArena *arena){ arguments_ty p; p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->args = args; p->vararg = vararg; p->kwarg = kwarg; p->defaults = defaults; return p;} keyword_tykeyword(identifier arg, expr_ty value, PyArena *arena){ keyword_ty p; if (!arg) { PyErr_SetString(PyExc_ValueError, "field arg is required for keyword"); return NULL; } if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for keyword"); return NULL; } p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->arg = arg; p->value = value; return p;} alias_tyalias(identifier name, identifier asname, PyArena *arena){ alias_ty p; if (!name) { PyErr_SetString(PyExc_ValueError, "field name is required for alias"); return NULL; } p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->name = name; p->asname = asname; return p;} PyObject*ast2obj_mod(void* _o){ mod_ty o = (mod_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { Py_INCREF(Py_None); return Py_None; } switch (o->kind) { case Module_kind: result = PyType_GenericNew(Module_type, NULL, NULL); if (!result) goto failed; value = ast2obj_list(o->v.Module.body, ast2obj_stmt); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; case Interactive_kind: result = PyType_GenericNew(Interactive_type, NULL, NULL); if (!result) goto failed; value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; case Expression_kind: result = PyType_GenericNew(Expression_type, NULL, NULL); if (!result) goto failed; value = ast2obj_expr(o->v.Expression.body); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; case Suite_kind: result = PyType_GenericNew(Suite_type, NULL, NULL); if (!result) goto failed; value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; } return result;failed: Py_XDECREF(value); Py_XDECREF(result); return NULL;} PyObject*ast2obj_stmt(void* _o){ stmt_ty o = (stmt_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { Py_INCREF(Py_None); return Py_None; } switch (o->kind) { case FunctionDef_kind: result = PyType_GenericNew(FunctionDef_type, NULL, NULL); if (!result) goto failed; value = ast2obj_identifier(o->v.FunctionDef.name); if (!value) goto failed; if (PyObject_SetAttrString(result, "name", value) == -1) goto failed; Py_DECREF(value); value = ast2obj_arguments(o->v.FunctionDef.args);Lines 1501–2000 of 3202. Previous lines Load more
p->col_offset = col_offset; return p; } expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!left) { PyErr_SetString(PyExc_ValueError, "field left is required for Compare"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Compare_kind; p->v.Compare.left = left; p->v.Compare.ops = ops; p->v.Compare.comparators = comparators; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, expr_ty kwargs, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!func) { PyErr_SetString(PyExc_ValueError, "field func is required for Call"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Call_kind; p->v.Call.func = func; p->v.Call.args = args; p->v.Call.keywords = keywords; p->v.Call.starargs = starargs; p->v.Call.kwargs = kwargs; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Repr(expr_ty value, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Repr"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Repr_kind; p->v.Repr.value = value; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Num(object n, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!n) { PyErr_SetString(PyExc_ValueError, "field n is required for Num"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Num_kind; p->v.Num.n = n; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Str(string s, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!s) { PyErr_SetString(PyExc_ValueError, "field s is required for Str"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Str_kind; p->v.Str.s = s; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Attribute"); return NULL; } if (!attr) { PyErr_SetString(PyExc_ValueError, "field attr is required for Attribute"); return NULL; } if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Attribute"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Attribute_kind; p->v.Attribute.value = value; p->v.Attribute.attr = attr; p->v.Attribute.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Subscript"); return NULL; } if (!slice) { PyErr_SetString(PyExc_ValueError, "field slice is required for Subscript"); return NULL; } if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Subscript"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Subscript_kind; p->v.Subscript.value = value; p->v.Subscript.slice = slice; p->v.Subscript.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!id) { PyErr_SetString(PyExc_ValueError, "field id is required for Name"); return NULL; } if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Name"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Name_kind; p->v.Name.id = id; p->v.Name.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for List"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = List_kind; p->v.List.elts = elts; p->v.List.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena) { expr_ty p; if (!ctx) { PyErr_SetString(PyExc_ValueError, "field ctx is required for Tuple"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Tuple_kind; p->v.Tuple.elts = elts; p->v.Tuple.ctx = ctx; p->lineno = lineno; p->col_offset = col_offset; return p; } slice_ty Ellipsis(PyArena *arena) { slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Ellipsis_kind; return p; } slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) { slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Slice_kind; p->v.Slice.lower = lower; p->v.Slice.upper = upper; p->v.Slice.step = step; return p; } slice_ty ExtSlice(asdl_seq * dims, PyArena *arena) { slice_ty p; p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = ExtSlice_kind; p->v.ExtSlice.dims = dims; return p; } slice_ty Index(expr_ty value, PyArena *arena) { slice_ty p; if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for Index"); return NULL; } p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->kind = Index_kind; p->v.Index.value = value; return p; } comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) { comprehension_ty p; if (!target) { PyErr_SetString(PyExc_ValueError, "field target is required for comprehension"); return NULL; } if (!iter) { PyErr_SetString(PyExc_ValueError, "field iter is required for comprehension"); return NULL; } p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->target = target; p->iter = iter; p->ifs = ifs; return p; } excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body, int lineno, int col_offset, PyArena *arena) { excepthandler_ty p; p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->type = type; p->name = name; p->body = body; p->lineno = lineno; p->col_offset = col_offset; return p; } arguments_ty arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * defaults, PyArena *arena) { arguments_ty p; p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->args = args; p->vararg = vararg; p->kwarg = kwarg; p->defaults = defaults; return p; } keyword_ty keyword(identifier arg, expr_ty value, PyArena *arena) { keyword_ty p; if (!arg) { PyErr_SetString(PyExc_ValueError, "field arg is required for keyword"); return NULL; } if (!value) { PyErr_SetString(PyExc_ValueError, "field value is required for keyword"); return NULL; } p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->arg = arg; p->value = value; return p; } alias_ty alias(identifier name, identifier asname, PyArena *arena) { alias_ty p; if (!name) { PyErr_SetString(PyExc_ValueError, "field name is required for alias"); return NULL; } p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } p->name = name; p->asname = asname; return p; } PyObject* ast2obj_mod(void* _o) { mod_ty o = (mod_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { Py_INCREF(Py_None); return Py_None; } switch (o->kind) { case Module_kind: result = PyType_GenericNew(Module_type, NULL, NULL); if (!result) goto failed; value = ast2obj_list(o->v.Module.body, ast2obj_stmt); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; case Interactive_kind: result = PyType_GenericNew(Interactive_type, NULL, NULL); if (!result) goto failed; value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; case Expression_kind: result = PyType_GenericNew(Expression_type, NULL, NULL); if (!result) goto failed; value = ast2obj_expr(o->v.Expression.body); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; case Suite_kind: result = PyType_GenericNew(Suite_type, NULL, NULL); if (!result) goto failed; value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); if (!value) goto failed; if (PyObject_SetAttrString(result, "body", value) == -1) goto failed; Py_DECREF(value); break; } return result; failed: Py_XDECREF(value); Py_XDECREF(result); return NULL; } PyObject* ast2obj_stmt(void* _o) { stmt_ty o = (stmt_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { Py_INCREF(Py_None); return Py_None; } switch (o->kind) { case FunctionDef_kind: result = PyType_GenericNew(FunctionDef_type, NULL, NULL); if (!result) goto failed; value = ast2obj_identifier(o->v.FunctionDef.name); if (!value) goto failed; if (PyObject_SetAttrString(result, "name", value) == -1) goto failed; Py_DECREF(value); value = ast2obj_arguments(o->v.FunctionDef.args);