Mercurial > cpython-lru_cache-weakref
annotate Python/Python-ast.c @ 36174:85b2d804ac0a legacy-trunk
Regenerate.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Mon, 02 Jan 2006 21:18:55 +0000 |
| parents | ea083efdc96c |
| children | 3c0b26113df6 |
| rev | line source |
|---|---|
|
36003
52f1d57f237d
SF #1373150, diffs in working copy after a build
Neal Norwitz <nnorwitz@gmail.com>
parents:
35866
diff
changeset
|
1 /* File automatically generated by Parser/asdl_c.py */ |
| 35742 | 2 |
| 3 #include "Python.h" | |
| 4 #include "Python-ast.h" | |
| 5 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
6 static int marshal_write_mod(PyObject **, int *, mod_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
7 static int marshal_write_stmt(PyObject **, int *, stmt_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
8 static int marshal_write_expr(PyObject **, int *, expr_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
9 static int marshal_write_expr_context(PyObject **, int *, expr_context_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
10 static int marshal_write_slice(PyObject **, int *, slice_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
11 static int marshal_write_boolop(PyObject **, int *, boolop_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
12 static int marshal_write_operator(PyObject **, int *, operator_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
13 static int marshal_write_unaryop(PyObject **, int *, unaryop_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
14 static int marshal_write_cmpop(PyObject **, int *, cmpop_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
15 static int marshal_write_comprehension(PyObject **, int *, comprehension_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
16 static int marshal_write_excepthandler(PyObject **, int *, excepthandler_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
17 static int marshal_write_arguments(PyObject **, int *, arguments_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
18 static int marshal_write_keyword(PyObject **, int *, keyword_ty); |
|
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
19 static int marshal_write_alias(PyObject **, int *, alias_ty); |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
20 |
| 35742 | 21 mod_ty |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
22 Module(asdl_seq * body, PyArena *arena) |
| 35742 | 23 { |
| 24 mod_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
25 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 26 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
27 PyErr_NoMemory(); |
| 35742 | 28 return NULL; |
| 29 } | |
| 30 p->kind = Module_kind; | |
| 31 p->v.Module.body = body; | |
| 32 return p; | |
| 33 } | |
| 34 | |
| 35 mod_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
36 Interactive(asdl_seq * body, PyArena *arena) |
| 35742 | 37 { |
| 38 mod_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
39 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 40 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
41 PyErr_NoMemory(); |
| 35742 | 42 return NULL; |
| 43 } | |
| 44 p->kind = Interactive_kind; | |
| 45 p->v.Interactive.body = body; | |
| 46 return p; | |
| 47 } | |
| 48 | |
| 49 mod_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
50 Expression(expr_ty body, PyArena *arena) |
| 35742 | 51 { |
| 52 mod_ty p; | |
| 53 if (!body) { | |
| 54 PyErr_SetString(PyExc_ValueError, | |
| 55 "field body is required for Expression"); | |
| 56 return NULL; | |
| 57 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
58 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 59 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
60 PyErr_NoMemory(); |
| 35742 | 61 return NULL; |
| 62 } | |
| 63 p->kind = Expression_kind; | |
| 64 p->v.Expression.body = body; | |
| 65 return p; | |
| 66 } | |
| 67 | |
| 68 mod_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
69 Suite(asdl_seq * body, PyArena *arena) |
| 35742 | 70 { |
| 71 mod_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
72 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 73 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
74 PyErr_NoMemory(); |
| 35742 | 75 return NULL; |
| 76 } | |
| 77 p->kind = Suite_kind; | |
| 78 p->v.Suite.body = body; | |
| 79 return p; | |
| 80 } | |
| 81 | |
| 82 stmt_ty | |
| 83 FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq * | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
84 decorators, int lineno, PyArena *arena) |
| 35742 | 85 { |
| 86 stmt_ty p; | |
| 87 if (!name) { | |
| 88 PyErr_SetString(PyExc_ValueError, | |
| 89 "field name is required for FunctionDef"); | |
| 90 return NULL; | |
| 91 } | |
| 92 if (!args) { | |
| 93 PyErr_SetString(PyExc_ValueError, | |
| 94 "field args is required for FunctionDef"); | |
| 95 return NULL; | |
| 96 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
97 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 98 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
99 PyErr_NoMemory(); |
| 35742 | 100 return NULL; |
| 101 } | |
| 102 p->kind = FunctionDef_kind; | |
| 103 p->v.FunctionDef.name = name; | |
| 104 p->v.FunctionDef.args = args; | |
| 105 p->v.FunctionDef.body = body; | |
| 106 p->v.FunctionDef.decorators = decorators; | |
| 107 p->lineno = lineno; | |
| 108 return p; | |
| 109 } | |
| 110 | |
| 111 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
112 ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno, |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
113 PyArena *arena) |
| 35742 | 114 { |
| 115 stmt_ty p; | |
| 116 if (!name) { | |
| 117 PyErr_SetString(PyExc_ValueError, | |
| 118 "field name is required for ClassDef"); | |
| 119 return NULL; | |
| 120 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
121 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 122 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
123 PyErr_NoMemory(); |
| 35742 | 124 return NULL; |
| 125 } | |
| 126 p->kind = ClassDef_kind; | |
| 127 p->v.ClassDef.name = name; | |
| 128 p->v.ClassDef.bases = bases; | |
| 129 p->v.ClassDef.body = body; | |
| 130 p->lineno = lineno; | |
| 131 return p; | |
| 132 } | |
| 133 | |
| 134 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
135 Return(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 136 { |
| 137 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
138 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 139 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
140 PyErr_NoMemory(); |
| 35742 | 141 return NULL; |
| 142 } | |
| 143 p->kind = Return_kind; | |
| 144 p->v.Return.value = value; | |
| 145 p->lineno = lineno; | |
| 146 return p; | |
| 147 } | |
| 148 | |
| 149 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
150 Delete(asdl_seq * targets, int lineno, PyArena *arena) |
| 35742 | 151 { |
| 152 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
153 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 154 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
155 PyErr_NoMemory(); |
| 35742 | 156 return NULL; |
| 157 } | |
| 158 p->kind = Delete_kind; | |
| 159 p->v.Delete.targets = targets; | |
| 160 p->lineno = lineno; | |
| 161 return p; | |
| 162 } | |
| 163 | |
| 164 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
165 Assign(asdl_seq * targets, expr_ty value, int lineno, PyArena *arena) |
| 35742 | 166 { |
| 167 stmt_ty p; | |
| 168 if (!value) { | |
| 169 PyErr_SetString(PyExc_ValueError, | |
| 170 "field value is required for Assign"); | |
| 171 return NULL; | |
| 172 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
173 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 174 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
175 PyErr_NoMemory(); |
| 35742 | 176 return NULL; |
| 177 } | |
| 178 p->kind = Assign_kind; | |
| 179 p->v.Assign.targets = targets; | |
| 180 p->v.Assign.value = value; | |
| 181 p->lineno = lineno; | |
| 182 return p; | |
| 183 } | |
| 184 | |
| 185 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
186 AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, PyArena |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
187 *arena) |
| 35742 | 188 { |
| 189 stmt_ty p; | |
| 190 if (!target) { | |
| 191 PyErr_SetString(PyExc_ValueError, | |
| 192 "field target is required for AugAssign"); | |
| 193 return NULL; | |
| 194 } | |
| 195 if (!op) { | |
| 196 PyErr_SetString(PyExc_ValueError, | |
| 197 "field op is required for AugAssign"); | |
| 198 return NULL; | |
| 199 } | |
| 200 if (!value) { | |
| 201 PyErr_SetString(PyExc_ValueError, | |
| 202 "field value is required for AugAssign"); | |
| 203 return NULL; | |
| 204 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
205 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 206 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
207 PyErr_NoMemory(); |
| 35742 | 208 return NULL; |
| 209 } | |
| 210 p->kind = AugAssign_kind; | |
| 211 p->v.AugAssign.target = target; | |
| 212 p->v.AugAssign.op = op; | |
| 213 p->v.AugAssign.value = value; | |
| 214 p->lineno = lineno; | |
| 215 return p; | |
| 216 } | |
| 217 | |
| 218 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
219 Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, PyArena *arena) |
| 35742 | 220 { |
| 221 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
222 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 223 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
224 PyErr_NoMemory(); |
| 35742 | 225 return NULL; |
| 226 } | |
| 227 p->kind = Print_kind; | |
| 228 p->v.Print.dest = dest; | |
| 229 p->v.Print.values = values; | |
| 230 p->v.Print.nl = nl; | |
| 231 p->lineno = lineno; | |
| 232 return p; | |
| 233 } | |
| 234 | |
| 235 stmt_ty | |
| 236 For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, int | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
237 lineno, PyArena *arena) |
| 35742 | 238 { |
| 239 stmt_ty p; | |
| 240 if (!target) { | |
| 241 PyErr_SetString(PyExc_ValueError, | |
| 242 "field target is required for For"); | |
| 243 return NULL; | |
| 244 } | |
| 245 if (!iter) { | |
| 246 PyErr_SetString(PyExc_ValueError, | |
| 247 "field iter is required for For"); | |
| 248 return NULL; | |
| 249 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
250 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 251 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
252 PyErr_NoMemory(); |
| 35742 | 253 return NULL; |
| 254 } | |
| 255 p->kind = For_kind; | |
| 256 p->v.For.target = target; | |
| 257 p->v.For.iter = iter; | |
| 258 p->v.For.body = body; | |
| 259 p->v.For.orelse = orelse; | |
| 260 p->lineno = lineno; | |
| 261 return p; | |
| 262 } | |
| 263 | |
| 264 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
265 While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, PyArena |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
266 *arena) |
| 35742 | 267 { |
| 268 stmt_ty p; | |
| 269 if (!test) { | |
| 270 PyErr_SetString(PyExc_ValueError, | |
| 271 "field test is required for While"); | |
| 272 return NULL; | |
| 273 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
274 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 275 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
276 PyErr_NoMemory(); |
| 35742 | 277 return NULL; |
| 278 } | |
| 279 p->kind = While_kind; | |
| 280 p->v.While.test = test; | |
| 281 p->v.While.body = body; | |
| 282 p->v.While.orelse = orelse; | |
| 283 p->lineno = lineno; | |
| 284 return p; | |
| 285 } | |
| 286 | |
| 287 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
288 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, PyArena *arena) |
| 35742 | 289 { |
| 290 stmt_ty p; | |
| 291 if (!test) { | |
| 292 PyErr_SetString(PyExc_ValueError, | |
| 293 "field test is required for If"); | |
| 294 return NULL; | |
| 295 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
296 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 297 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
298 PyErr_NoMemory(); |
| 35742 | 299 return NULL; |
| 300 } | |
| 301 p->kind = If_kind; | |
| 302 p->v.If.test = test; | |
| 303 p->v.If.body = body; | |
| 304 p->v.If.orelse = orelse; | |
| 305 p->lineno = lineno; | |
| 306 return p; | |
| 307 } | |
| 308 | |
| 309 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
310 Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, PyArena *arena) |
| 35742 | 311 { |
| 312 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
313 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 314 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
315 PyErr_NoMemory(); |
| 35742 | 316 return NULL; |
| 317 } | |
| 318 p->kind = Raise_kind; | |
| 319 p->v.Raise.type = type; | |
| 320 p->v.Raise.inst = inst; | |
| 321 p->v.Raise.tback = tback; | |
| 322 p->lineno = lineno; | |
| 323 return p; | |
| 324 } | |
| 325 | |
| 326 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
327 TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int lineno, |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
328 PyArena *arena) |
| 35742 | 329 { |
| 330 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
331 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 332 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
333 PyErr_NoMemory(); |
| 35742 | 334 return NULL; |
| 335 } | |
| 336 p->kind = TryExcept_kind; | |
| 337 p->v.TryExcept.body = body; | |
| 338 p->v.TryExcept.handlers = handlers; | |
| 339 p->v.TryExcept.orelse = orelse; | |
| 340 p->lineno = lineno; | |
| 341 return p; | |
| 342 } | |
| 343 | |
| 344 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
345 TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, PyArena *arena) |
| 35742 | 346 { |
| 347 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
348 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 349 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
350 PyErr_NoMemory(); |
| 35742 | 351 return NULL; |
| 352 } | |
| 353 p->kind = TryFinally_kind; | |
| 354 p->v.TryFinally.body = body; | |
| 355 p->v.TryFinally.finalbody = finalbody; | |
| 356 p->lineno = lineno; | |
| 357 return p; | |
| 358 } | |
| 359 | |
| 360 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
361 Assert(expr_ty test, expr_ty msg, int lineno, PyArena *arena) |
| 35742 | 362 { |
| 363 stmt_ty p; | |
| 364 if (!test) { | |
| 365 PyErr_SetString(PyExc_ValueError, | |
| 366 "field test is required for Assert"); | |
| 367 return NULL; | |
| 368 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
369 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 370 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
371 PyErr_NoMemory(); |
| 35742 | 372 return NULL; |
| 373 } | |
| 374 p->kind = Assert_kind; | |
| 375 p->v.Assert.test = test; | |
| 376 p->v.Assert.msg = msg; | |
| 377 p->lineno = lineno; | |
| 378 return p; | |
| 379 } | |
| 380 | |
| 381 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
382 Import(asdl_seq * names, int lineno, PyArena *arena) |
| 35742 | 383 { |
| 384 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
385 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 386 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
387 PyErr_NoMemory(); |
| 35742 | 388 return NULL; |
| 389 } | |
| 390 p->kind = Import_kind; | |
| 391 p->v.Import.names = names; | |
| 392 p->lineno = lineno; | |
| 393 return p; | |
| 394 } | |
| 395 | |
| 396 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
397 ImportFrom(identifier module, asdl_seq * names, int lineno, PyArena *arena) |
| 35742 | 398 { |
| 399 stmt_ty p; | |
| 400 if (!module) { | |
| 401 PyErr_SetString(PyExc_ValueError, | |
| 402 "field module is required for ImportFrom"); | |
| 403 return NULL; | |
| 404 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
405 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 406 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
407 PyErr_NoMemory(); |
| 35742 | 408 return NULL; |
| 409 } | |
| 410 p->kind = ImportFrom_kind; | |
| 411 p->v.ImportFrom.module = module; | |
| 412 p->v.ImportFrom.names = names; | |
| 413 p->lineno = lineno; | |
| 414 return p; | |
| 415 } | |
| 416 | |
| 417 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
418 Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, PyArena *arena) |
| 35742 | 419 { |
| 420 stmt_ty p; | |
| 421 if (!body) { | |
| 422 PyErr_SetString(PyExc_ValueError, | |
| 423 "field body is required for Exec"); | |
| 424 return NULL; | |
| 425 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
426 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 427 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
428 PyErr_NoMemory(); |
| 35742 | 429 return NULL; |
| 430 } | |
| 431 p->kind = Exec_kind; | |
| 432 p->v.Exec.body = body; | |
| 433 p->v.Exec.globals = globals; | |
| 434 p->v.Exec.locals = locals; | |
| 435 p->lineno = lineno; | |
| 436 return p; | |
| 437 } | |
| 438 | |
| 439 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
440 Global(asdl_seq * names, int lineno, PyArena *arena) |
| 35742 | 441 { |
| 442 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
443 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 444 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
445 PyErr_NoMemory(); |
| 35742 | 446 return NULL; |
| 447 } | |
| 448 p->kind = Global_kind; | |
| 449 p->v.Global.names = names; | |
| 450 p->lineno = lineno; | |
| 451 return p; | |
| 452 } | |
| 453 | |
| 454 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
455 Expr(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 456 { |
| 457 stmt_ty p; | |
| 458 if (!value) { | |
| 459 PyErr_SetString(PyExc_ValueError, | |
| 460 "field value is required for Expr"); | |
| 461 return NULL; | |
| 462 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
463 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 464 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
465 PyErr_NoMemory(); |
| 35742 | 466 return NULL; |
| 467 } | |
| 468 p->kind = Expr_kind; | |
| 469 p->v.Expr.value = value; | |
| 470 p->lineno = lineno; | |
| 471 return p; | |
| 472 } | |
| 473 | |
| 474 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
475 Pass(int lineno, PyArena *arena) |
| 35742 | 476 { |
| 477 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
478 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 479 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
480 PyErr_NoMemory(); |
| 35742 | 481 return NULL; |
| 482 } | |
| 483 p->kind = Pass_kind; | |
| 484 p->lineno = lineno; | |
| 485 return p; | |
| 486 } | |
| 487 | |
| 488 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
489 Break(int lineno, PyArena *arena) |
| 35742 | 490 { |
| 491 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
492 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 493 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
494 PyErr_NoMemory(); |
| 35742 | 495 return NULL; |
| 496 } | |
| 497 p->kind = Break_kind; | |
| 498 p->lineno = lineno; | |
| 499 return p; | |
| 500 } | |
| 501 | |
| 502 stmt_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
503 Continue(int lineno, PyArena *arena) |
| 35742 | 504 { |
| 505 stmt_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
506 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 507 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
508 PyErr_NoMemory(); |
| 35742 | 509 return NULL; |
| 510 } | |
| 511 p->kind = Continue_kind; | |
| 512 p->lineno = lineno; | |
| 513 return p; | |
| 514 } | |
| 515 | |
| 516 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
517 BoolOp(boolop_ty op, asdl_seq * values, int lineno, PyArena *arena) |
| 35742 | 518 { |
| 519 expr_ty p; | |
| 520 if (!op) { | |
| 521 PyErr_SetString(PyExc_ValueError, | |
| 522 "field op is required for BoolOp"); | |
| 523 return NULL; | |
| 524 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
525 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 526 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
527 PyErr_NoMemory(); |
| 35742 | 528 return NULL; |
| 529 } | |
| 530 p->kind = BoolOp_kind; | |
| 531 p->v.BoolOp.op = op; | |
| 532 p->v.BoolOp.values = values; | |
| 533 p->lineno = lineno; | |
| 534 return p; | |
| 535 } | |
| 536 | |
| 537 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
538 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, PyArena *arena) |
| 35742 | 539 { |
| 540 expr_ty p; | |
| 541 if (!left) { | |
| 542 PyErr_SetString(PyExc_ValueError, | |
| 543 "field left is required for BinOp"); | |
| 544 return NULL; | |
| 545 } | |
| 546 if (!op) { | |
| 547 PyErr_SetString(PyExc_ValueError, | |
| 548 "field op is required for BinOp"); | |
| 549 return NULL; | |
| 550 } | |
| 551 if (!right) { | |
| 552 PyErr_SetString(PyExc_ValueError, | |
| 553 "field right is required for BinOp"); | |
| 554 return NULL; | |
| 555 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
556 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 557 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
558 PyErr_NoMemory(); |
| 35742 | 559 return NULL; |
| 560 } | |
| 561 p->kind = BinOp_kind; | |
| 562 p->v.BinOp.left = left; | |
| 563 p->v.BinOp.op = op; | |
| 564 p->v.BinOp.right = right; | |
| 565 p->lineno = lineno; | |
| 566 return p; | |
| 567 } | |
| 568 | |
| 569 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
570 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, PyArena *arena) |
| 35742 | 571 { |
| 572 expr_ty p; | |
| 573 if (!op) { | |
| 574 PyErr_SetString(PyExc_ValueError, | |
| 575 "field op is required for UnaryOp"); | |
| 576 return NULL; | |
| 577 } | |
| 578 if (!operand) { | |
| 579 PyErr_SetString(PyExc_ValueError, | |
| 580 "field operand is required for UnaryOp"); | |
| 581 return NULL; | |
| 582 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
583 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 584 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
585 PyErr_NoMemory(); |
| 35742 | 586 return NULL; |
| 587 } | |
| 588 p->kind = UnaryOp_kind; | |
| 589 p->v.UnaryOp.op = op; | |
| 590 p->v.UnaryOp.operand = operand; | |
| 591 p->lineno = lineno; | |
| 592 return p; | |
| 593 } | |
| 594 | |
| 595 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
596 Lambda(arguments_ty args, expr_ty body, int lineno, PyArena *arena) |
| 35742 | 597 { |
| 598 expr_ty p; | |
| 599 if (!args) { | |
| 600 PyErr_SetString(PyExc_ValueError, | |
| 601 "field args is required for Lambda"); | |
| 602 return NULL; | |
| 603 } | |
| 604 if (!body) { | |
| 605 PyErr_SetString(PyExc_ValueError, | |
| 606 "field body is required for Lambda"); | |
| 607 return NULL; | |
| 608 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
609 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 610 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
611 PyErr_NoMemory(); |
| 35742 | 612 return NULL; |
| 613 } | |
| 614 p->kind = Lambda_kind; | |
| 615 p->v.Lambda.args = args; | |
| 616 p->v.Lambda.body = body; | |
| 617 p->lineno = lineno; | |
| 618 return p; | |
| 619 } | |
| 620 | |
| 621 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
622 Dict(asdl_seq * keys, asdl_seq * values, int lineno, PyArena *arena) |
| 35742 | 623 { |
| 624 expr_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
625 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 626 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
627 PyErr_NoMemory(); |
| 35742 | 628 return NULL; |
| 629 } | |
| 630 p->kind = Dict_kind; | |
| 631 p->v.Dict.keys = keys; | |
| 632 p->v.Dict.values = values; | |
| 633 p->lineno = lineno; | |
| 634 return p; | |
| 635 } | |
| 636 | |
| 637 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
638 ListComp(expr_ty elt, asdl_seq * generators, int lineno, PyArena *arena) |
| 35742 | 639 { |
| 640 expr_ty p; | |
| 641 if (!elt) { | |
| 642 PyErr_SetString(PyExc_ValueError, | |
| 643 "field elt is required for ListComp"); | |
| 644 return NULL; | |
| 645 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
646 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 647 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
648 PyErr_NoMemory(); |
| 35742 | 649 return NULL; |
| 650 } | |
| 651 p->kind = ListComp_kind; | |
| 652 p->v.ListComp.elt = elt; | |
| 653 p->v.ListComp.generators = generators; | |
| 654 p->lineno = lineno; | |
| 655 return p; | |
| 656 } | |
| 657 | |
| 658 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
659 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, PyArena *arena) |
| 35742 | 660 { |
| 661 expr_ty p; | |
| 662 if (!elt) { | |
| 663 PyErr_SetString(PyExc_ValueError, | |
| 664 "field elt is required for GeneratorExp"); | |
| 665 return NULL; | |
| 666 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
667 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 668 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
669 PyErr_NoMemory(); |
| 35742 | 670 return NULL; |
| 671 } | |
| 672 p->kind = GeneratorExp_kind; | |
| 673 p->v.GeneratorExp.elt = elt; | |
| 674 p->v.GeneratorExp.generators = generators; | |
| 675 p->lineno = lineno; | |
| 676 return p; | |
| 677 } | |
| 678 | |
| 679 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
680 Yield(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 681 { |
| 682 expr_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
683 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 684 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
685 PyErr_NoMemory(); |
| 35742 | 686 return NULL; |
| 687 } | |
| 688 p->kind = Yield_kind; | |
| 689 p->v.Yield.value = value; | |
| 690 p->lineno = lineno; | |
| 691 return p; | |
| 692 } | |
| 693 | |
| 694 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
695 Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators, int lineno, |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
696 PyArena *arena) |
| 35742 | 697 { |
| 698 expr_ty p; | |
| 699 if (!left) { | |
| 700 PyErr_SetString(PyExc_ValueError, | |
| 701 "field left is required for Compare"); | |
| 702 return NULL; | |
| 703 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
704 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 705 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
706 PyErr_NoMemory(); |
| 35742 | 707 return NULL; |
| 708 } | |
| 709 p->kind = Compare_kind; | |
| 710 p->v.Compare.left = left; | |
| 711 p->v.Compare.ops = ops; | |
| 712 p->v.Compare.comparators = comparators; | |
| 713 p->lineno = lineno; | |
| 714 return p; | |
| 715 } | |
| 716 | |
| 717 expr_ty | |
| 718 Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
719 expr_ty kwargs, int lineno, PyArena *arena) |
| 35742 | 720 { |
| 721 expr_ty p; | |
| 722 if (!func) { | |
| 723 PyErr_SetString(PyExc_ValueError, | |
| 724 "field func is required for Call"); | |
| 725 return NULL; | |
| 726 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
727 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 728 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
729 PyErr_NoMemory(); |
| 35742 | 730 return NULL; |
| 731 } | |
| 732 p->kind = Call_kind; | |
| 733 p->v.Call.func = func; | |
| 734 p->v.Call.args = args; | |
| 735 p->v.Call.keywords = keywords; | |
| 736 p->v.Call.starargs = starargs; | |
| 737 p->v.Call.kwargs = kwargs; | |
| 738 p->lineno = lineno; | |
| 739 return p; | |
| 740 } | |
| 741 | |
| 742 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
743 Repr(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 744 { |
| 745 expr_ty p; | |
| 746 if (!value) { | |
| 747 PyErr_SetString(PyExc_ValueError, | |
| 748 "field value is required for Repr"); | |
| 749 return NULL; | |
| 750 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
751 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 752 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
753 PyErr_NoMemory(); |
| 35742 | 754 return NULL; |
| 755 } | |
| 756 p->kind = Repr_kind; | |
| 757 p->v.Repr.value = value; | |
| 758 p->lineno = lineno; | |
| 759 return p; | |
| 760 } | |
| 761 | |
| 762 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
763 Num(object n, int lineno, PyArena *arena) |
| 35742 | 764 { |
| 765 expr_ty p; | |
| 766 if (!n) { | |
| 767 PyErr_SetString(PyExc_ValueError, | |
| 768 "field n is required for Num"); | |
| 769 return NULL; | |
| 770 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
771 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 772 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
773 PyErr_NoMemory(); |
| 35742 | 774 return NULL; |
| 775 } | |
| 776 p->kind = Num_kind; | |
| 777 p->v.Num.n = n; | |
| 778 p->lineno = lineno; | |
| 779 return p; | |
| 780 } | |
| 781 | |
| 782 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
783 Str(string s, int lineno, PyArena *arena) |
| 35742 | 784 { |
| 785 expr_ty p; | |
| 786 if (!s) { | |
| 787 PyErr_SetString(PyExc_ValueError, | |
| 788 "field s is required for Str"); | |
| 789 return NULL; | |
| 790 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
791 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 792 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
793 PyErr_NoMemory(); |
| 35742 | 794 return NULL; |
| 795 } | |
| 796 p->kind = Str_kind; | |
| 797 p->v.Str.s = s; | |
| 798 p->lineno = lineno; | |
| 799 return p; | |
| 800 } | |
| 801 | |
| 802 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
803 Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
804 PyArena *arena) |
| 35742 | 805 { |
| 806 expr_ty p; | |
| 807 if (!value) { | |
| 808 PyErr_SetString(PyExc_ValueError, | |
| 809 "field value is required for Attribute"); | |
| 810 return NULL; | |
| 811 } | |
| 812 if (!attr) { | |
| 813 PyErr_SetString(PyExc_ValueError, | |
| 814 "field attr is required for Attribute"); | |
| 815 return NULL; | |
| 816 } | |
| 817 if (!ctx) { | |
| 818 PyErr_SetString(PyExc_ValueError, | |
| 819 "field ctx is required for Attribute"); | |
| 820 return NULL; | |
| 821 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
822 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 823 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
824 PyErr_NoMemory(); |
| 35742 | 825 return NULL; |
| 826 } | |
| 827 p->kind = Attribute_kind; | |
| 828 p->v.Attribute.value = value; | |
| 829 p->v.Attribute.attr = attr; | |
| 830 p->v.Attribute.ctx = ctx; | |
| 831 p->lineno = lineno; | |
| 832 return p; | |
| 833 } | |
| 834 | |
| 835 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
836 Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int lineno, |
|
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
837 PyArena *arena) |
| 35742 | 838 { |
| 839 expr_ty p; | |
| 840 if (!value) { | |
| 841 PyErr_SetString(PyExc_ValueError, | |
| 842 "field value is required for Subscript"); | |
| 843 return NULL; | |
| 844 } | |
| 845 if (!slice) { | |
| 846 PyErr_SetString(PyExc_ValueError, | |
| 847 "field slice is required for Subscript"); | |
| 848 return NULL; | |
| 849 } | |
| 850 if (!ctx) { | |
| 851 PyErr_SetString(PyExc_ValueError, | |
| 852 "field ctx is required for Subscript"); | |
| 853 return NULL; | |
| 854 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
855 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 856 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
857 PyErr_NoMemory(); |
| 35742 | 858 return NULL; |
| 859 } | |
| 860 p->kind = Subscript_kind; | |
| 861 p->v.Subscript.value = value; | |
| 862 p->v.Subscript.slice = slice; | |
| 863 p->v.Subscript.ctx = ctx; | |
| 864 p->lineno = lineno; | |
| 865 return p; | |
| 866 } | |
| 867 | |
| 868 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
869 Name(identifier id, expr_context_ty ctx, int lineno, PyArena *arena) |
| 35742 | 870 { |
| 871 expr_ty p; | |
| 872 if (!id) { | |
| 873 PyErr_SetString(PyExc_ValueError, | |
| 874 "field id is required for Name"); | |
| 875 return NULL; | |
| 876 } | |
| 877 if (!ctx) { | |
| 878 PyErr_SetString(PyExc_ValueError, | |
| 879 "field ctx is required for Name"); | |
| 880 return NULL; | |
| 881 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
882 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 883 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
884 PyErr_NoMemory(); |
| 35742 | 885 return NULL; |
| 886 } | |
| 887 p->kind = Name_kind; | |
| 888 p->v.Name.id = id; | |
| 889 p->v.Name.ctx = ctx; | |
| 890 p->lineno = lineno; | |
| 891 return p; | |
| 892 } | |
| 893 | |
| 894 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
895 List(asdl_seq * elts, expr_context_ty ctx, int lineno, PyArena *arena) |
| 35742 | 896 { |
| 897 expr_ty p; | |
| 898 if (!ctx) { | |
| 899 PyErr_SetString(PyExc_ValueError, | |
| 900 "field ctx is required for List"); | |
| 901 return NULL; | |
| 902 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
903 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 904 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
905 PyErr_NoMemory(); |
| 35742 | 906 return NULL; |
| 907 } | |
| 908 p->kind = List_kind; | |
| 909 p->v.List.elts = elts; | |
| 910 p->v.List.ctx = ctx; | |
| 911 p->lineno = lineno; | |
| 912 return p; | |
| 913 } | |
| 914 | |
| 915 expr_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
916 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, PyArena *arena) |
| 35742 | 917 { |
| 918 expr_ty p; | |
| 919 if (!ctx) { | |
| 920 PyErr_SetString(PyExc_ValueError, | |
| 921 "field ctx is required for Tuple"); | |
| 922 return NULL; | |
| 923 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
924 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 925 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
926 PyErr_NoMemory(); |
| 35742 | 927 return NULL; |
| 928 } | |
| 929 p->kind = Tuple_kind; | |
| 930 p->v.Tuple.elts = elts; | |
| 931 p->v.Tuple.ctx = ctx; | |
| 932 p->lineno = lineno; | |
| 933 return p; | |
| 934 } | |
| 935 | |
| 936 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
937 Ellipsis(PyArena *arena) |
| 35742 | 938 { |
| 939 slice_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
940 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 941 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
942 PyErr_NoMemory(); |
| 35742 | 943 return NULL; |
| 944 } | |
| 945 p->kind = Ellipsis_kind; | |
| 946 return p; | |
| 947 } | |
| 948 | |
| 949 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
950 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 35742 | 951 { |
| 952 slice_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
953 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 954 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
955 PyErr_NoMemory(); |
| 35742 | 956 return NULL; |
| 957 } | |
| 958 p->kind = Slice_kind; | |
| 959 p->v.Slice.lower = lower; | |
| 960 p->v.Slice.upper = upper; | |
| 961 p->v.Slice.step = step; | |
| 962 return p; | |
| 963 } | |
| 964 | |
| 965 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
966 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 35742 | 967 { |
| 968 slice_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
969 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 970 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
971 PyErr_NoMemory(); |
| 35742 | 972 return NULL; |
| 973 } | |
| 974 p->kind = ExtSlice_kind; | |
| 975 p->v.ExtSlice.dims = dims; | |
| 976 return p; | |
| 977 } | |
| 978 | |
| 979 slice_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
980 Index(expr_ty value, PyArena *arena) |
| 35742 | 981 { |
| 982 slice_ty p; | |
| 983 if (!value) { | |
| 984 PyErr_SetString(PyExc_ValueError, | |
| 985 "field value is required for Index"); | |
| 986 return NULL; | |
| 987 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
988 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 989 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
990 PyErr_NoMemory(); |
| 35742 | 991 return NULL; |
| 992 } | |
| 993 p->kind = Index_kind; | |
| 994 p->v.Index.value = value; | |
| 995 return p; | |
| 996 } | |
| 997 | |
| 998 comprehension_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
999 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 35742 | 1000 { |
| 1001 comprehension_ty p; | |
| 1002 if (!target) { | |
| 1003 PyErr_SetString(PyExc_ValueError, | |
| 1004 "field target is required for comprehension"); | |
| 1005 return NULL; | |
| 1006 } | |
| 1007 if (!iter) { | |
| 1008 PyErr_SetString(PyExc_ValueError, | |
| 1009 "field iter is required for comprehension"); | |
| 1010 return NULL; | |
| 1011 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1012 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1013 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1014 PyErr_NoMemory(); |
| 35742 | 1015 return NULL; |
| 1016 } | |
| 1017 p->target = target; | |
| 1018 p->iter = iter; | |
| 1019 p->ifs = ifs; | |
| 1020 return p; | |
| 1021 } | |
| 1022 | |
| 1023 excepthandler_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1024 excepthandler(expr_ty type, expr_ty name, asdl_seq * body, PyArena *arena) |
| 35742 | 1025 { |
| 1026 excepthandler_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1027 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1028 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1029 PyErr_NoMemory(); |
| 35742 | 1030 return NULL; |
| 1031 } | |
| 1032 p->type = type; | |
| 1033 p->name = name; | |
| 1034 p->body = body; | |
| 1035 return p; | |
| 1036 } | |
| 1037 | |
| 1038 arguments_ty | |
| 1039 arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1040 defaults, PyArena *arena) |
| 35742 | 1041 { |
| 1042 arguments_ty p; | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1043 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1044 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1045 PyErr_NoMemory(); |
| 35742 | 1046 return NULL; |
| 1047 } | |
| 1048 p->args = args; | |
| 1049 p->vararg = vararg; | |
| 1050 p->kwarg = kwarg; | |
| 1051 p->defaults = defaults; | |
| 1052 return p; | |
| 1053 } | |
| 1054 | |
| 1055 keyword_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1056 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 35742 | 1057 { |
| 1058 keyword_ty p; | |
| 1059 if (!arg) { | |
| 1060 PyErr_SetString(PyExc_ValueError, | |
| 1061 "field arg is required for keyword"); | |
| 1062 return NULL; | |
| 1063 } | |
| 1064 if (!value) { | |
| 1065 PyErr_SetString(PyExc_ValueError, | |
| 1066 "field value is required for keyword"); | |
| 1067 return NULL; | |
| 1068 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1069 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1070 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1071 PyErr_NoMemory(); |
| 35742 | 1072 return NULL; |
| 1073 } | |
| 1074 p->arg = arg; | |
| 1075 p->value = value; | |
| 1076 return p; | |
| 1077 } | |
| 1078 | |
| 1079 alias_ty | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1080 alias(identifier name, identifier asname, PyArena *arena) |
| 35742 | 1081 { |
| 1082 alias_ty p; | |
| 1083 if (!name) { | |
| 1084 PyErr_SetString(PyExc_ValueError, | |
| 1085 "field name is required for alias"); | |
| 1086 return NULL; | |
| 1087 } | |
|
36065
ea083efdc96c
Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
Neal Norwitz <nnorwitz@gmail.com>
parents:
36003
diff
changeset
|
1088 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1089 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1090 PyErr_NoMemory(); |
| 35742 | 1091 return NULL; |
| 1092 } | |
| 1093 p->name = name; | |
| 1094 p->asname = asname; | |
| 1095 return p; | |
| 1096 } | |
| 1097 | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1098 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1099 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1100 #define CHECKSIZE(BUF, OFF, MIN) { \ |
| 36174 | 1101 int need = *(OFF) + MIN; \ |
| 1102 if (need >= PyString_GET_SIZE(*(BUF))) { \ | |
| 1103 int newsize = PyString_GET_SIZE(*(BUF)) * 2; \ | |
| 1104 if (newsize < need) \ | |
| 1105 newsize = need; \ | |
| 1106 if (_PyString_Resize((BUF), newsize) < 0) \ | |
| 1107 return 0; \ | |
| 1108 } \ | |
| 1109 } | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1110 |
| 36174 | 1111 static int |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1112 marshal_write_int(PyObject **buf, int *offset, int x) |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1113 { |
| 36174 | 1114 char *s; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1115 |
| 36174 | 1116 CHECKSIZE(buf, offset, 4) |
| 1117 s = PyString_AS_STRING(*buf) + (*offset); | |
| 1118 s[0] = (x & 0xff); | |
| 1119 s[1] = (x >> 8) & 0xff; | |
| 1120 s[2] = (x >> 16) & 0xff; | |
| 1121 s[3] = (x >> 24) & 0xff; | |
| 1122 *offset += 4; | |
| 1123 return 1; | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1124 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1125 |
| 36174 | 1126 static int |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1127 marshal_write_bool(PyObject **buf, int *offset, bool b) |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1128 { |
| 36174 | 1129 if (b) |
| 1130 marshal_write_int(buf, offset, 1); | |
| 1131 else | |
| 1132 marshal_write_int(buf, offset, 0); | |
| 1133 return 1; | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1134 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1135 |
| 36174 | 1136 static int |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1137 marshal_write_identifier(PyObject **buf, int *offset, identifier id) |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1138 { |
| 36174 | 1139 int l = PyString_GET_SIZE(id); |
| 1140 marshal_write_int(buf, offset, l); | |
| 1141 CHECKSIZE(buf, offset, l); | |
| 1142 memcpy(PyString_AS_STRING(*buf) + *offset, | |
| 1143 PyString_AS_STRING(id), l); | |
| 1144 *offset += l; | |
| 1145 return 1; | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1146 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1147 |
| 36174 | 1148 static int |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1149 marshal_write_string(PyObject **buf, int *offset, string s) |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1150 { |
| 36174 | 1151 int len = PyString_GET_SIZE(s); |
| 1152 marshal_write_int(buf, offset, len); | |
| 1153 CHECKSIZE(buf, offset, len); | |
| 1154 memcpy(PyString_AS_STRING(*buf) + *offset, | |
| 1155 PyString_AS_STRING(s), len); | |
| 1156 *offset += len; | |
| 1157 return 1; | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1158 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1159 |
| 36174 | 1160 static int |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1161 marshal_write_object(PyObject **buf, int *offset, object s) |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1162 { |
| 36174 | 1163 /* XXX */ |
| 1164 return 0; | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1165 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1166 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1167 |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1168 static int |
| 35742 | 1169 marshal_write_mod(PyObject **buf, int *off, mod_ty o) |
| 1170 { | |
| 1171 int i; | |
| 1172 switch (o->kind) { | |
| 1173 case Module_kind: | |
| 1174 marshal_write_int(buf, off, 1); | |
| 1175 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Module.body)); | |
| 1176 for (i = 0; i < asdl_seq_LEN(o->v.Module.body); i++) { | |
| 1177 void *elt = asdl_seq_GET(o->v.Module.body, i); | |
| 1178 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1179 } | |
| 1180 break; | |
| 1181 case Interactive_kind: | |
| 1182 marshal_write_int(buf, off, 2); | |
| 1183 marshal_write_int(buf, off, | |
| 1184 asdl_seq_LEN(o->v.Interactive.body)); | |
| 1185 for (i = 0; i < asdl_seq_LEN(o->v.Interactive.body); i++) { | |
| 1186 void *elt = asdl_seq_GET(o->v.Interactive.body, i); | |
| 1187 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1188 } | |
| 1189 break; | |
| 1190 case Expression_kind: | |
| 1191 marshal_write_int(buf, off, 3); | |
| 1192 marshal_write_expr(buf, off, o->v.Expression.body); | |
| 1193 break; | |
| 1194 case Suite_kind: | |
| 1195 marshal_write_int(buf, off, 4); | |
| 1196 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Suite.body)); | |
| 1197 for (i = 0; i < asdl_seq_LEN(o->v.Suite.body); i++) { | |
| 1198 void *elt = asdl_seq_GET(o->v.Suite.body, i); | |
| 1199 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1200 } | |
| 1201 break; | |
| 1202 } | |
| 1203 return 1; | |
| 1204 } | |
| 1205 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1206 static int |
| 35742 | 1207 marshal_write_stmt(PyObject **buf, int *off, stmt_ty o) |
| 1208 { | |
| 1209 int i; | |
| 1210 switch (o->kind) { | |
| 1211 case FunctionDef_kind: | |
| 1212 marshal_write_int(buf, off, 1); | |
| 1213 marshal_write_identifier(buf, off, o->v.FunctionDef.name); | |
| 1214 marshal_write_arguments(buf, off, o->v.FunctionDef.args); | |
| 1215 marshal_write_int(buf, off, | |
| 1216 asdl_seq_LEN(o->v.FunctionDef.body)); | |
| 1217 for (i = 0; i < asdl_seq_LEN(o->v.FunctionDef.body); i++) { | |
| 1218 void *elt = asdl_seq_GET(o->v.FunctionDef.body, i); | |
| 1219 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1220 } | |
| 1221 marshal_write_int(buf, off, | |
| 1222 asdl_seq_LEN(o->v.FunctionDef.decorators)); | |
| 1223 for (i = 0; i < asdl_seq_LEN(o->v.FunctionDef.decorators); i++) | |
| 1224 { | |
| 1225 void *elt = asdl_seq_GET(o->v.FunctionDef.decorators, | |
| 1226 i); | |
| 1227 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1228 } | |
| 1229 break; | |
| 1230 case ClassDef_kind: | |
| 1231 marshal_write_int(buf, off, 2); | |
| 1232 marshal_write_identifier(buf, off, o->v.ClassDef.name); | |
| 1233 marshal_write_int(buf, off, asdl_seq_LEN(o->v.ClassDef.bases)); | |
| 1234 for (i = 0; i < asdl_seq_LEN(o->v.ClassDef.bases); i++) { | |
| 1235 void *elt = asdl_seq_GET(o->v.ClassDef.bases, i); | |
| 1236 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1237 } | |
| 1238 marshal_write_int(buf, off, asdl_seq_LEN(o->v.ClassDef.body)); | |
| 1239 for (i = 0; i < asdl_seq_LEN(o->v.ClassDef.body); i++) { | |
| 1240 void *elt = asdl_seq_GET(o->v.ClassDef.body, i); | |
| 1241 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1242 } | |
| 1243 break; | |
| 1244 case Return_kind: | |
| 1245 marshal_write_int(buf, off, 3); | |
| 1246 if (o->v.Return.value) { | |
| 1247 marshal_write_int(buf, off, 1); | |
| 1248 marshal_write_expr(buf, off, o->v.Return.value); | |
| 1249 } | |
| 1250 else { | |
| 1251 marshal_write_int(buf, off, 0); | |
| 1252 } | |
| 1253 break; | |
| 1254 case Delete_kind: | |
| 1255 marshal_write_int(buf, off, 4); | |
| 1256 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Delete.targets)); | |
| 1257 for (i = 0; i < asdl_seq_LEN(o->v.Delete.targets); i++) { | |
| 1258 void *elt = asdl_seq_GET(o->v.Delete.targets, i); | |
| 1259 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1260 } | |
| 1261 break; | |
| 1262 case Assign_kind: | |
| 1263 marshal_write_int(buf, off, 5); | |
| 1264 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Assign.targets)); | |
| 1265 for (i = 0; i < asdl_seq_LEN(o->v.Assign.targets); i++) { | |
| 1266 void *elt = asdl_seq_GET(o->v.Assign.targets, i); | |
| 1267 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1268 } | |
| 1269 marshal_write_expr(buf, off, o->v.Assign.value); | |
| 1270 break; | |
| 1271 case AugAssign_kind: | |
| 1272 marshal_write_int(buf, off, 6); | |
| 1273 marshal_write_expr(buf, off, o->v.AugAssign.target); | |
| 1274 marshal_write_operator(buf, off, o->v.AugAssign.op); | |
| 1275 marshal_write_expr(buf, off, o->v.AugAssign.value); | |
| 1276 break; | |
| 1277 case Print_kind: | |
| 1278 marshal_write_int(buf, off, 7); | |
| 1279 if (o->v.Print.dest) { | |
| 1280 marshal_write_int(buf, off, 1); | |
| 1281 marshal_write_expr(buf, off, o->v.Print.dest); | |
| 1282 } | |
| 1283 else { | |
| 1284 marshal_write_int(buf, off, 0); | |
| 1285 } | |
| 1286 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Print.values)); | |
| 1287 for (i = 0; i < asdl_seq_LEN(o->v.Print.values); i++) { | |
| 1288 void *elt = asdl_seq_GET(o->v.Print.values, i); | |
| 1289 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1290 } | |
| 1291 marshal_write_bool(buf, off, o->v.Print.nl); | |
| 1292 break; | |
| 1293 case For_kind: | |
| 1294 marshal_write_int(buf, off, 8); | |
| 1295 marshal_write_expr(buf, off, o->v.For.target); | |
| 1296 marshal_write_expr(buf, off, o->v.For.iter); | |
| 1297 marshal_write_int(buf, off, asdl_seq_LEN(o->v.For.body)); | |
| 1298 for (i = 0; i < asdl_seq_LEN(o->v.For.body); i++) { | |
| 1299 void *elt = asdl_seq_GET(o->v.For.body, i); | |
| 1300 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1301 } | |
| 1302 marshal_write_int(buf, off, asdl_seq_LEN(o->v.For.orelse)); | |
| 1303 for (i = 0; i < asdl_seq_LEN(o->v.For.orelse); i++) { | |
| 1304 void *elt = asdl_seq_GET(o->v.For.orelse, i); | |
| 1305 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1306 } | |
| 1307 break; | |
| 1308 case While_kind: | |
| 1309 marshal_write_int(buf, off, 9); | |
| 1310 marshal_write_expr(buf, off, o->v.While.test); | |
| 1311 marshal_write_int(buf, off, asdl_seq_LEN(o->v.While.body)); | |
| 1312 for (i = 0; i < asdl_seq_LEN(o->v.While.body); i++) { | |
| 1313 void *elt = asdl_seq_GET(o->v.While.body, i); | |
| 1314 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1315 } | |
| 1316 marshal_write_int(buf, off, asdl_seq_LEN(o->v.While.orelse)); | |
| 1317 for (i = 0; i < asdl_seq_LEN(o->v.While.orelse); i++) { | |
| 1318 void *elt = asdl_seq_GET(o->v.While.orelse, i); | |
| 1319 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1320 } | |
| 1321 break; | |
| 1322 case If_kind: | |
| 1323 marshal_write_int(buf, off, 10); | |
| 1324 marshal_write_expr(buf, off, o->v.If.test); | |
| 1325 marshal_write_int(buf, off, asdl_seq_LEN(o->v.If.body)); | |
| 1326 for (i = 0; i < asdl_seq_LEN(o->v.If.body); i++) { | |
| 1327 void *elt = asdl_seq_GET(o->v.If.body, i); | |
| 1328 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1329 } | |
| 1330 marshal_write_int(buf, off, asdl_seq_LEN(o->v.If.orelse)); | |
| 1331 for (i = 0; i < asdl_seq_LEN(o->v.If.orelse); i++) { | |
| 1332 void *elt = asdl_seq_GET(o->v.If.orelse, i); | |
| 1333 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1334 } | |
| 1335 break; | |
| 1336 case Raise_kind: | |
| 1337 marshal_write_int(buf, off, 11); | |
| 1338 if (o->v.Raise.type) { | |
| 1339 marshal_write_int(buf, off, 1); | |
| 1340 marshal_write_expr(buf, off, o->v.Raise.type); | |
| 1341 } | |
| 1342 else { | |
| 1343 marshal_write_int(buf, off, 0); | |
| 1344 } | |
| 1345 if (o->v.Raise.inst) { | |
| 1346 marshal_write_int(buf, off, 1); | |
| 1347 marshal_write_expr(buf, off, o->v.Raise.inst); | |
| 1348 } | |
| 1349 else { | |
| 1350 marshal_write_int(buf, off, 0); | |
| 1351 } | |
| 1352 if (o->v.Raise.tback) { | |
| 1353 marshal_write_int(buf, off, 1); | |
| 1354 marshal_write_expr(buf, off, o->v.Raise.tback); | |
| 1355 } | |
| 1356 else { | |
| 1357 marshal_write_int(buf, off, 0); | |
| 1358 } | |
| 1359 break; | |
| 1360 case TryExcept_kind: | |
| 1361 marshal_write_int(buf, off, 12); | |
| 1362 marshal_write_int(buf, off, asdl_seq_LEN(o->v.TryExcept.body)); | |
| 1363 for (i = 0; i < asdl_seq_LEN(o->v.TryExcept.body); i++) { | |
| 1364 void *elt = asdl_seq_GET(o->v.TryExcept.body, i); | |
| 1365 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1366 } | |
| 1367 marshal_write_int(buf, off, | |
| 1368 asdl_seq_LEN(o->v.TryExcept.handlers)); | |
| 1369 for (i = 0; i < asdl_seq_LEN(o->v.TryExcept.handlers); i++) { | |
| 1370 void *elt = asdl_seq_GET(o->v.TryExcept.handlers, i); | |
| 1371 marshal_write_excepthandler(buf, off, | |
| 1372 (excepthandler_ty)elt); | |
| 1373 } | |
| 1374 marshal_write_int(buf, off, | |
| 1375 asdl_seq_LEN(o->v.TryExcept.orelse)); | |
| 1376 for (i = 0; i < asdl_seq_LEN(o->v.TryExcept.orelse); i++) { | |
| 1377 void *elt = asdl_seq_GET(o->v.TryExcept.orelse, i); | |
| 1378 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1379 } | |
| 1380 break; | |
| 1381 case TryFinally_kind: | |
| 1382 marshal_write_int(buf, off, 13); | |
| 1383 marshal_write_int(buf, off, asdl_seq_LEN(o->v.TryFinally.body)); | |
| 1384 for (i = 0; i < asdl_seq_LEN(o->v.TryFinally.body); i++) { | |
| 1385 void *elt = asdl_seq_GET(o->v.TryFinally.body, i); | |
| 1386 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1387 } | |
| 1388 marshal_write_int(buf, off, | |
| 1389 asdl_seq_LEN(o->v.TryFinally.finalbody)); | |
| 1390 for (i = 0; i < asdl_seq_LEN(o->v.TryFinally.finalbody); i++) { | |
| 1391 void *elt = asdl_seq_GET(o->v.TryFinally.finalbody, i); | |
| 1392 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1393 } | |
| 1394 break; | |
| 1395 case Assert_kind: | |
| 1396 marshal_write_int(buf, off, 14); | |
| 1397 marshal_write_expr(buf, off, o->v.Assert.test); | |
| 1398 if (o->v.Assert.msg) { | |
| 1399 marshal_write_int(buf, off, 1); | |
| 1400 marshal_write_expr(buf, off, o->v.Assert.msg); | |
| 1401 } | |
| 1402 else { | |
| 1403 marshal_write_int(buf, off, 0); | |
| 1404 } | |
| 1405 break; | |
| 1406 case Import_kind: | |
| 1407 marshal_write_int(buf, off, 15); | |
| 1408 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Import.names)); | |
| 1409 for (i = 0; i < asdl_seq_LEN(o->v.Import.names); i++) { | |
| 1410 void *elt = asdl_seq_GET(o->v.Import.names, i); | |
| 1411 marshal_write_alias(buf, off, (alias_ty)elt); | |
| 1412 } | |
| 1413 break; | |
| 1414 case ImportFrom_kind: | |
| 1415 marshal_write_int(buf, off, 16); | |
| 1416 marshal_write_identifier(buf, off, o->v.ImportFrom.module); | |
| 1417 marshal_write_int(buf, off, | |
| 1418 asdl_seq_LEN(o->v.ImportFrom.names)); | |
| 1419 for (i = 0; i < asdl_seq_LEN(o->v.ImportFrom.names); i++) { | |
| 1420 void *elt = asdl_seq_GET(o->v.ImportFrom.names, i); | |
| 1421 marshal_write_alias(buf, off, (alias_ty)elt); | |
| 1422 } | |
| 1423 break; | |
| 1424 case Exec_kind: | |
| 1425 marshal_write_int(buf, off, 17); | |
| 1426 marshal_write_expr(buf, off, o->v.Exec.body); | |
| 1427 if (o->v.Exec.globals) { | |
| 1428 marshal_write_int(buf, off, 1); | |
| 1429 marshal_write_expr(buf, off, o->v.Exec.globals); | |
| 1430 } | |
| 1431 else { | |
| 1432 marshal_write_int(buf, off, 0); | |
| 1433 } | |
| 1434 if (o->v.Exec.locals) { | |
| 1435 marshal_write_int(buf, off, 1); | |
| 1436 marshal_write_expr(buf, off, o->v.Exec.locals); | |
| 1437 } | |
| 1438 else { | |
| 1439 marshal_write_int(buf, off, 0); | |
| 1440 } | |
| 1441 break; | |
| 1442 case Global_kind: | |
| 1443 marshal_write_int(buf, off, 18); | |
| 1444 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Global.names)); | |
| 1445 for (i = 0; i < asdl_seq_LEN(o->v.Global.names); i++) { | |
| 1446 void *elt = asdl_seq_GET(o->v.Global.names, i); | |
| 1447 marshal_write_identifier(buf, off, (identifier)elt); | |
| 1448 } | |
| 1449 break; | |
| 1450 case Expr_kind: | |
| 1451 marshal_write_int(buf, off, 19); | |
| 1452 marshal_write_expr(buf, off, o->v.Expr.value); | |
| 1453 break; | |
| 1454 case Pass_kind: | |
| 1455 marshal_write_int(buf, off, 20); | |
| 1456 break; | |
| 1457 case Break_kind: | |
| 1458 marshal_write_int(buf, off, 21); | |
| 1459 break; | |
| 1460 case Continue_kind: | |
| 1461 marshal_write_int(buf, off, 22); | |
| 1462 break; | |
| 1463 } | |
| 1464 return 1; | |
| 1465 } | |
| 1466 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1467 static int |
| 35742 | 1468 marshal_write_expr(PyObject **buf, int *off, expr_ty o) |
| 1469 { | |
| 1470 int i; | |
| 1471 switch (o->kind) { | |
| 1472 case BoolOp_kind: | |
| 1473 marshal_write_int(buf, off, 1); | |
| 1474 marshal_write_boolop(buf, off, o->v.BoolOp.op); | |
| 1475 marshal_write_int(buf, off, asdl_seq_LEN(o->v.BoolOp.values)); | |
| 1476 for (i = 0; i < asdl_seq_LEN(o->v.BoolOp.values); i++) { | |
| 1477 void *elt = asdl_seq_GET(o->v.BoolOp.values, i); | |
| 1478 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1479 } | |
| 1480 break; | |
| 1481 case BinOp_kind: | |
| 1482 marshal_write_int(buf, off, 2); | |
| 1483 marshal_write_expr(buf, off, o->v.BinOp.left); | |
| 1484 marshal_write_operator(buf, off, o->v.BinOp.op); | |
| 1485 marshal_write_expr(buf, off, o->v.BinOp.right); | |
| 1486 break; | |
| 1487 case UnaryOp_kind: | |
| 1488 marshal_write_int(buf, off, 3); | |
| 1489 marshal_write_unaryop(buf, off, o->v.UnaryOp.op); | |
| 1490 marshal_write_expr(buf, off, o->v.UnaryOp.operand); | |
| 1491 break; | |
| 1492 case Lambda_kind: | |
| 1493 marshal_write_int(buf, off, 4); | |
| 1494 marshal_write_arguments(buf, off, o->v.Lambda.args); | |
| 1495 marshal_write_expr(buf, off, o->v.Lambda.body); | |
| 1496 break; | |
| 1497 case Dict_kind: | |
| 1498 marshal_write_int(buf, off, 5); | |
| 1499 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Dict.keys)); | |
| 1500 for (i = 0; i < asdl_seq_LEN(o->v.Dict.keys); i++) { | |
| 1501 void *elt = asdl_seq_GET(o->v.Dict.keys, i); | |
| 1502 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1503 } | |
| 1504 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Dict.values)); | |
| 1505 for (i = 0; i < asdl_seq_LEN(o->v.Dict.values); i++) { | |
| 1506 void *elt = asdl_seq_GET(o->v.Dict.values, i); | |
| 1507 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1508 } | |
| 1509 break; | |
| 1510 case ListComp_kind: | |
| 1511 marshal_write_int(buf, off, 6); | |
| 1512 marshal_write_expr(buf, off, o->v.ListComp.elt); | |
| 1513 marshal_write_int(buf, off, | |
| 1514 asdl_seq_LEN(o->v.ListComp.generators)); | |
| 1515 for (i = 0; i < asdl_seq_LEN(o->v.ListComp.generators); i++) { | |
| 1516 void *elt = asdl_seq_GET(o->v.ListComp.generators, i); | |
| 1517 marshal_write_comprehension(buf, off, | |
| 1518 (comprehension_ty)elt); | |
| 1519 } | |
| 1520 break; | |
| 1521 case GeneratorExp_kind: | |
| 1522 marshal_write_int(buf, off, 7); | |
| 1523 marshal_write_expr(buf, off, o->v.GeneratorExp.elt); | |
| 1524 marshal_write_int(buf, off, | |
| 1525 asdl_seq_LEN(o->v.GeneratorExp.generators)); | |
| 1526 for (i = 0; i < asdl_seq_LEN(o->v.GeneratorExp.generators); | |
| 1527 i++) { | |
| 1528 void *elt = asdl_seq_GET(o->v.GeneratorExp.generators, | |
| 1529 i); | |
| 1530 marshal_write_comprehension(buf, off, | |
| 1531 (comprehension_ty)elt); | |
| 1532 } | |
| 1533 break; | |
| 1534 case Yield_kind: | |
| 1535 marshal_write_int(buf, off, 8); | |
| 1536 if (o->v.Yield.value) { | |
| 1537 marshal_write_int(buf, off, 1); | |
| 1538 marshal_write_expr(buf, off, o->v.Yield.value); | |
| 1539 } | |
| 1540 else { | |
| 1541 marshal_write_int(buf, off, 0); | |
| 1542 } | |
| 1543 break; | |
| 1544 case Compare_kind: | |
| 1545 marshal_write_int(buf, off, 9); | |
| 1546 marshal_write_expr(buf, off, o->v.Compare.left); | |
| 1547 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Compare.ops)); | |
| 1548 for (i = 0; i < asdl_seq_LEN(o->v.Compare.ops); i++) { | |
| 1549 void *elt = asdl_seq_GET(o->v.Compare.ops, i); | |
| 1550 marshal_write_cmpop(buf, off, (cmpop_ty)elt); | |
| 1551 } | |
| 1552 marshal_write_int(buf, off, | |
| 1553 asdl_seq_LEN(o->v.Compare.comparators)); | |
| 1554 for (i = 0; i < asdl_seq_LEN(o->v.Compare.comparators); i++) { | |
| 1555 void *elt = asdl_seq_GET(o->v.Compare.comparators, i); | |
| 1556 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1557 } | |
| 1558 break; | |
| 1559 case Call_kind: | |
| 1560 marshal_write_int(buf, off, 10); | |
| 1561 marshal_write_expr(buf, off, o->v.Call.func); | |
| 1562 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Call.args)); | |
| 1563 for (i = 0; i < asdl_seq_LEN(o->v.Call.args); i++) { | |
| 1564 void *elt = asdl_seq_GET(o->v.Call.args, i); | |
| 1565 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1566 } | |
| 1567 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Call.keywords)); | |
| 1568 for (i = 0; i < asdl_seq_LEN(o->v.Call.keywords); i++) { | |
| 1569 void *elt = asdl_seq_GET(o->v.Call.keywords, i); | |
| 1570 marshal_write_keyword(buf, off, (keyword_ty)elt); | |
| 1571 } | |
| 1572 if (o->v.Call.starargs) { | |
| 1573 marshal_write_int(buf, off, 1); | |
| 1574 marshal_write_expr(buf, off, o->v.Call.starargs); | |
| 1575 } | |
| 1576 else { | |
| 1577 marshal_write_int(buf, off, 0); | |
| 1578 } | |
| 1579 if (o->v.Call.kwargs) { | |
| 1580 marshal_write_int(buf, off, 1); | |
| 1581 marshal_write_expr(buf, off, o->v.Call.kwargs); | |
| 1582 } | |
| 1583 else { | |
| 1584 marshal_write_int(buf, off, 0); | |
| 1585 } | |
| 1586 break; | |
| 1587 case Repr_kind: | |
| 1588 marshal_write_int(buf, off, 11); | |
| 1589 marshal_write_expr(buf, off, o->v.Repr.value); | |
| 1590 break; | |
| 1591 case Num_kind: | |
| 1592 marshal_write_int(buf, off, 12); | |
| 1593 marshal_write_object(buf, off, o->v.Num.n); | |
| 1594 break; | |
| 1595 case Str_kind: | |
| 1596 marshal_write_int(buf, off, 13); | |
| 1597 marshal_write_string(buf, off, o->v.Str.s); | |
| 1598 break; | |
| 1599 case Attribute_kind: | |
| 1600 marshal_write_int(buf, off, 14); | |
| 1601 marshal_write_expr(buf, off, o->v.Attribute.value); | |
| 1602 marshal_write_identifier(buf, off, o->v.Attribute.attr); | |
| 1603 marshal_write_expr_context(buf, off, o->v.Attribute.ctx); | |
| 1604 break; | |
| 1605 case Subscript_kind: | |
| 1606 marshal_write_int(buf, off, 15); | |
| 1607 marshal_write_expr(buf, off, o->v.Subscript.value); | |
| 1608 marshal_write_slice(buf, off, o->v.Subscript.slice); | |
| 1609 marshal_write_expr_context(buf, off, o->v.Subscript.ctx); | |
| 1610 break; | |
| 1611 case Name_kind: | |
| 1612 marshal_write_int(buf, off, 16); | |
| 1613 marshal_write_identifier(buf, off, o->v.Name.id); | |
| 1614 marshal_write_expr_context(buf, off, o->v.Name.ctx); | |
| 1615 break; | |
| 1616 case List_kind: | |
| 1617 marshal_write_int(buf, off, 17); | |
| 1618 marshal_write_int(buf, off, asdl_seq_LEN(o->v.List.elts)); | |
| 1619 for (i = 0; i < asdl_seq_LEN(o->v.List.elts); i++) { | |
| 1620 void *elt = asdl_seq_GET(o->v.List.elts, i); | |
| 1621 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1622 } | |
| 1623 marshal_write_expr_context(buf, off, o->v.List.ctx); | |
| 1624 break; | |
| 1625 case Tuple_kind: | |
| 1626 marshal_write_int(buf, off, 18); | |
| 1627 marshal_write_int(buf, off, asdl_seq_LEN(o->v.Tuple.elts)); | |
| 1628 for (i = 0; i < asdl_seq_LEN(o->v.Tuple.elts); i++) { | |
| 1629 void *elt = asdl_seq_GET(o->v.Tuple.elts, i); | |
| 1630 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1631 } | |
| 1632 marshal_write_expr_context(buf, off, o->v.Tuple.ctx); | |
| 1633 break; | |
| 1634 } | |
| 1635 return 1; | |
| 1636 } | |
| 1637 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1638 static int |
| 35742 | 1639 marshal_write_expr_context(PyObject **buf, int *off, expr_context_ty o) |
| 1640 { | |
| 1641 switch (o) { | |
| 1642 case Load: | |
| 1643 marshal_write_int(buf, off, 1); | |
| 1644 break; | |
| 1645 case Store: | |
| 1646 marshal_write_int(buf, off, 2); | |
| 1647 break; | |
| 1648 case Del: | |
| 1649 marshal_write_int(buf, off, 3); | |
| 1650 break; | |
| 1651 case AugLoad: | |
| 1652 marshal_write_int(buf, off, 4); | |
| 1653 break; | |
| 1654 case AugStore: | |
| 1655 marshal_write_int(buf, off, 5); | |
| 1656 break; | |
| 1657 case Param: | |
| 1658 marshal_write_int(buf, off, 6); | |
| 1659 break; | |
| 1660 } | |
| 1661 return 1; | |
| 1662 } | |
| 1663 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1664 static int |
| 35742 | 1665 marshal_write_slice(PyObject **buf, int *off, slice_ty o) |
| 1666 { | |
| 1667 int i; | |
| 1668 switch (o->kind) { | |
| 1669 case Ellipsis_kind: | |
| 1670 marshal_write_int(buf, off, 1); | |
| 1671 break; | |
| 1672 case Slice_kind: | |
| 1673 marshal_write_int(buf, off, 2); | |
| 1674 if (o->v.Slice.lower) { | |
| 1675 marshal_write_int(buf, off, 1); | |
| 1676 marshal_write_expr(buf, off, o->v.Slice.lower); | |
| 1677 } | |
| 1678 else { | |
| 1679 marshal_write_int(buf, off, 0); | |
| 1680 } | |
| 1681 if (o->v.Slice.upper) { | |
| 1682 marshal_write_int(buf, off, 1); | |
| 1683 marshal_write_expr(buf, off, o->v.Slice.upper); | |
| 1684 } | |
| 1685 else { | |
| 1686 marshal_write_int(buf, off, 0); | |
| 1687 } | |
| 1688 if (o->v.Slice.step) { | |
| 1689 marshal_write_int(buf, off, 1); | |
| 1690 marshal_write_expr(buf, off, o->v.Slice.step); | |
| 1691 } | |
| 1692 else { | |
| 1693 marshal_write_int(buf, off, 0); | |
| 1694 } | |
| 1695 break; | |
| 1696 case ExtSlice_kind: | |
| 1697 marshal_write_int(buf, off, 3); | |
| 1698 marshal_write_int(buf, off, asdl_seq_LEN(o->v.ExtSlice.dims)); | |
| 1699 for (i = 0; i < asdl_seq_LEN(o->v.ExtSlice.dims); i++) { | |
| 1700 void *elt = asdl_seq_GET(o->v.ExtSlice.dims, i); | |
| 1701 marshal_write_slice(buf, off, (slice_ty)elt); | |
| 1702 } | |
| 1703 break; | |
| 1704 case Index_kind: | |
| 1705 marshal_write_int(buf, off, 4); | |
| 1706 marshal_write_expr(buf, off, o->v.Index.value); | |
| 1707 break; | |
| 1708 } | |
| 1709 return 1; | |
| 1710 } | |
| 1711 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1712 static int |
| 35742 | 1713 marshal_write_boolop(PyObject **buf, int *off, boolop_ty o) |
| 1714 { | |
| 1715 switch (o) { | |
| 1716 case And: | |
| 1717 marshal_write_int(buf, off, 1); | |
| 1718 break; | |
| 1719 case Or: | |
| 1720 marshal_write_int(buf, off, 2); | |
| 1721 break; | |
| 1722 } | |
| 1723 return 1; | |
| 1724 } | |
| 1725 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1726 static int |
| 35742 | 1727 marshal_write_operator(PyObject **buf, int *off, operator_ty o) |
| 1728 { | |
| 1729 switch (o) { | |
| 1730 case Add: | |
| 1731 marshal_write_int(buf, off, 1); | |
| 1732 break; | |
| 1733 case Sub: | |
| 1734 marshal_write_int(buf, off, 2); | |
| 1735 break; | |
| 1736 case Mult: | |
| 1737 marshal_write_int(buf, off, 3); | |
| 1738 break; | |
| 1739 case Div: | |
| 1740 marshal_write_int(buf, off, 4); | |
| 1741 break; | |
| 1742 case Mod: | |
| 1743 marshal_write_int(buf, off, 5); | |
| 1744 break; | |
| 1745 case Pow: | |
| 1746 marshal_write_int(buf, off, 6); | |
| 1747 break; | |
| 1748 case LShift: | |
| 1749 marshal_write_int(buf, off, 7); | |
| 1750 break; | |
| 1751 case RShift: | |
| 1752 marshal_write_int(buf, off, 8); | |
| 1753 break; | |
| 1754 case BitOr: | |
| 1755 marshal_write_int(buf, off, 9); | |
| 1756 break; | |
| 1757 case BitXor: | |
| 1758 marshal_write_int(buf, off, 10); | |
| 1759 break; | |
| 1760 case BitAnd: | |
| 1761 marshal_write_int(buf, off, 11); | |
| 1762 break; | |
| 1763 case FloorDiv: | |
| 1764 marshal_write_int(buf, off, 12); | |
| 1765 break; | |
| 1766 } | |
| 1767 return 1; | |
| 1768 } | |
| 1769 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1770 static int |
| 35742 | 1771 marshal_write_unaryop(PyObject **buf, int *off, unaryop_ty o) |
| 1772 { | |
| 1773 switch (o) { | |
| 1774 case Invert: | |
| 1775 marshal_write_int(buf, off, 1); | |
| 1776 break; | |
| 1777 case Not: | |
| 1778 marshal_write_int(buf, off, 2); | |
| 1779 break; | |
| 1780 case UAdd: | |
| 1781 marshal_write_int(buf, off, 3); | |
| 1782 break; | |
| 1783 case USub: | |
| 1784 marshal_write_int(buf, off, 4); | |
| 1785 break; | |
| 1786 } | |
| 1787 return 1; | |
| 1788 } | |
| 1789 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1790 static int |
| 35742 | 1791 marshal_write_cmpop(PyObject **buf, int *off, cmpop_ty o) |
| 1792 { | |
| 1793 switch (o) { | |
| 1794 case Eq: | |
| 1795 marshal_write_int(buf, off, 1); | |
| 1796 break; | |
| 1797 case NotEq: | |
| 1798 marshal_write_int(buf, off, 2); | |
| 1799 break; | |
| 1800 case Lt: | |
| 1801 marshal_write_int(buf, off, 3); | |
| 1802 break; | |
| 1803 case LtE: | |
| 1804 marshal_write_int(buf, off, 4); | |
| 1805 break; | |
| 1806 case Gt: | |
| 1807 marshal_write_int(buf, off, 5); | |
| 1808 break; | |
| 1809 case GtE: | |
| 1810 marshal_write_int(buf, off, 6); | |
| 1811 break; | |
| 1812 case Is: | |
| 1813 marshal_write_int(buf, off, 7); | |
| 1814 break; | |
| 1815 case IsNot: | |
| 1816 marshal_write_int(buf, off, 8); | |
| 1817 break; | |
| 1818 case In: | |
| 1819 marshal_write_int(buf, off, 9); | |
| 1820 break; | |
| 1821 case NotIn: | |
| 1822 marshal_write_int(buf, off, 10); | |
| 1823 break; | |
| 1824 } | |
| 1825 return 1; | |
| 1826 } | |
| 1827 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1828 static int |
| 35742 | 1829 marshal_write_comprehension(PyObject **buf, int *off, comprehension_ty o) |
| 1830 { | |
| 1831 int i; | |
| 1832 marshal_write_expr(buf, off, o->target); | |
| 1833 marshal_write_expr(buf, off, o->iter); | |
| 1834 marshal_write_int(buf, off, asdl_seq_LEN(o->ifs)); | |
| 1835 for (i = 0; i < asdl_seq_LEN(o->ifs); i++) { | |
| 1836 void *elt = asdl_seq_GET(o->ifs, i); | |
| 1837 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1838 } | |
| 1839 return 1; | |
| 1840 } | |
| 1841 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1842 static int |
| 35742 | 1843 marshal_write_excepthandler(PyObject **buf, int *off, excepthandler_ty o) |
| 1844 { | |
| 1845 int i; | |
| 1846 if (o->type) { | |
| 1847 marshal_write_int(buf, off, 1); | |
| 1848 marshal_write_expr(buf, off, o->type); | |
| 1849 } | |
| 1850 else { | |
| 1851 marshal_write_int(buf, off, 0); | |
| 1852 } | |
| 1853 if (o->name) { | |
| 1854 marshal_write_int(buf, off, 1); | |
| 1855 marshal_write_expr(buf, off, o->name); | |
| 1856 } | |
| 1857 else { | |
| 1858 marshal_write_int(buf, off, 0); | |
| 1859 } | |
| 1860 marshal_write_int(buf, off, asdl_seq_LEN(o->body)); | |
| 1861 for (i = 0; i < asdl_seq_LEN(o->body); i++) { | |
| 1862 void *elt = asdl_seq_GET(o->body, i); | |
| 1863 marshal_write_stmt(buf, off, (stmt_ty)elt); | |
| 1864 } | |
| 1865 return 1; | |
| 1866 } | |
| 1867 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1868 static int |
| 35742 | 1869 marshal_write_arguments(PyObject **buf, int *off, arguments_ty o) |
| 1870 { | |
| 1871 int i; | |
| 1872 marshal_write_int(buf, off, asdl_seq_LEN(o->args)); | |
| 1873 for (i = 0; i < asdl_seq_LEN(o->args); i++) { | |
| 1874 void *elt = asdl_seq_GET(o->args, i); | |
| 1875 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1876 } | |
| 1877 if (o->vararg) { | |
| 1878 marshal_write_int(buf, off, 1); | |
| 1879 marshal_write_identifier(buf, off, o->vararg); | |
| 1880 } | |
| 1881 else { | |
| 1882 marshal_write_int(buf, off, 0); | |
| 1883 } | |
| 1884 if (o->kwarg) { | |
| 1885 marshal_write_int(buf, off, 1); | |
| 1886 marshal_write_identifier(buf, off, o->kwarg); | |
| 1887 } | |
| 1888 else { | |
| 1889 marshal_write_int(buf, off, 0); | |
| 1890 } | |
| 1891 marshal_write_int(buf, off, asdl_seq_LEN(o->defaults)); | |
| 1892 for (i = 0; i < asdl_seq_LEN(o->defaults); i++) { | |
| 1893 void *elt = asdl_seq_GET(o->defaults, i); | |
| 1894 marshal_write_expr(buf, off, (expr_ty)elt); | |
| 1895 } | |
| 1896 return 1; | |
| 1897 } | |
| 1898 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1899 static int |
| 35742 | 1900 marshal_write_keyword(PyObject **buf, int *off, keyword_ty o) |
| 1901 { | |
| 1902 marshal_write_identifier(buf, off, o->arg); | |
| 1903 marshal_write_expr(buf, off, o->value); | |
| 1904 return 1; | |
| 1905 } | |
| 1906 | |
|
35862
6867995a18a7
Prevent name pollution by making lots of internal functions static.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35784
diff
changeset
|
1907 static int |
| 35742 | 1908 marshal_write_alias(PyObject **buf, int *off, alias_ty o) |
| 1909 { | |
| 1910 marshal_write_identifier(buf, off, o->name); | |
| 1911 if (o->asname) { | |
| 1912 marshal_write_int(buf, off, 1); | |
| 1913 marshal_write_identifier(buf, off, o->asname); | |
| 1914 } | |
| 1915 else { | |
| 1916 marshal_write_int(buf, off, 0); | |
| 1917 } | |
| 1918 return 1; | |
| 1919 } | |
| 1920 | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1921 |
