Mercurial > cpython-lru_cache-weakref
annotate Python/Python-ast.c @ 36726:bbf16fd024df legacy-trunk
from __future__ import with_statement addon for 'with', mostly written by
Neal.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Tue, 28 Feb 2006 19:02:24 +0000 |
| parents | 5c36c222e7ca |
| children | dbf9cc6c36eb |
| 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 | |
| 36669 | 6 PyTypeObject* AST_type; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
7 PyTypeObject *mod_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
8 static PyObject* ast2obj_mod(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
9 PyTypeObject *Module_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
10 char *Module_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
11 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
12 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
13 PyTypeObject *Interactive_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
14 char *Interactive_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
15 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
16 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
17 PyTypeObject *Expression_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
18 char *Expression_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
19 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
20 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
21 PyTypeObject *Suite_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
22 char *Suite_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
23 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
24 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
25 PyTypeObject *stmt_type; |
| 36669 | 26 char *stmt_attributes[] = { |
| 27 "lineno", | |
| 28 }; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
29 static PyObject* ast2obj_stmt(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
30 PyTypeObject *FunctionDef_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
31 char *FunctionDef_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
32 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
33 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
34 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
35 "decorators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
36 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
37 PyTypeObject *ClassDef_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
38 char *ClassDef_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
39 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
40 "bases", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
41 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
42 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
43 PyTypeObject *Return_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
44 char *Return_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
45 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
46 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
47 PyTypeObject *Delete_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
48 char *Delete_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
49 "targets", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
50 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
51 PyTypeObject *Assign_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
52 char *Assign_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
53 "targets", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
54 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
55 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
56 PyTypeObject *AugAssign_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
57 char *AugAssign_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
58 "target", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
59 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
60 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
61 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
62 PyTypeObject *Print_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
63 char *Print_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
64 "dest", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
65 "values", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
66 "nl", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
67 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
68 PyTypeObject *For_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
69 char *For_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
70 "target", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
71 "iter", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
72 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
73 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
74 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
75 PyTypeObject *While_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
76 char *While_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
77 "test", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
78 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
79 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
80 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
81 PyTypeObject *If_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
82 char *If_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
83 "test", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
84 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
85 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
86 }; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
87 PyTypeObject *With_type; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
88 char *With_fields[]={ |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
89 "context_expr", |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
90 "optional_vars", |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
91 "body", |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
92 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
93 PyTypeObject *Raise_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
94 char *Raise_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
95 "type", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
96 "inst", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
97 "tback", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
98 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
99 PyTypeObject *TryExcept_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
100 char *TryExcept_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
101 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
102 "handlers", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
103 "orelse", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
104 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
105 PyTypeObject *TryFinally_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
106 char *TryFinally_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
107 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
108 "finalbody", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
109 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
110 PyTypeObject *Assert_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
111 char *Assert_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
112 "test", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
113 "msg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
114 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
115 PyTypeObject *Import_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
116 char *Import_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
117 "names", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
118 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
119 PyTypeObject *ImportFrom_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
120 char *ImportFrom_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
121 "module", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
122 "names", |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
123 "level", |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
124 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
125 PyTypeObject *Exec_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
126 char *Exec_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
127 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
128 "globals", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
129 "locals", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
130 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
131 PyTypeObject *Global_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
132 char *Global_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
133 "names", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
134 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
135 PyTypeObject *Expr_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
136 char *Expr_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
137 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
138 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
139 PyTypeObject *Pass_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
140 PyTypeObject *Break_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
141 PyTypeObject *Continue_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
142 PyTypeObject *expr_type; |
| 36669 | 143 char *expr_attributes[] = { |
| 144 "lineno", | |
| 145 }; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
146 static PyObject* ast2obj_expr(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
147 PyTypeObject *BoolOp_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
148 char *BoolOp_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
149 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
150 "values", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
151 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
152 PyTypeObject *BinOp_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
153 char *BinOp_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
154 "left", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
155 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
156 "right", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
157 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
158 PyTypeObject *UnaryOp_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
159 char *UnaryOp_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
160 "op", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
161 "operand", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
162 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
163 PyTypeObject *Lambda_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
164 char *Lambda_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
165 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
166 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
167 }; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
168 PyTypeObject *IfExp_type; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
169 char *IfExp_fields[]={ |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
170 "test", |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
171 "body", |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
172 "orelse", |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
173 }; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
174 PyTypeObject *Dict_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
175 char *Dict_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
176 "keys", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
177 "values", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
178 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
179 PyTypeObject *ListComp_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
180 char *ListComp_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
181 "elt", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
182 "generators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
183 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
184 PyTypeObject *GeneratorExp_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
185 char *GeneratorExp_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
186 "elt", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
187 "generators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
188 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
189 PyTypeObject *Yield_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
190 char *Yield_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
191 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
192 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
193 PyTypeObject *Compare_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
194 char *Compare_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
195 "left", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
196 "ops", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
197 "comparators", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
198 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
199 PyTypeObject *Call_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
200 char *Call_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
201 "func", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
202 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
203 "keywords", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
204 "starargs", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
205 "kwargs", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
206 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
207 PyTypeObject *Repr_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
208 char *Repr_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
209 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
210 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
211 PyTypeObject *Num_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
212 char *Num_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
213 "n", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
214 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
215 PyTypeObject *Str_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
216 char *Str_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
217 "s", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
218 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
219 PyTypeObject *Attribute_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
220 char *Attribute_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
221 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
222 "attr", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
223 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
224 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
225 PyTypeObject *Subscript_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
226 char *Subscript_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
227 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
228 "slice", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
229 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
230 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
231 PyTypeObject *Name_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
232 char *Name_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
233 "id", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
234 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
235 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
236 PyTypeObject *List_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
237 char *List_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
238 "elts", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
239 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
240 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
241 PyTypeObject *Tuple_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
242 char *Tuple_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
243 "elts", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
244 "ctx", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
245 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
246 PyTypeObject *expr_context_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
247 static PyObject *Load_singleton, *Store_singleton, *Del_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
248 *AugLoad_singleton, *AugStore_singleton, *Param_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
249 static PyObject* ast2obj_expr_context(expr_context_ty); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
250 PyTypeObject *Load_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
251 PyTypeObject *Store_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
252 PyTypeObject *Del_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
253 PyTypeObject *AugLoad_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
254 PyTypeObject *AugStore_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
255 PyTypeObject *Param_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
256 PyTypeObject *slice_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
257 static PyObject* ast2obj_slice(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
258 PyTypeObject *Ellipsis_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
259 PyTypeObject *Slice_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
260 char *Slice_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
261 "lower", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
262 "upper", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
263 "step", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
264 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
265 PyTypeObject *ExtSlice_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
266 char *ExtSlice_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
267 "dims", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
268 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
269 PyTypeObject *Index_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
270 char *Index_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
271 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
272 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
273 PyTypeObject *boolop_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
274 static PyObject *And_singleton, *Or_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
275 static PyObject* ast2obj_boolop(boolop_ty); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
276 PyTypeObject *And_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
277 PyTypeObject *Or_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
278 PyTypeObject *operator_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
279 static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
280 *Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
281 *RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
282 *FloorDiv_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
283 static PyObject* ast2obj_operator(operator_ty); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
284 PyTypeObject *Add_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
285 PyTypeObject *Sub_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
286 PyTypeObject *Mult_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
287 PyTypeObject *Div_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
288 PyTypeObject *Mod_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
289 PyTypeObject *Pow_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
290 PyTypeObject *LShift_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
291 PyTypeObject *RShift_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
292 PyTypeObject *BitOr_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
293 PyTypeObject *BitXor_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
294 PyTypeObject *BitAnd_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
295 PyTypeObject *FloorDiv_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
296 PyTypeObject *unaryop_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
297 static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
298 *USub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
299 static PyObject* ast2obj_unaryop(unaryop_ty); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
300 PyTypeObject *Invert_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
301 PyTypeObject *Not_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
302 PyTypeObject *UAdd_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
303 PyTypeObject *USub_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
304 PyTypeObject *cmpop_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
305 static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
306 *Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
307 *NotIn_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
308 static PyObject* ast2obj_cmpop(cmpop_ty); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
309 PyTypeObject *Eq_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
310 PyTypeObject *NotEq_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
311 PyTypeObject *Lt_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
312 PyTypeObject *LtE_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
313 PyTypeObject *Gt_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
314 PyTypeObject *GtE_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
315 PyTypeObject *Is_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
316 PyTypeObject *IsNot_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
317 PyTypeObject *In_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
318 PyTypeObject *NotIn_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
319 PyTypeObject *comprehension_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
320 static PyObject* ast2obj_comprehension(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
321 char *comprehension_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
322 "target", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
323 "iter", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
324 "ifs", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
325 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
326 PyTypeObject *excepthandler_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
327 static PyObject* ast2obj_excepthandler(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
328 char *excepthandler_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
329 "type", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
330 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
331 "body", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
332 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
333 PyTypeObject *arguments_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
334 static PyObject* ast2obj_arguments(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
335 char *arguments_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
336 "args", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
337 "vararg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
338 "kwarg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
339 "defaults", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
340 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
341 PyTypeObject *keyword_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
342 static PyObject* ast2obj_keyword(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
343 char *keyword_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
344 "arg", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
345 "value", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
346 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
347 PyTypeObject *alias_type; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
348 static PyObject* ast2obj_alias(void*); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
349 char *alias_fields[]={ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
350 "name", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
351 "asname", |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
352 }; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
353 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
354 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
355 static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
356 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
357 PyObject *fnames, *result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
358 int i; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
359 if (num_fields) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
360 fnames = PyTuple_New(num_fields); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
361 if (!fnames) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
362 } else { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
363 fnames = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
364 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
365 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
366 for(i=0; i < num_fields; i++) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
367 PyObject *field = PyString_FromString(fields[i]); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
368 if (!field) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
369 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
370 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
371 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
372 PyTuple_SET_ITEM(fnames, i, field); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
373 } |
|
36726
bbf16fd024df
from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents:
36712
diff
changeset
|
374 result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}", |
| 36669 | 375 type, base, "_fields", fnames, "__module__", "_ast"); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
376 Py_DECREF(fnames); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
377 return (PyTypeObject*)result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
378 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
379 |
| 36669 | 380 static int add_attributes(PyTypeObject* type, char**attrs, int num_fields) |
| 381 { | |
| 382 int i; | |
| 383 PyObject *s, *l = PyList_New(num_fields); | |
| 384 if (!l) return 0; | |
| 385 for(i=0; i < num_fields; i++) { | |
| 386 s = PyString_FromString(attrs[i]); | |
| 387 if (!s) { | |
| 388 Py_DECREF(l); | |
| 389 return 0; | |
| 390 } | |
| 391 PyList_SET_ITEM(l, i, s); | |
| 392 } | |
| 393 return PyObject_SetAttrString((PyObject*)type, "_attributes", l) >=0; | |
| 394 } | |
| 395 | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
396 static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*)) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
397 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
398 int i, n = asdl_seq_LEN(seq); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
399 PyObject *result = PyList_New(n); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
400 PyObject *value; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
401 if (!result) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
402 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
403 for (i = 0; i < n; i++) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
404 value = func(asdl_seq_GET(seq, i)); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
405 if (!value) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
406 Py_DECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
407 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
408 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
409 PyList_SET_ITEM(result, i, value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
410 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
411 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
412 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
413 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
414 static PyObject* ast2obj_object(void *o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
415 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
416 if (!o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
417 o = Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
418 Py_INCREF((PyObject*)o); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
419 return (PyObject*)o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
420 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
421 #define ast2obj_identifier ast2obj_object |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
422 #define ast2obj_string ast2obj_object |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
423 static PyObject* ast2obj_bool(bool b) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
424 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
425 return PyBool_FromLong(b); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
426 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
427 |
| 36669 | 428 static PyObject* ast2obj_int(bool b) |
| 429 { | |
| 430 return PyInt_FromLong(b); | |
| 431 } | |
| 432 | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
433 static int initialized; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
434 static int init_types(void) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
435 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
436 if (initialized) return 1; |
| 36669 | 437 AST_type = make_type("AST", &PyBaseObject_Type, NULL, 0); |
| 438 mod_type = make_type("mod", AST_type, NULL, 0); | |
| 439 if (!mod_type) return 0; | |
| 440 if (!add_attributes(mod_type, NULL, 0)) return 0; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
441 Module_type = make_type("Module", mod_type, Module_fields, 1); |
| 36669 | 442 if (!Module_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
443 Interactive_type = make_type("Interactive", mod_type, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
444 Interactive_fields, 1); |
| 36669 | 445 if (!Interactive_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
446 Expression_type = make_type("Expression", mod_type, Expression_fields, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
447 1); |
| 36669 | 448 if (!Expression_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
449 Suite_type = make_type("Suite", mod_type, Suite_fields, 1); |
| 36669 | 450 if (!Suite_type) return 0; |
| 451 stmt_type = make_type("stmt", AST_type, NULL, 0); | |
| 452 if (!stmt_type) return 0; | |
| 453 if (!add_attributes(stmt_type, stmt_attributes, 1)) return 0; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
454 FunctionDef_type = make_type("FunctionDef", stmt_type, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
455 FunctionDef_fields, 4); |
| 36669 | 456 if (!FunctionDef_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
457 ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 3); |
| 36669 | 458 if (!ClassDef_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
459 Return_type = make_type("Return", stmt_type, Return_fields, 1); |
| 36669 | 460 if (!Return_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
461 Delete_type = make_type("Delete", stmt_type, Delete_fields, 1); |
| 36669 | 462 if (!Delete_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
463 Assign_type = make_type("Assign", stmt_type, Assign_fields, 2); |
| 36669 | 464 if (!Assign_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
465 AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3); |
| 36669 | 466 if (!AugAssign_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
467 Print_type = make_type("Print", stmt_type, Print_fields, 3); |
| 36669 | 468 if (!Print_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
469 For_type = make_type("For", stmt_type, For_fields, 4); |
| 36669 | 470 if (!For_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
471 While_type = make_type("While", stmt_type, While_fields, 3); |
| 36669 | 472 if (!While_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
473 If_type = make_type("If", stmt_type, If_fields, 3); |
| 36669 | 474 if (!If_type) return 0; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
475 With_type = make_type("With", stmt_type, With_fields, 3); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
476 if (!With_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
477 Raise_type = make_type("Raise", stmt_type, Raise_fields, 3); |
| 36669 | 478 if (!Raise_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
479 TryExcept_type = make_type("TryExcept", stmt_type, TryExcept_fields, 3); |
| 36669 | 480 if (!TryExcept_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
481 TryFinally_type = make_type("TryFinally", stmt_type, TryFinally_fields, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
482 2); |
| 36669 | 483 if (!TryFinally_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
484 Assert_type = make_type("Assert", stmt_type, Assert_fields, 2); |
| 36669 | 485 if (!Assert_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
486 Import_type = make_type("Import", stmt_type, Import_fields, 1); |
| 36669 | 487 if (!Import_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
488 ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
489 3); |
| 36669 | 490 if (!ImportFrom_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
491 Exec_type = make_type("Exec", stmt_type, Exec_fields, 3); |
| 36669 | 492 if (!Exec_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
493 Global_type = make_type("Global", stmt_type, Global_fields, 1); |
| 36669 | 494 if (!Global_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
495 Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); |
| 36669 | 496 if (!Expr_type) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
497 Pass_type = make_type("Pass", stmt_type, NULL, 0); |
| 36669 | 498 if (!Pass_type) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
499 Break_type = make_type("Break", stmt_type, NULL, 0); |
| 36669 | 500 if (!Break_type) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
501 Continue_type = make_type("Continue", stmt_type, NULL, 0); |
| 36669 | 502 if (!Continue_type) return 0; |
| 503 expr_type = make_type("expr", AST_type, NULL, 0); | |
| 504 if (!expr_type) return 0; | |
| 505 if (!add_attributes(expr_type, expr_attributes, 1)) return 0; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
506 BoolOp_type = make_type("BoolOp", expr_type, BoolOp_fields, 2); |
| 36669 | 507 if (!BoolOp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
508 BinOp_type = make_type("BinOp", expr_type, BinOp_fields, 3); |
| 36669 | 509 if (!BinOp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
510 UnaryOp_type = make_type("UnaryOp", expr_type, UnaryOp_fields, 2); |
| 36669 | 511 if (!UnaryOp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
512 Lambda_type = make_type("Lambda", expr_type, Lambda_fields, 2); |
| 36669 | 513 if (!Lambda_type) return 0; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
514 IfExp_type = make_type("IfExp", expr_type, IfExp_fields, 3); |
| 36669 | 515 if (!IfExp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
516 Dict_type = make_type("Dict", expr_type, Dict_fields, 2); |
| 36669 | 517 if (!Dict_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
518 ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); |
| 36669 | 519 if (!ListComp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
520 GeneratorExp_type = make_type("GeneratorExp", expr_type, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
521 GeneratorExp_fields, 2); |
| 36669 | 522 if (!GeneratorExp_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
523 Yield_type = make_type("Yield", expr_type, Yield_fields, 1); |
| 36669 | 524 if (!Yield_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
525 Compare_type = make_type("Compare", expr_type, Compare_fields, 3); |
| 36669 | 526 if (!Compare_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
527 Call_type = make_type("Call", expr_type, Call_fields, 5); |
| 36669 | 528 if (!Call_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
529 Repr_type = make_type("Repr", expr_type, Repr_fields, 1); |
| 36669 | 530 if (!Repr_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
531 Num_type = make_type("Num", expr_type, Num_fields, 1); |
| 36669 | 532 if (!Num_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
533 Str_type = make_type("Str", expr_type, Str_fields, 1); |
| 36669 | 534 if (!Str_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
535 Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); |
| 36669 | 536 if (!Attribute_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
537 Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); |
| 36669 | 538 if (!Subscript_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
539 Name_type = make_type("Name", expr_type, Name_fields, 2); |
| 36669 | 540 if (!Name_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
541 List_type = make_type("List", expr_type, List_fields, 2); |
| 36669 | 542 if (!List_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
543 Tuple_type = make_type("Tuple", expr_type, Tuple_fields, 2); |
| 36669 | 544 if (!Tuple_type) return 0; |
| 545 expr_context_type = make_type("expr_context", AST_type, NULL, 0); | |
| 546 if (!expr_context_type) return 0; | |
| 547 if (!add_attributes(expr_context_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
548 Load_type = make_type("Load", expr_context_type, NULL, 0); |
| 36669 | 549 if (!Load_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
550 Load_singleton = PyType_GenericNew(Load_type, NULL, NULL); |
| 36669 | 551 if (!Load_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
552 Store_type = make_type("Store", expr_context_type, NULL, 0); |
| 36669 | 553 if (!Store_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
554 Store_singleton = PyType_GenericNew(Store_type, NULL, NULL); |
| 36669 | 555 if (!Store_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
556 Del_type = make_type("Del", expr_context_type, NULL, 0); |
| 36669 | 557 if (!Del_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
558 Del_singleton = PyType_GenericNew(Del_type, NULL, NULL); |
| 36669 | 559 if (!Del_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
560 AugLoad_type = make_type("AugLoad", expr_context_type, NULL, 0); |
| 36669 | 561 if (!AugLoad_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
562 AugLoad_singleton = PyType_GenericNew(AugLoad_type, NULL, NULL); |
| 36669 | 563 if (!AugLoad_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
564 AugStore_type = make_type("AugStore", expr_context_type, NULL, 0); |
| 36669 | 565 if (!AugStore_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
566 AugStore_singleton = PyType_GenericNew(AugStore_type, NULL, NULL); |
| 36669 | 567 if (!AugStore_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
568 Param_type = make_type("Param", expr_context_type, NULL, 0); |
| 36669 | 569 if (!Param_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
570 Param_singleton = PyType_GenericNew(Param_type, NULL, NULL); |
| 36669 | 571 if (!Param_singleton) return 0; |
| 572 slice_type = make_type("slice", AST_type, NULL, 0); | |
| 573 if (!slice_type) return 0; | |
| 574 if (!add_attributes(slice_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
575 Ellipsis_type = make_type("Ellipsis", slice_type, NULL, 0); |
| 36669 | 576 if (!Ellipsis_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
577 Slice_type = make_type("Slice", slice_type, Slice_fields, 3); |
| 36669 | 578 if (!Slice_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
579 ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); |
| 36669 | 580 if (!ExtSlice_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
581 Index_type = make_type("Index", slice_type, Index_fields, 1); |
| 36669 | 582 if (!Index_type) return 0; |
| 583 boolop_type = make_type("boolop", AST_type, NULL, 0); | |
| 584 if (!boolop_type) return 0; | |
| 585 if (!add_attributes(boolop_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
586 And_type = make_type("And", boolop_type, NULL, 0); |
| 36669 | 587 if (!And_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
588 And_singleton = PyType_GenericNew(And_type, NULL, NULL); |
| 36669 | 589 if (!And_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
590 Or_type = make_type("Or", boolop_type, NULL, 0); |
| 36669 | 591 if (!Or_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
592 Or_singleton = PyType_GenericNew(Or_type, NULL, NULL); |
| 36669 | 593 if (!Or_singleton) return 0; |
| 594 operator_type = make_type("operator", AST_type, NULL, 0); | |
| 595 if (!operator_type) return 0; | |
| 596 if (!add_attributes(operator_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
597 Add_type = make_type("Add", operator_type, NULL, 0); |
| 36669 | 598 if (!Add_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
599 Add_singleton = PyType_GenericNew(Add_type, NULL, NULL); |
| 36669 | 600 if (!Add_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
601 Sub_type = make_type("Sub", operator_type, NULL, 0); |
| 36669 | 602 if (!Sub_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
603 Sub_singleton = PyType_GenericNew(Sub_type, NULL, NULL); |
| 36669 | 604 if (!Sub_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
605 Mult_type = make_type("Mult", operator_type, NULL, 0); |
| 36669 | 606 if (!Mult_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
607 Mult_singleton = PyType_GenericNew(Mult_type, NULL, NULL); |
| 36669 | 608 if (!Mult_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
609 Div_type = make_type("Div", operator_type, NULL, 0); |
| 36669 | 610 if (!Div_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
611 Div_singleton = PyType_GenericNew(Div_type, NULL, NULL); |
| 36669 | 612 if (!Div_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
613 Mod_type = make_type("Mod", operator_type, NULL, 0); |
| 36669 | 614 if (!Mod_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
615 Mod_singleton = PyType_GenericNew(Mod_type, NULL, NULL); |
| 36669 | 616 if (!Mod_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
617 Pow_type = make_type("Pow", operator_type, NULL, 0); |
| 36669 | 618 if (!Pow_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
619 Pow_singleton = PyType_GenericNew(Pow_type, NULL, NULL); |
| 36669 | 620 if (!Pow_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
621 LShift_type = make_type("LShift", operator_type, NULL, 0); |
| 36669 | 622 if (!LShift_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
623 LShift_singleton = PyType_GenericNew(LShift_type, NULL, NULL); |
| 36669 | 624 if (!LShift_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
625 RShift_type = make_type("RShift", operator_type, NULL, 0); |
| 36669 | 626 if (!RShift_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
627 RShift_singleton = PyType_GenericNew(RShift_type, NULL, NULL); |
| 36669 | 628 if (!RShift_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
629 BitOr_type = make_type("BitOr", operator_type, NULL, 0); |
| 36669 | 630 if (!BitOr_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
631 BitOr_singleton = PyType_GenericNew(BitOr_type, NULL, NULL); |
| 36669 | 632 if (!BitOr_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
633 BitXor_type = make_type("BitXor", operator_type, NULL, 0); |
| 36669 | 634 if (!BitXor_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
635 BitXor_singleton = PyType_GenericNew(BitXor_type, NULL, NULL); |
| 36669 | 636 if (!BitXor_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
637 BitAnd_type = make_type("BitAnd", operator_type, NULL, 0); |
| 36669 | 638 if (!BitAnd_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
639 BitAnd_singleton = PyType_GenericNew(BitAnd_type, NULL, NULL); |
| 36669 | 640 if (!BitAnd_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
641 FloorDiv_type = make_type("FloorDiv", operator_type, NULL, 0); |
| 36669 | 642 if (!FloorDiv_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
643 FloorDiv_singleton = PyType_GenericNew(FloorDiv_type, NULL, NULL); |
| 36669 | 644 if (!FloorDiv_singleton) return 0; |
| 645 unaryop_type = make_type("unaryop", AST_type, NULL, 0); | |
| 646 if (!unaryop_type) return 0; | |
| 647 if (!add_attributes(unaryop_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
648 Invert_type = make_type("Invert", unaryop_type, NULL, 0); |
| 36669 | 649 if (!Invert_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
650 Invert_singleton = PyType_GenericNew(Invert_type, NULL, NULL); |
| 36669 | 651 if (!Invert_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
652 Not_type = make_type("Not", unaryop_type, NULL, 0); |
| 36669 | 653 if (!Not_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
654 Not_singleton = PyType_GenericNew(Not_type, NULL, NULL); |
| 36669 | 655 if (!Not_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
656 UAdd_type = make_type("UAdd", unaryop_type, NULL, 0); |
| 36669 | 657 if (!UAdd_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
658 UAdd_singleton = PyType_GenericNew(UAdd_type, NULL, NULL); |
| 36669 | 659 if (!UAdd_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
660 USub_type = make_type("USub", unaryop_type, NULL, 0); |
| 36669 | 661 if (!USub_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
662 USub_singleton = PyType_GenericNew(USub_type, NULL, NULL); |
| 36669 | 663 if (!USub_singleton) return 0; |
| 664 cmpop_type = make_type("cmpop", AST_type, NULL, 0); | |
| 665 if (!cmpop_type) return 0; | |
| 666 if (!add_attributes(cmpop_type, NULL, 0)) return 0; | |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
667 Eq_type = make_type("Eq", cmpop_type, NULL, 0); |
| 36669 | 668 if (!Eq_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
669 Eq_singleton = PyType_GenericNew(Eq_type, NULL, NULL); |
| 36669 | 670 if (!Eq_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
671 NotEq_type = make_type("NotEq", cmpop_type, NULL, 0); |
| 36669 | 672 if (!NotEq_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
673 NotEq_singleton = PyType_GenericNew(NotEq_type, NULL, NULL); |
| 36669 | 674 if (!NotEq_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
675 Lt_type = make_type("Lt", cmpop_type, NULL, 0); |
| 36669 | 676 if (!Lt_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
677 Lt_singleton = PyType_GenericNew(Lt_type, NULL, NULL); |
| 36669 | 678 if (!Lt_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
679 LtE_type = make_type("LtE", cmpop_type, NULL, 0); |
| 36669 | 680 if (!LtE_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
681 LtE_singleton = PyType_GenericNew(LtE_type, NULL, NULL); |
| 36669 | 682 if (!LtE_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
683 Gt_type = make_type("Gt", cmpop_type, NULL, 0); |
| 36669 | 684 if (!Gt_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
685 Gt_singleton = PyType_GenericNew(Gt_type, NULL, NULL); |
| 36669 | 686 if (!Gt_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
687 GtE_type = make_type("GtE", cmpop_type, NULL, 0); |
| 36669 | 688 if (!GtE_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
689 GtE_singleton = PyType_GenericNew(GtE_type, NULL, NULL); |
| 36669 | 690 if (!GtE_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
691 Is_type = make_type("Is", cmpop_type, NULL, 0); |
| 36669 | 692 if (!Is_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
693 Is_singleton = PyType_GenericNew(Is_type, NULL, NULL); |
| 36669 | 694 if (!Is_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
695 IsNot_type = make_type("IsNot", cmpop_type, NULL, 0); |
| 36669 | 696 if (!IsNot_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
697 IsNot_singleton = PyType_GenericNew(IsNot_type, NULL, NULL); |
| 36669 | 698 if (!IsNot_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
699 In_type = make_type("In", cmpop_type, NULL, 0); |
| 36669 | 700 if (!In_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
701 In_singleton = PyType_GenericNew(In_type, NULL, NULL); |
| 36669 | 702 if (!In_singleton) return 0; |
|
36664
7bfbfb2ef4e2
Stop generating empty arrays.
Martin v. Löwis <martin@v.loewis.de>
parents:
36661
diff
changeset
|
703 NotIn_type = make_type("NotIn", cmpop_type, NULL, 0); |
| 36669 | 704 if (!NotIn_type) return 0; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
705 NotIn_singleton = PyType_GenericNew(NotIn_type, NULL, NULL); |
| 36669 | 706 if (!NotIn_singleton) return 0; |
| 707 comprehension_type = make_type("comprehension", AST_type, | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
708 comprehension_fields, 3); |
| 36669 | 709 if (!comprehension_type) return 0; |
| 710 excepthandler_type = make_type("excepthandler", AST_type, | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
711 excepthandler_fields, 3); |
| 36669 | 712 if (!excepthandler_type) return 0; |
| 713 arguments_type = make_type("arguments", AST_type, arguments_fields, 4); | |
| 714 if (!arguments_type) return 0; | |
| 715 keyword_type = make_type("keyword", AST_type, keyword_fields, 2); | |
| 716 if (!keyword_type) return 0; | |
| 717 alias_type = make_type("alias", AST_type, alias_fields, 2); | |
| 718 if (!alias_type) return 0; | |
| 719 initialized = 1; | |
| 720 return 1; | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
721 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
722 |
| 35742 | 723 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
|
724 Module(asdl_seq * body, PyArena *arena) |
| 35742 | 725 { |
| 726 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
|
727 p = (mod_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 = Module_kind; | |
| 733 p->v.Module.body = body; | |
| 734 return p; | |
| 735 } | |
| 736 | |
| 737 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
|
738 Interactive(asdl_seq * body, PyArena *arena) |
| 35742 | 739 { |
| 740 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
|
741 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 742 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
743 PyErr_NoMemory(); |
| 35742 | 744 return NULL; |
| 745 } | |
| 746 p->kind = Interactive_kind; | |
| 747 p->v.Interactive.body = body; | |
| 748 return p; | |
| 749 } | |
| 750 | |
| 751 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
|
752 Expression(expr_ty body, PyArena *arena) |
| 35742 | 753 { |
| 754 mod_ty p; | |
| 755 if (!body) { | |
| 756 PyErr_SetString(PyExc_ValueError, | |
| 757 "field body is required for Expression"); | |
| 758 return NULL; | |
| 759 } | |
|
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
|
760 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 761 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
762 PyErr_NoMemory(); |
| 35742 | 763 return NULL; |
| 764 } | |
| 765 p->kind = Expression_kind; | |
| 766 p->v.Expression.body = body; | |
| 767 return p; | |
| 768 } | |
| 769 | |
| 770 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
|
771 Suite(asdl_seq * body, PyArena *arena) |
| 35742 | 772 { |
| 773 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
|
774 p = (mod_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 775 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
776 PyErr_NoMemory(); |
| 35742 | 777 return NULL; |
| 778 } | |
| 779 p->kind = Suite_kind; | |
| 780 p->v.Suite.body = body; | |
| 781 return p; | |
| 782 } | |
| 783 | |
| 784 stmt_ty | |
| 785 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
|
786 decorators, int lineno, PyArena *arena) |
| 35742 | 787 { |
| 788 stmt_ty p; | |
| 789 if (!name) { | |
| 790 PyErr_SetString(PyExc_ValueError, | |
| 791 "field name is required for FunctionDef"); | |
| 792 return NULL; | |
| 793 } | |
| 794 if (!args) { | |
| 795 PyErr_SetString(PyExc_ValueError, | |
| 796 "field args is required for FunctionDef"); | |
| 797 return NULL; | |
| 798 } | |
|
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
|
799 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 800 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
801 PyErr_NoMemory(); |
| 35742 | 802 return NULL; |
| 803 } | |
| 804 p->kind = FunctionDef_kind; | |
| 805 p->v.FunctionDef.name = name; | |
| 806 p->v.FunctionDef.args = args; | |
| 807 p->v.FunctionDef.body = body; | |
| 808 p->v.FunctionDef.decorators = decorators; | |
| 809 p->lineno = lineno; | |
| 810 return p; | |
| 811 } | |
| 812 | |
| 813 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
|
814 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
|
815 PyArena *arena) |
| 35742 | 816 { |
| 817 stmt_ty p; | |
| 818 if (!name) { | |
| 819 PyErr_SetString(PyExc_ValueError, | |
| 820 "field name is required for ClassDef"); | |
| 821 return NULL; | |
| 822 } | |
|
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
|
823 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 824 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
825 PyErr_NoMemory(); |
| 35742 | 826 return NULL; |
| 827 } | |
| 828 p->kind = ClassDef_kind; | |
| 829 p->v.ClassDef.name = name; | |
| 830 p->v.ClassDef.bases = bases; | |
| 831 p->v.ClassDef.body = body; | |
| 832 p->lineno = lineno; | |
| 833 return p; | |
| 834 } | |
| 835 | |
| 836 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
|
837 Return(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 838 { |
| 839 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
|
840 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 841 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
842 PyErr_NoMemory(); |
| 35742 | 843 return NULL; |
| 844 } | |
| 845 p->kind = Return_kind; | |
| 846 p->v.Return.value = value; | |
| 847 p->lineno = lineno; | |
| 848 return p; | |
| 849 } | |
| 850 | |
| 851 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
|
852 Delete(asdl_seq * targets, int lineno, PyArena *arena) |
| 35742 | 853 { |
| 854 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
|
855 p = (stmt_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 = Delete_kind; | |
| 861 p->v.Delete.targets = targets; | |
| 862 p->lineno = lineno; | |
| 863 return p; | |
| 864 } | |
| 865 | |
| 866 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
|
867 Assign(asdl_seq * targets, expr_ty value, int lineno, PyArena *arena) |
| 35742 | 868 { |
| 869 stmt_ty p; | |
| 870 if (!value) { | |
| 871 PyErr_SetString(PyExc_ValueError, | |
| 872 "field value is required for Assign"); | |
| 873 return NULL; | |
| 874 } | |
|
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
|
875 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 876 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
877 PyErr_NoMemory(); |
| 35742 | 878 return NULL; |
| 879 } | |
| 880 p->kind = Assign_kind; | |
| 881 p->v.Assign.targets = targets; | |
| 882 p->v.Assign.value = value; | |
| 883 p->lineno = lineno; | |
| 884 return p; | |
| 885 } | |
| 886 | |
| 887 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
|
888 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
|
889 *arena) |
| 35742 | 890 { |
| 891 stmt_ty p; | |
| 892 if (!target) { | |
| 893 PyErr_SetString(PyExc_ValueError, | |
| 894 "field target is required for AugAssign"); | |
| 895 return NULL; | |
| 896 } | |
| 897 if (!op) { | |
| 898 PyErr_SetString(PyExc_ValueError, | |
| 899 "field op is required for AugAssign"); | |
| 900 return NULL; | |
| 901 } | |
| 902 if (!value) { | |
| 903 PyErr_SetString(PyExc_ValueError, | |
| 904 "field value is required for AugAssign"); | |
| 905 return NULL; | |
| 906 } | |
|
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
|
907 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 908 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
909 PyErr_NoMemory(); |
| 35742 | 910 return NULL; |
| 911 } | |
| 912 p->kind = AugAssign_kind; | |
| 913 p->v.AugAssign.target = target; | |
| 914 p->v.AugAssign.op = op; | |
| 915 p->v.AugAssign.value = value; | |
| 916 p->lineno = lineno; | |
| 917 return p; | |
| 918 } | |
| 919 | |
| 920 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
|
921 Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, PyArena *arena) |
| 35742 | 922 { |
| 923 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
|
924 p = (stmt_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 = Print_kind; | |
| 930 p->v.Print.dest = dest; | |
| 931 p->v.Print.values = values; | |
| 932 p->v.Print.nl = nl; | |
| 933 p->lineno = lineno; | |
| 934 return p; | |
| 935 } | |
| 936 | |
| 937 stmt_ty | |
| 938 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
|
939 lineno, PyArena *arena) |
| 35742 | 940 { |
| 941 stmt_ty p; | |
| 942 if (!target) { | |
| 943 PyErr_SetString(PyExc_ValueError, | |
| 944 "field target is required for For"); | |
| 945 return NULL; | |
| 946 } | |
| 947 if (!iter) { | |
| 948 PyErr_SetString(PyExc_ValueError, | |
| 949 "field iter is required for For"); | |
| 950 return NULL; | |
| 951 } | |
|
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
|
952 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 953 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
954 PyErr_NoMemory(); |
| 35742 | 955 return NULL; |
| 956 } | |
| 957 p->kind = For_kind; | |
| 958 p->v.For.target = target; | |
| 959 p->v.For.iter = iter; | |
| 960 p->v.For.body = body; | |
| 961 p->v.For.orelse = orelse; | |
| 962 p->lineno = lineno; | |
| 963 return p; | |
| 964 } | |
| 965 | |
| 966 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
|
967 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
|
968 *arena) |
| 35742 | 969 { |
| 970 stmt_ty p; | |
| 971 if (!test) { | |
| 972 PyErr_SetString(PyExc_ValueError, | |
| 973 "field test is required for While"); | |
| 974 return NULL; | |
| 975 } | |
|
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
|
976 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 977 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
978 PyErr_NoMemory(); |
| 35742 | 979 return NULL; |
| 980 } | |
| 981 p->kind = While_kind; | |
| 982 p->v.While.test = test; | |
| 983 p->v.While.body = body; | |
| 984 p->v.While.orelse = orelse; | |
| 985 p->lineno = lineno; | |
| 986 return p; | |
| 987 } | |
| 988 | |
| 989 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
|
990 If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, PyArena *arena) |
| 35742 | 991 { |
| 992 stmt_ty p; | |
| 993 if (!test) { | |
| 994 PyErr_SetString(PyExc_ValueError, | |
| 995 "field test is required for If"); | |
| 996 return NULL; | |
| 997 } | |
|
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
|
998 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 999 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1000 PyErr_NoMemory(); |
| 35742 | 1001 return NULL; |
| 1002 } | |
| 1003 p->kind = If_kind; | |
| 1004 p->v.If.test = test; | |
| 1005 p->v.If.body = body; | |
| 1006 p->v.If.orelse = orelse; | |
| 1007 p->lineno = lineno; | |
| 1008 return p; | |
| 1009 } | |
| 1010 | |
| 1011 stmt_ty | |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1012 With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int lineno, |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1013 PyArena *arena) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1014 { |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1015 stmt_ty p; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1016 if (!context_expr) { |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1017 PyErr_SetString(PyExc_ValueError, |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1018 "field context_expr is required for With"); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1019 return NULL; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1020 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1021 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1022 if (!p) { |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1023 PyErr_NoMemory(); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1024 return NULL; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1025 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1026 p->kind = With_kind; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1027 p->v.With.context_expr = context_expr; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1028 p->v.With.optional_vars = optional_vars; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1029 p->v.With.body = body; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1030 p->lineno = lineno; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1031 return p; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1032 } |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1033 |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
1034 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
|
1035 Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, PyArena *arena) |
| 35742 | 1036 { |
| 1037 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
|
1038 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1039 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1040 PyErr_NoMemory(); |
| 35742 | 1041 return NULL; |
| 1042 } | |
| 1043 p->kind = Raise_kind; | |
| 1044 p->v.Raise.type = type; | |
| 1045 p->v.Raise.inst = inst; | |
| 1046 p->v.Raise.tback = tback; | |
| 1047 p->lineno = lineno; | |
| 1048 return p; | |
| 1049 } | |
| 1050 | |
| 1051 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
|
1052 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
|
1053 PyArena *arena) |
| 35742 | 1054 { |
| 1055 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
|
1056 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1057 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1058 PyErr_NoMemory(); |
| 35742 | 1059 return NULL; |
| 1060 } | |
| 1061 p->kind = TryExcept_kind; | |
| 1062 p->v.TryExcept.body = body; | |
| 1063 p->v.TryExcept.handlers = handlers; | |
| 1064 p->v.TryExcept.orelse = orelse; | |
| 1065 p->lineno = lineno; | |
| 1066 return p; | |
| 1067 } | |
| 1068 | |
| 1069 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
|
1070 TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, PyArena *arena) |
| 35742 | 1071 { |
| 1072 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
|
1073 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1074 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1075 PyErr_NoMemory(); |
| 35742 | 1076 return NULL; |
| 1077 } | |
| 1078 p->kind = TryFinally_kind; | |
| 1079 p->v.TryFinally.body = body; | |
| 1080 p->v.TryFinally.finalbody = finalbody; | |
| 1081 p->lineno = lineno; | |
| 1082 return p; | |
| 1083 } | |
| 1084 | |
| 1085 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
|
1086 Assert(expr_ty test, expr_ty msg, int lineno, PyArena *arena) |
| 35742 | 1087 { |
| 1088 stmt_ty p; | |
| 1089 if (!test) { | |
| 1090 PyErr_SetString(PyExc_ValueError, | |
| 1091 "field test is required for Assert"); | |
| 1092 return NULL; | |
| 1093 } | |
|
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
|
1094 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1095 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1096 PyErr_NoMemory(); |
| 35742 | 1097 return NULL; |
| 1098 } | |
| 1099 p->kind = Assert_kind; | |
| 1100 p->v.Assert.test = test; | |
| 1101 p->v.Assert.msg = msg; | |
| 1102 p->lineno = lineno; | |
| 1103 return p; | |
| 1104 } | |
| 1105 | |
| 1106 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
|
1107 Import(asdl_seq * names, int lineno, PyArena *arena) |
| 35742 | 1108 { |
| 1109 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
|
1110 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1111 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1112 PyErr_NoMemory(); |
| 35742 | 1113 return NULL; |
| 1114 } | |
| 1115 p->kind = Import_kind; | |
| 1116 p->v.Import.names = names; | |
| 1117 p->lineno = lineno; | |
| 1118 return p; | |
| 1119 } | |
| 1120 | |
| 1121 stmt_ty | |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
1122 ImportFrom(identifier module, asdl_seq * names, int level, int lineno, PyArena |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
1123 *arena) |
| 35742 | 1124 { |
| 1125 stmt_ty p; | |
| 1126 if (!module) { | |
| 1127 PyErr_SetString(PyExc_ValueError, | |
| 1128 "field module is required for ImportFrom"); | |
| 1129 return NULL; | |
| 1130 } | |
|
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
|
1131 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1132 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1133 PyErr_NoMemory(); |
| 35742 | 1134 return NULL; |
| 1135 } | |
| 1136 p->kind = ImportFrom_kind; | |
| 1137 p->v.ImportFrom.module = module; | |
| 1138 p->v.ImportFrom.names = names; | |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
1139 p->v.ImportFrom.level = level; |
| 35742 | 1140 p->lineno = lineno; |
| 1141 return p; | |
| 1142 } | |
| 1143 | |
| 1144 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
|
1145 Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, PyArena *arena) |
| 35742 | 1146 { |
| 1147 stmt_ty p; | |
| 1148 if (!body) { | |
| 1149 PyErr_SetString(PyExc_ValueError, | |
| 1150 "field body is required for Exec"); | |
| 1151 return NULL; | |
| 1152 } | |
|
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
|
1153 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1154 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1155 PyErr_NoMemory(); |
| 35742 | 1156 return NULL; |
| 1157 } | |
| 1158 p->kind = Exec_kind; | |
| 1159 p->v.Exec.body = body; | |
| 1160 p->v.Exec.globals = globals; | |
| 1161 p->v.Exec.locals = locals; | |
| 1162 p->lineno = lineno; | |
| 1163 return p; | |
| 1164 } | |
| 1165 | |
| 1166 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
|
1167 Global(asdl_seq * names, int lineno, PyArena *arena) |
| 35742 | 1168 { |
| 1169 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
|
1170 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1171 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1172 PyErr_NoMemory(); |
| 35742 | 1173 return NULL; |
| 1174 } | |
| 1175 p->kind = Global_kind; | |
| 1176 p->v.Global.names = names; | |
| 1177 p->lineno = lineno; | |
| 1178 return p; | |
| 1179 } | |
| 1180 | |
| 1181 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
|
1182 Expr(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 1183 { |
| 1184 stmt_ty p; | |
| 1185 if (!value) { | |
| 1186 PyErr_SetString(PyExc_ValueError, | |
| 1187 "field value is required for Expr"); | |
| 1188 return NULL; | |
| 1189 } | |
|
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
|
1190 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1191 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1192 PyErr_NoMemory(); |
| 35742 | 1193 return NULL; |
| 1194 } | |
| 1195 p->kind = Expr_kind; | |
| 1196 p->v.Expr.value = value; | |
| 1197 p->lineno = lineno; | |
| 1198 return p; | |
| 1199 } | |
| 1200 | |
| 1201 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
|
1202 Pass(int lineno, PyArena *arena) |
| 35742 | 1203 { |
| 1204 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
|
1205 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1206 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1207 PyErr_NoMemory(); |
| 35742 | 1208 return NULL; |
| 1209 } | |
| 1210 p->kind = Pass_kind; | |
| 1211 p->lineno = lineno; | |
| 1212 return p; | |
| 1213 } | |
| 1214 | |
| 1215 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
|
1216 Break(int lineno, PyArena *arena) |
| 35742 | 1217 { |
| 1218 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
|
1219 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1220 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1221 PyErr_NoMemory(); |
| 35742 | 1222 return NULL; |
| 1223 } | |
| 1224 p->kind = Break_kind; | |
| 1225 p->lineno = lineno; | |
| 1226 return p; | |
| 1227 } | |
| 1228 | |
| 1229 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
|
1230 Continue(int lineno, PyArena *arena) |
| 35742 | 1231 { |
| 1232 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
|
1233 p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1234 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1235 PyErr_NoMemory(); |
| 35742 | 1236 return NULL; |
| 1237 } | |
| 1238 p->kind = Continue_kind; | |
| 1239 p->lineno = lineno; | |
| 1240 return p; | |
| 1241 } | |
| 1242 | |
| 1243 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
|
1244 BoolOp(boolop_ty op, asdl_seq * values, int lineno, PyArena *arena) |
| 35742 | 1245 { |
| 1246 expr_ty p; | |
| 1247 if (!op) { | |
| 1248 PyErr_SetString(PyExc_ValueError, | |
| 1249 "field op is required for BoolOp"); | |
| 1250 return NULL; | |
| 1251 } | |
|
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
|
1252 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1253 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1254 PyErr_NoMemory(); |
| 35742 | 1255 return NULL; |
| 1256 } | |
| 1257 p->kind = BoolOp_kind; | |
| 1258 p->v.BoolOp.op = op; | |
| 1259 p->v.BoolOp.values = values; | |
| 1260 p->lineno = lineno; | |
| 1261 return p; | |
| 1262 } | |
| 1263 | |
| 1264 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
|
1265 BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, PyArena *arena) |
| 35742 | 1266 { |
| 1267 expr_ty p; | |
| 1268 if (!left) { | |
| 1269 PyErr_SetString(PyExc_ValueError, | |
| 1270 "field left is required for BinOp"); | |
| 1271 return NULL; | |
| 1272 } | |
| 1273 if (!op) { | |
| 1274 PyErr_SetString(PyExc_ValueError, | |
| 1275 "field op is required for BinOp"); | |
| 1276 return NULL; | |
| 1277 } | |
| 1278 if (!right) { | |
| 1279 PyErr_SetString(PyExc_ValueError, | |
| 1280 "field right is required for BinOp"); | |
| 1281 return NULL; | |
| 1282 } | |
|
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
|
1283 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1284 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1285 PyErr_NoMemory(); |
| 35742 | 1286 return NULL; |
| 1287 } | |
| 1288 p->kind = BinOp_kind; | |
| 1289 p->v.BinOp.left = left; | |
| 1290 p->v.BinOp.op = op; | |
| 1291 p->v.BinOp.right = right; | |
| 1292 p->lineno = lineno; | |
| 1293 return p; | |
| 1294 } | |
| 1295 | |
| 1296 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
|
1297 UnaryOp(unaryop_ty op, expr_ty operand, int lineno, PyArena *arena) |
| 35742 | 1298 { |
| 1299 expr_ty p; | |
| 1300 if (!op) { | |
| 1301 PyErr_SetString(PyExc_ValueError, | |
| 1302 "field op is required for UnaryOp"); | |
| 1303 return NULL; | |
| 1304 } | |
| 1305 if (!operand) { | |
| 1306 PyErr_SetString(PyExc_ValueError, | |
| 1307 "field operand is required for UnaryOp"); | |
| 1308 return NULL; | |
| 1309 } | |
|
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
|
1310 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1311 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1312 PyErr_NoMemory(); |
| 35742 | 1313 return NULL; |
| 1314 } | |
| 1315 p->kind = UnaryOp_kind; | |
| 1316 p->v.UnaryOp.op = op; | |
| 1317 p->v.UnaryOp.operand = operand; | |
| 1318 p->lineno = lineno; | |
| 1319 return p; | |
| 1320 } | |
| 1321 | |
| 1322 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
|
1323 Lambda(arguments_ty args, expr_ty body, int lineno, PyArena *arena) |
| 35742 | 1324 { |
| 1325 expr_ty p; | |
| 1326 if (!args) { | |
| 1327 PyErr_SetString(PyExc_ValueError, | |
| 1328 "field args is required for Lambda"); | |
| 1329 return NULL; | |
| 1330 } | |
| 1331 if (!body) { | |
| 1332 PyErr_SetString(PyExc_ValueError, | |
| 1333 "field body is required for Lambda"); | |
| 1334 return NULL; | |
| 1335 } | |
|
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
|
1336 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1337 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1338 PyErr_NoMemory(); |
| 35742 | 1339 return NULL; |
| 1340 } | |
| 1341 p->kind = Lambda_kind; | |
| 1342 p->v.Lambda.args = args; | |
| 1343 p->v.Lambda.body = body; | |
| 1344 p->lineno = lineno; | |
| 1345 return p; | |
| 1346 } | |
| 1347 | |
| 1348 expr_ty | |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1349 IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, PyArena *arena) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1350 { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1351 expr_ty p; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1352 if (!test) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1353 PyErr_SetString(PyExc_ValueError, |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1354 "field test is required for IfExp"); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1355 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1356 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1357 if (!body) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1358 PyErr_SetString(PyExc_ValueError, |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1359 "field body is required for IfExp"); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1360 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1361 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1362 if (!orelse) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1363 PyErr_SetString(PyExc_ValueError, |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1364 "field orelse is required for IfExp"); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1365 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1366 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1367 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1368 if (!p) { |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1369 PyErr_NoMemory(); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1370 return NULL; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1371 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1372 p->kind = IfExp_kind; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1373 p->v.IfExp.test = test; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1374 p->v.IfExp.body = body; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1375 p->v.IfExp.orelse = orelse; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1376 p->lineno = lineno; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1377 return p; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1378 } |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1379 |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
1380 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
|
1381 Dict(asdl_seq * keys, asdl_seq * values, int lineno, PyArena *arena) |
| 35742 | 1382 { |
| 1383 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
|
1384 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1385 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1386 PyErr_NoMemory(); |
| 35742 | 1387 return NULL; |
| 1388 } | |
| 1389 p->kind = Dict_kind; | |
| 1390 p->v.Dict.keys = keys; | |
| 1391 p->v.Dict.values = values; | |
| 1392 p->lineno = lineno; | |
| 1393 return p; | |
| 1394 } | |
| 1395 | |
| 1396 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
|
1397 ListComp(expr_ty elt, asdl_seq * generators, int lineno, PyArena *arena) |
| 35742 | 1398 { |
| 1399 expr_ty p; | |
| 1400 if (!elt) { | |
| 1401 PyErr_SetString(PyExc_ValueError, | |
| 1402 "field elt is required for ListComp"); | |
| 1403 return NULL; | |
| 1404 } | |
|
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
|
1405 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1406 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1407 PyErr_NoMemory(); |
| 35742 | 1408 return NULL; |
| 1409 } | |
| 1410 p->kind = ListComp_kind; | |
| 1411 p->v.ListComp.elt = elt; | |
| 1412 p->v.ListComp.generators = generators; | |
| 1413 p->lineno = lineno; | |
| 1414 return p; | |
| 1415 } | |
| 1416 | |
| 1417 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
|
1418 GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, PyArena *arena) |
| 35742 | 1419 { |
| 1420 expr_ty p; | |
| 1421 if (!elt) { | |
| 1422 PyErr_SetString(PyExc_ValueError, | |
| 1423 "field elt is required for GeneratorExp"); | |
| 1424 return NULL; | |
| 1425 } | |
|
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
|
1426 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1427 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1428 PyErr_NoMemory(); |
| 35742 | 1429 return NULL; |
| 1430 } | |
| 1431 p->kind = GeneratorExp_kind; | |
| 1432 p->v.GeneratorExp.elt = elt; | |
| 1433 p->v.GeneratorExp.generators = generators; | |
| 1434 p->lineno = lineno; | |
| 1435 return p; | |
| 1436 } | |
| 1437 | |
| 1438 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
|
1439 Yield(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 1440 { |
| 1441 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
|
1442 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1443 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1444 PyErr_NoMemory(); |
| 35742 | 1445 return NULL; |
| 1446 } | |
| 1447 p->kind = Yield_kind; | |
| 1448 p->v.Yield.value = value; | |
| 1449 p->lineno = lineno; | |
| 1450 return p; | |
| 1451 } | |
| 1452 | |
| 1453 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
|
1454 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
|
1455 PyArena *arena) |
| 35742 | 1456 { |
| 1457 expr_ty p; | |
| 1458 if (!left) { | |
| 1459 PyErr_SetString(PyExc_ValueError, | |
| 1460 "field left is required for Compare"); | |
| 1461 return NULL; | |
| 1462 } | |
|
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
|
1463 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1464 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1465 PyErr_NoMemory(); |
| 35742 | 1466 return NULL; |
| 1467 } | |
| 1468 p->kind = Compare_kind; | |
| 1469 p->v.Compare.left = left; | |
| 1470 p->v.Compare.ops = ops; | |
| 1471 p->v.Compare.comparators = comparators; | |
| 1472 p->lineno = lineno; | |
| 1473 return p; | |
| 1474 } | |
| 1475 | |
| 1476 expr_ty | |
| 1477 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
|
1478 expr_ty kwargs, int lineno, PyArena *arena) |
| 35742 | 1479 { |
| 1480 expr_ty p; | |
| 1481 if (!func) { | |
| 1482 PyErr_SetString(PyExc_ValueError, | |
| 1483 "field func is required for Call"); | |
| 1484 return NULL; | |
| 1485 } | |
|
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
|
1486 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1487 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1488 PyErr_NoMemory(); |
| 35742 | 1489 return NULL; |
| 1490 } | |
| 1491 p->kind = Call_kind; | |
| 1492 p->v.Call.func = func; | |
| 1493 p->v.Call.args = args; | |
| 1494 p->v.Call.keywords = keywords; | |
| 1495 p->v.Call.starargs = starargs; | |
| 1496 p->v.Call.kwargs = kwargs; | |
| 1497 p->lineno = lineno; | |
| 1498 return p; | |
| 1499 } | |
| 1500 | |
| 1501 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
|
1502 Repr(expr_ty value, int lineno, PyArena *arena) |
| 35742 | 1503 { |
| 1504 expr_ty p; | |
| 1505 if (!value) { | |
| 1506 PyErr_SetString(PyExc_ValueError, | |
| 1507 "field value is required for Repr"); | |
| 1508 return NULL; | |
| 1509 } | |
|
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
|
1510 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1511 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1512 PyErr_NoMemory(); |
| 35742 | 1513 return NULL; |
| 1514 } | |
| 1515 p->kind = Repr_kind; | |
| 1516 p->v.Repr.value = value; | |
| 1517 p->lineno = lineno; | |
| 1518 return p; | |
| 1519 } | |
| 1520 | |
| 1521 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
|
1522 Num(object n, int lineno, PyArena *arena) |
| 35742 | 1523 { |
| 1524 expr_ty p; | |
| 1525 if (!n) { | |
| 1526 PyErr_SetString(PyExc_ValueError, | |
| 1527 "field n is required for Num"); | |
| 1528 return NULL; | |
| 1529 } | |
|
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
|
1530 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1531 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1532 PyErr_NoMemory(); |
| 35742 | 1533 return NULL; |
| 1534 } | |
| 1535 p->kind = Num_kind; | |
| 1536 p->v.Num.n = n; | |
| 1537 p->lineno = lineno; | |
| 1538 return p; | |
| 1539 } | |
| 1540 | |
| 1541 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
|
1542 Str(string s, int lineno, PyArena *arena) |
| 35742 | 1543 { |
| 1544 expr_ty p; | |
| 1545 if (!s) { | |
| 1546 PyErr_SetString(PyExc_ValueError, | |
| 1547 "field s is required for Str"); | |
| 1548 return NULL; | |
| 1549 } | |
|
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
|
1550 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1551 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1552 PyErr_NoMemory(); |
| 35742 | 1553 return NULL; |
| 1554 } | |
| 1555 p->kind = Str_kind; | |
| 1556 p->v.Str.s = s; | |
| 1557 p->lineno = lineno; | |
| 1558 return p; | |
| 1559 } | |
| 1560 | |
| 1561 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
|
1562 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
|
1563 PyArena *arena) |
| 35742 | 1564 { |
| 1565 expr_ty p; | |
| 1566 if (!value) { | |
| 1567 PyErr_SetString(PyExc_ValueError, | |
| 1568 "field value is required for Attribute"); | |
| 1569 return NULL; | |
| 1570 } | |
| 1571 if (!attr) { | |
| 1572 PyErr_SetString(PyExc_ValueError, | |
| 1573 "field attr is required for Attribute"); | |
| 1574 return NULL; | |
| 1575 } | |
| 1576 if (!ctx) { | |
| 1577 PyErr_SetString(PyExc_ValueError, | |
| 1578 "field ctx is required for Attribute"); | |
| 1579 return NULL; | |
| 1580 } | |
|
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
|
1581 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1582 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1583 PyErr_NoMemory(); |
| 35742 | 1584 return NULL; |
| 1585 } | |
| 1586 p->kind = Attribute_kind; | |
| 1587 p->v.Attribute.value = value; | |
| 1588 p->v.Attribute.attr = attr; | |
| 1589 p->v.Attribute.ctx = ctx; | |
| 1590 p->lineno = lineno; | |
| 1591 return p; | |
| 1592 } | |
| 1593 | |
| 1594 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
|
1595 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
|
1596 PyArena *arena) |
| 35742 | 1597 { |
| 1598 expr_ty p; | |
| 1599 if (!value) { | |
| 1600 PyErr_SetString(PyExc_ValueError, | |
| 1601 "field value is required for Subscript"); | |
| 1602 return NULL; | |
| 1603 } | |
| 1604 if (!slice) { | |
| 1605 PyErr_SetString(PyExc_ValueError, | |
| 1606 "field slice is required for Subscript"); | |
| 1607 return NULL; | |
| 1608 } | |
| 1609 if (!ctx) { | |
| 1610 PyErr_SetString(PyExc_ValueError, | |
| 1611 "field ctx is required for Subscript"); | |
| 1612 return NULL; | |
| 1613 } | |
|
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
|
1614 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1615 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1616 PyErr_NoMemory(); |
| 35742 | 1617 return NULL; |
| 1618 } | |
| 1619 p->kind = Subscript_kind; | |
| 1620 p->v.Subscript.value = value; | |
| 1621 p->v.Subscript.slice = slice; | |
| 1622 p->v.Subscript.ctx = ctx; | |
| 1623 p->lineno = lineno; | |
| 1624 return p; | |
| 1625 } | |
| 1626 | |
| 1627 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
|
1628 Name(identifier id, expr_context_ty ctx, int lineno, PyArena *arena) |
| 35742 | 1629 { |
| 1630 expr_ty p; | |
| 1631 if (!id) { | |
| 1632 PyErr_SetString(PyExc_ValueError, | |
| 1633 "field id is required for Name"); | |
| 1634 return NULL; | |
| 1635 } | |
| 1636 if (!ctx) { | |
| 1637 PyErr_SetString(PyExc_ValueError, | |
| 1638 "field ctx is required for Name"); | |
| 1639 return NULL; | |
| 1640 } | |
|
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
|
1641 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1642 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1643 PyErr_NoMemory(); |
| 35742 | 1644 return NULL; |
| 1645 } | |
| 1646 p->kind = Name_kind; | |
| 1647 p->v.Name.id = id; | |
| 1648 p->v.Name.ctx = ctx; | |
| 1649 p->lineno = lineno; | |
| 1650 return p; | |
| 1651 } | |
| 1652 | |
| 1653 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
|
1654 List(asdl_seq * elts, expr_context_ty ctx, int lineno, PyArena *arena) |
| 35742 | 1655 { |
| 1656 expr_ty p; | |
| 1657 if (!ctx) { | |
| 1658 PyErr_SetString(PyExc_ValueError, | |
| 1659 "field ctx is required for List"); | |
| 1660 return NULL; | |
| 1661 } | |
|
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
|
1662 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1663 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1664 PyErr_NoMemory(); |
| 35742 | 1665 return NULL; |
| 1666 } | |
| 1667 p->kind = List_kind; | |
| 1668 p->v.List.elts = elts; | |
| 1669 p->v.List.ctx = ctx; | |
| 1670 p->lineno = lineno; | |
| 1671 return p; | |
| 1672 } | |
| 1673 | |
| 1674 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
|
1675 Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, PyArena *arena) |
| 35742 | 1676 { |
| 1677 expr_ty p; | |
| 1678 if (!ctx) { | |
| 1679 PyErr_SetString(PyExc_ValueError, | |
| 1680 "field ctx is required for Tuple"); | |
| 1681 return NULL; | |
| 1682 } | |
|
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
|
1683 p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1684 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1685 PyErr_NoMemory(); |
| 35742 | 1686 return NULL; |
| 1687 } | |
| 1688 p->kind = Tuple_kind; | |
| 1689 p->v.Tuple.elts = elts; | |
| 1690 p->v.Tuple.ctx = ctx; | |
| 1691 p->lineno = lineno; | |
| 1692 return p; | |
| 1693 } | |
| 1694 | |
| 1695 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
|
1696 Ellipsis(PyArena *arena) |
| 35742 | 1697 { |
| 1698 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
|
1699 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1700 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1701 PyErr_NoMemory(); |
| 35742 | 1702 return NULL; |
| 1703 } | |
| 1704 p->kind = Ellipsis_kind; | |
| 1705 return p; | |
| 1706 } | |
| 1707 | |
| 1708 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
|
1709 Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) |
| 35742 | 1710 { |
| 1711 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
|
1712 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1713 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1714 PyErr_NoMemory(); |
| 35742 | 1715 return NULL; |
| 1716 } | |
| 1717 p->kind = Slice_kind; | |
| 1718 p->v.Slice.lower = lower; | |
| 1719 p->v.Slice.upper = upper; | |
| 1720 p->v.Slice.step = step; | |
| 1721 return p; | |
| 1722 } | |
| 1723 | |
| 1724 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
|
1725 ExtSlice(asdl_seq * dims, PyArena *arena) |
| 35742 | 1726 { |
| 1727 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
|
1728 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1729 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1730 PyErr_NoMemory(); |
| 35742 | 1731 return NULL; |
| 1732 } | |
| 1733 p->kind = ExtSlice_kind; | |
| 1734 p->v.ExtSlice.dims = dims; | |
| 1735 return p; | |
| 1736 } | |
| 1737 | |
| 1738 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
|
1739 Index(expr_ty value, PyArena *arena) |
| 35742 | 1740 { |
| 1741 slice_ty p; | |
| 1742 if (!value) { | |
| 1743 PyErr_SetString(PyExc_ValueError, | |
| 1744 "field value is required for Index"); | |
| 1745 return NULL; | |
| 1746 } | |
|
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
|
1747 p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1748 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1749 PyErr_NoMemory(); |
| 35742 | 1750 return NULL; |
| 1751 } | |
| 1752 p->kind = Index_kind; | |
| 1753 p->v.Index.value = value; | |
| 1754 return p; | |
| 1755 } | |
| 1756 | |
| 1757 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
|
1758 comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) |
| 35742 | 1759 { |
| 1760 comprehension_ty p; | |
| 1761 if (!target) { | |
| 1762 PyErr_SetString(PyExc_ValueError, | |
| 1763 "field target is required for comprehension"); | |
| 1764 return NULL; | |
| 1765 } | |
| 1766 if (!iter) { | |
| 1767 PyErr_SetString(PyExc_ValueError, | |
| 1768 "field iter is required for comprehension"); | |
| 1769 return NULL; | |
| 1770 } | |
|
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
|
1771 p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1772 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1773 PyErr_NoMemory(); |
| 35742 | 1774 return NULL; |
| 1775 } | |
| 1776 p->target = target; | |
| 1777 p->iter = iter; | |
| 1778 p->ifs = ifs; | |
| 1779 return p; | |
| 1780 } | |
| 1781 | |
| 1782 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
|
1783 excepthandler(expr_ty type, expr_ty name, asdl_seq * body, PyArena *arena) |
| 35742 | 1784 { |
| 1785 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
|
1786 p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1787 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1788 PyErr_NoMemory(); |
| 35742 | 1789 return NULL; |
| 1790 } | |
| 1791 p->type = type; | |
| 1792 p->name = name; | |
| 1793 p->body = body; | |
| 1794 return p; | |
| 1795 } | |
| 1796 | |
| 1797 arguments_ty | |
| 1798 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
|
1799 defaults, PyArena *arena) |
| 35742 | 1800 { |
| 1801 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
|
1802 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1803 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1804 PyErr_NoMemory(); |
| 35742 | 1805 return NULL; |
| 1806 } | |
| 1807 p->args = args; | |
| 1808 p->vararg = vararg; | |
| 1809 p->kwarg = kwarg; | |
| 1810 p->defaults = defaults; | |
| 1811 return p; | |
| 1812 } | |
| 1813 | |
| 1814 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
|
1815 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 35742 | 1816 { |
| 1817 keyword_ty p; | |
| 1818 if (!arg) { | |
| 1819 PyErr_SetString(PyExc_ValueError, | |
| 1820 "field arg is required for keyword"); | |
| 1821 return NULL; | |
| 1822 } | |
| 1823 if (!value) { | |
| 1824 PyErr_SetString(PyExc_ValueError, | |
| 1825 "field value is required for keyword"); | |
| 1826 return NULL; | |
| 1827 } | |
|
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
|
1828 p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1829 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1830 PyErr_NoMemory(); |
| 35742 | 1831 return NULL; |
| 1832 } | |
| 1833 p->arg = arg; | |
| 1834 p->value = value; | |
| 1835 return p; | |
| 1836 } | |
| 1837 | |
| 1838 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
|
1839 alias(identifier name, identifier asname, PyArena *arena) |
| 35742 | 1840 { |
| 1841 alias_ty p; | |
| 1842 if (!name) { | |
| 1843 PyErr_SetString(PyExc_ValueError, | |
| 1844 "field name is required for alias"); | |
| 1845 return NULL; | |
| 1846 } | |
|
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
|
1847 p = (alias_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 35742 | 1848 if (!p) { |
|
35784
c6dbf88e4b14
Use PyErr_NoMemory() instead of rolling our own.
Neal Norwitz <nnorwitz@gmail.com>
parents:
35742
diff
changeset
|
1849 PyErr_NoMemory(); |
| 35742 | 1850 return NULL; |
| 1851 } | |
| 1852 p->name = name; | |
| 1853 p->asname = asname; | |
| 1854 return p; | |
| 1855 } | |
| 1856 | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1857 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1858 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1859 ast2obj_mod(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1860 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1861 mod_ty o = (mod_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1862 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1863 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1864 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1865 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1866 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1867 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1868 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1869 case Module_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1870 result = PyType_GenericNew(Module_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1871 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1872 value = ast2obj_list(o->v.Module.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1873 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1874 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1875 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1876 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1877 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1878 case Interactive_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1879 result = PyType_GenericNew(Interactive_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1880 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1881 value = ast2obj_list(o->v.Interactive.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1882 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1883 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1884 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1885 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1886 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1887 case Expression_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1888 result = PyType_GenericNew(Expression_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1889 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1890 value = ast2obj_expr(o->v.Expression.body); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1891 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1892 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1893 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1894 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1895 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1896 case Suite_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1897 result = PyType_GenericNew(Suite_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1898 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1899 value = ast2obj_list(o->v.Suite.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1900 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1901 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1902 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1903 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1904 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1905 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1906 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1907 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1908 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1909 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1910 return NULL; |
| 36174 | 1911 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1912 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1913 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1914 ast2obj_stmt(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1915 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1916 stmt_ty o = (stmt_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1917 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1918 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1919 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1920 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1921 } |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
1922 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1923 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1924 case FunctionDef_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1925 result = PyType_GenericNew(FunctionDef_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1926 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1927 value = ast2obj_identifier(o->v.FunctionDef.name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1928 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1929 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1930 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1931 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1932 value = ast2obj_arguments(o->v.FunctionDef.args); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1933 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1934 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1935 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1936 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1937 value = ast2obj_list(o->v.FunctionDef.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1938 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1939 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1940 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1941 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1942 value = ast2obj_list(o->v.FunctionDef.decorators, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1943 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1944 if (PyObject_SetAttrString(result, "decorators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1945 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1946 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1947 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1948 case ClassDef_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1949 result = PyType_GenericNew(ClassDef_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1950 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1951 value = ast2obj_identifier(o->v.ClassDef.name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1952 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1953 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1954 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1955 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1956 value = ast2obj_list(o->v.ClassDef.bases, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1957 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1958 if (PyObject_SetAttrString(result, "bases", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1959 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1960 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1961 value = ast2obj_list(o->v.ClassDef.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1962 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1963 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1964 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1965 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1966 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1967 case Return_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1968 result = PyType_GenericNew(Return_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1969 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1970 value = ast2obj_expr(o->v.Return.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1971 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1972 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1973 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1974 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1975 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1976 case Delete_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1977 result = PyType_GenericNew(Delete_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1978 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1979 value = ast2obj_list(o->v.Delete.targets, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1980 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1981 if (PyObject_SetAttrString(result, "targets", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1982 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1983 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1984 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1985 case Assign_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1986 result = PyType_GenericNew(Assign_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1987 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1988 value = ast2obj_list(o->v.Assign.targets, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1989 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1990 if (PyObject_SetAttrString(result, "targets", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1991 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1992 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1993 value = ast2obj_expr(o->v.Assign.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1994 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1995 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1996 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1997 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1998 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
1999 case AugAssign_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2000 result = PyType_GenericNew(AugAssign_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2001 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2002 value = ast2obj_expr(o->v.AugAssign.target); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2003 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2004 if (PyObject_SetAttrString(result, "target", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2005 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2006 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2007 value = ast2obj_operator(o->v.AugAssign.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2008 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2009 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2010 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2011 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2012 value = ast2obj_expr(o->v.AugAssign.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2013 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2014 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2015 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2016 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2017 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2018 case Print_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2019 result = PyType_GenericNew(Print_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2020 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2021 value = ast2obj_expr(o->v.Print.dest); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2022 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2023 if (PyObject_SetAttrString(result, "dest", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2024 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2025 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2026 value = ast2obj_list(o->v.Print.values, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2027 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2028 if (PyObject_SetAttrString(result, "values", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2029 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2030 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2031 value = ast2obj_bool(o->v.Print.nl); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2032 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2033 if (PyObject_SetAttrString(result, "nl", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2034 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2035 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2036 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2037 case For_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2038 result = PyType_GenericNew(For_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2039 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2040 value = ast2obj_expr(o->v.For.target); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2041 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2042 if (PyObject_SetAttrString(result, "target", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2043 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2044 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2045 value = ast2obj_expr(o->v.For.iter); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2046 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2047 if (PyObject_SetAttrString(result, "iter", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2048 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2049 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2050 value = ast2obj_list(o->v.For.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2051 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2052 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2053 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2054 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2055 value = ast2obj_list(o->v.For.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2056 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2057 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2058 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2059 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2060 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2061 case While_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2062 result = PyType_GenericNew(While_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2063 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2064 value = ast2obj_expr(o->v.While.test); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2065 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2066 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2067 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2068 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2069 value = ast2obj_list(o->v.While.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2070 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2071 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2072 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2073 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2074 value = ast2obj_list(o->v.While.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2075 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2076 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2077 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2078 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2079 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2080 case If_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2081 result = PyType_GenericNew(If_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2082 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2083 value = ast2obj_expr(o->v.If.test); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2084 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2085 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2086 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2087 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2088 value = ast2obj_list(o->v.If.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2089 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2090 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2091 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2092 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2093 value = ast2obj_list(o->v.If.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2094 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2095 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2096 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2097 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2098 break; |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2099 case With_kind: |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2100 result = PyType_GenericNew(With_type, NULL, NULL); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2101 if (!result) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2102 value = ast2obj_expr(o->v.With.context_expr); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2103 if (!value) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2104 if (PyObject_SetAttrString(result, "context_expr", value) == -1) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2105 goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2106 Py_DECREF(value); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2107 value = ast2obj_expr(o->v.With.optional_vars); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2108 if (!value) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2109 if (PyObject_SetAttrString(result, "optional_vars", value) == |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2110 -1) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2111 goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2112 Py_DECREF(value); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2113 value = ast2obj_list(o->v.With.body, ast2obj_stmt); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2114 if (!value) goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2115 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2116 goto failed; |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2117 Py_DECREF(value); |
|
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2118 break; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2119 case Raise_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2120 result = PyType_GenericNew(Raise_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2121 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2122 value = ast2obj_expr(o->v.Raise.type); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2123 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2124 if (PyObject_SetAttrString(result, "type", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2125 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2126 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2127 value = ast2obj_expr(o->v.Raise.inst); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2128 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2129 if (PyObject_SetAttrString(result, "inst", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2130 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2131 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2132 value = ast2obj_expr(o->v.Raise.tback); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2133 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2134 if (PyObject_SetAttrString(result, "tback", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2135 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2136 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2137 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2138 case TryExcept_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2139 result = PyType_GenericNew(TryExcept_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2140 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2141 value = ast2obj_list(o->v.TryExcept.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2142 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2143 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2144 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2145 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2146 value = ast2obj_list(o->v.TryExcept.handlers, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2147 ast2obj_excepthandler); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2148 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2149 if (PyObject_SetAttrString(result, "handlers", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2150 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2151 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2152 value = ast2obj_list(o->v.TryExcept.orelse, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2153 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2154 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2155 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2156 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2157 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2158 case TryFinally_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2159 result = PyType_GenericNew(TryFinally_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2160 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2161 value = ast2obj_list(o->v.TryFinally.body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2162 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2163 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2164 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2165 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2166 value = ast2obj_list(o->v.TryFinally.finalbody, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2167 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2168 if (PyObject_SetAttrString(result, "finalbody", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2169 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2170 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2171 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2172 case Assert_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2173 result = PyType_GenericNew(Assert_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2174 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2175 value = ast2obj_expr(o->v.Assert.test); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2176 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2177 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2178 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2179 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2180 value = ast2obj_expr(o->v.Assert.msg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2181 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2182 if (PyObject_SetAttrString(result, "msg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2183 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2184 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2185 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2186 case Import_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2187 result = PyType_GenericNew(Import_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2188 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2189 value = ast2obj_list(o->v.Import.names, ast2obj_alias); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2190 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2191 if (PyObject_SetAttrString(result, "names", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2192 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2193 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2194 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2195 case ImportFrom_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2196 result = PyType_GenericNew(ImportFrom_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2197 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2198 value = ast2obj_identifier(o->v.ImportFrom.module); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2199 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2200 if (PyObject_SetAttrString(result, "module", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2201 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2202 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2203 value = ast2obj_list(o->v.ImportFrom.names, ast2obj_alias); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2204 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2205 if (PyObject_SetAttrString(result, "names", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2206 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2207 Py_DECREF(value); |
|
36712
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2208 value = ast2obj_int(o->v.ImportFrom.level); |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2209 if (!value) goto failed; |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2210 if (PyObject_SetAttrString(result, "level", value) == -1) |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2211 goto failed; |
|
5c36c222e7ca
SF patch #1438387, PEP 328: relative and absolute imports.
Thomas Wouters <thomas@python.org>
parents:
36707
diff
changeset
|
2212 Py_DECREF(value); |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2213 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2214 case Exec_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2215 result = PyType_GenericNew(Exec_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2216 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2217 value = ast2obj_expr(o->v.Exec.body); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2218 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2219 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2220 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2221 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2222 value = ast2obj_expr(o->v.Exec.globals); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2223 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2224 if (PyObject_SetAttrString(result, "globals", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2225 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2226 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2227 value = ast2obj_expr(o->v.Exec.locals); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2228 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2229 if (PyObject_SetAttrString(result, "locals", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2230 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2231 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2232 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2233 case Global_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2234 result = PyType_GenericNew(Global_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2235 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2236 value = ast2obj_list(o->v.Global.names, ast2obj_identifier); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2237 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2238 if (PyObject_SetAttrString(result, "names", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2239 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2240 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2241 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2242 case Expr_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2243 result = PyType_GenericNew(Expr_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2244 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2245 value = ast2obj_expr(o->v.Expr.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2246 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2247 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2248 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2249 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2250 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2251 case Pass_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2252 result = PyType_GenericNew(Pass_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2253 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2254 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2255 case Break_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2256 result = PyType_GenericNew(Break_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2257 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2258 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2259 case Continue_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2260 result = PyType_GenericNew(Continue_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2261 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2262 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2263 } |
| 36669 | 2264 value = ast2obj_int(o->lineno); |
| 2265 if (!value) goto failed; | |
| 2266 PyObject_SetAttrString(result, "lineno", value); | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2267 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2268 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2269 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2270 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2271 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2272 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2273 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2274 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2275 ast2obj_expr(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2276 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2277 expr_ty o = (expr_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2278 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2279 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2280 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2281 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2282 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2283 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2284 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2285 case BoolOp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2286 result = PyType_GenericNew(BoolOp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2287 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2288 value = ast2obj_boolop(o->v.BoolOp.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2289 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2290 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2291 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2292 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2293 value = ast2obj_list(o->v.BoolOp.values, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2294 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2295 if (PyObject_SetAttrString(result, "values", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2296 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2297 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2298 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2299 case BinOp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2300 result = PyType_GenericNew(BinOp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2301 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2302 value = ast2obj_expr(o->v.BinOp.left); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2303 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2304 if (PyObject_SetAttrString(result, "left", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2305 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2306 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2307 value = ast2obj_operator(o->v.BinOp.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2308 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2309 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2310 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2311 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2312 value = ast2obj_expr(o->v.BinOp.right); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2313 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2314 if (PyObject_SetAttrString(result, "right", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2315 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2316 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2317 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2318 case UnaryOp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2319 result = PyType_GenericNew(UnaryOp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2320 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2321 value = ast2obj_unaryop(o->v.UnaryOp.op); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2322 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2323 if (PyObject_SetAttrString(result, "op", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2324 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2325 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2326 value = ast2obj_expr(o->v.UnaryOp.operand); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2327 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2328 if (PyObject_SetAttrString(result, "operand", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2329 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2330 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2331 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2332 case Lambda_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2333 result = PyType_GenericNew(Lambda_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2334 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2335 value = ast2obj_arguments(o->v.Lambda.args); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2336 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2337 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2338 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2339 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2340 value = ast2obj_expr(o->v.Lambda.body); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2341 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2342 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2343 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2344 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2345 break; |
|
36666
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2346 case IfExp_kind: |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2347 result = PyType_GenericNew(IfExp_type, NULL, NULL); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2348 if (!result) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2349 value = ast2obj_expr(o->v.IfExp.test); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2350 if (!value) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2351 if (PyObject_SetAttrString(result, "test", value) == -1) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2352 goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2353 Py_DECREF(value); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2354 value = ast2obj_expr(o->v.IfExp.body); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2355 if (!value) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2356 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2357 goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2358 Py_DECREF(value); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2359 value = ast2obj_expr(o->v.IfExp.orelse); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2360 if (!value) goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2361 if (PyObject_SetAttrString(result, "orelse", value) == -1) |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2362 goto failed; |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2363 Py_DECREF(value); |
|
6165927431d6
PEP 308 implementation, including minor refdocs and some testcases. It
Thomas Wouters <thomas@python.org>
parents:
36665
diff
changeset
|
2364 break; |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2365 case Dict_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2366 result = PyType_GenericNew(Dict_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2367 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2368 value = ast2obj_list(o->v.Dict.keys, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2369 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2370 if (PyObject_SetAttrString(result, "keys", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2371 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2372 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2373 value = ast2obj_list(o->v.Dict.values, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2374 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2375 if (PyObject_SetAttrString(result, "values", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2376 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2377 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2378 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2379 case ListComp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2380 result = PyType_GenericNew(ListComp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2381 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2382 value = ast2obj_expr(o->v.ListComp.elt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2383 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2384 if (PyObject_SetAttrString(result, "elt", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2385 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2386 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2387 value = ast2obj_list(o->v.ListComp.generators, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2388 ast2obj_comprehension); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2389 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2390 if (PyObject_SetAttrString(result, "generators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2391 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2392 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2393 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2394 case GeneratorExp_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2395 result = PyType_GenericNew(GeneratorExp_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2396 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2397 value = ast2obj_expr(o->v.GeneratorExp.elt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2398 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2399 if (PyObject_SetAttrString(result, "elt", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2400 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2401 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2402 value = ast2obj_list(o->v.GeneratorExp.generators, |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2403 ast2obj_comprehension); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2404 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2405 if (PyObject_SetAttrString(result, "generators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2406 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2407 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2408 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2409 case Yield_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2410 result = PyType_GenericNew(Yield_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2411 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2412 value = ast2obj_expr(o->v.Yield.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2413 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2414 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2415 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2416 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2417 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2418 case Compare_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2419 result = PyType_GenericNew(Compare_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2420 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2421 value = ast2obj_expr(o->v.Compare.left); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2422 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2423 if (PyObject_SetAttrString(result, "left", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2424 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2425 Py_DECREF(value); |
|
36661
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2426 { |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2427 int i, n = asdl_seq_LEN(o->v.Compare.ops); |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2428 value = PyList_New(n); |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2429 if (!value) goto failed; |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2430 for(i = 0; i < n; i++) |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2431 PyList_SET_ITEM(value, i, ast2obj_cmpop((cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i))); |
|
710cbdd478a8
Fix iterating over cmpop_ty lists.
Martin v. Löwis <martin@v.loewis.de>
parents:
36660
diff
changeset
|
2432 } |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2433 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2434 if (PyObject_SetAttrString(result, "ops", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2435 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2436 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2437 value = ast2obj_list(o->v.Compare.comparators, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2438 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2439 if (PyObject_SetAttrString(result, "comparators", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2440 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2441 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2442 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2443 case Call_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2444 result = PyType_GenericNew(Call_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2445 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2446 value = ast2obj_expr(o->v.Call.func); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2447 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2448 if (PyObject_SetAttrString(result, "func", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2449 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2450 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2451 value = ast2obj_list(o->v.Call.args, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2452 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2453 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2454 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2455 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2456 value = ast2obj_list(o->v.Call.keywords, ast2obj_keyword); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2457 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2458 if (PyObject_SetAttrString(result, "keywords", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2459 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2460 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2461 value = ast2obj_expr(o->v.Call.starargs); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2462 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2463 if (PyObject_SetAttrString(result, "starargs", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2464 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2465 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2466 value = ast2obj_expr(o->v.Call.kwargs); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2467 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2468 if (PyObject_SetAttrString(result, "kwargs", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2469 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2470 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2471 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2472 case Repr_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2473 result = PyType_GenericNew(Repr_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2474 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2475 value = ast2obj_expr(o->v.Repr.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2476 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2477 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2478 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2479 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2480 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2481 case Num_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2482 result = PyType_GenericNew(Num_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2483 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2484 value = ast2obj_object(o->v.Num.n); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2485 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2486 if (PyObject_SetAttrString(result, "n", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2487 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2488 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2489 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2490 case Str_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2491 result = PyType_GenericNew(Str_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2492 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2493 value = ast2obj_string(o->v.Str.s); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2494 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2495 if (PyObject_SetAttrString(result, "s", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2496 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2497 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2498 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2499 case Attribute_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2500 result = PyType_GenericNew(Attribute_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2501 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2502 value = ast2obj_expr(o->v.Attribute.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2503 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2504 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2505 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2506 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2507 value = ast2obj_identifier(o->v.Attribute.attr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2508 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2509 if (PyObject_SetAttrString(result, "attr", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2510 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2511 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2512 value = ast2obj_expr_context(o->v.Attribute.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2513 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2514 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2515 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2516 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2517 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2518 case Subscript_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2519 result = PyType_GenericNew(Subscript_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2520 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2521 value = ast2obj_expr(o->v.Subscript.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2522 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2523 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2524 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2525 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2526 value = ast2obj_slice(o->v.Subscript.slice); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2527 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2528 if (PyObject_SetAttrString(result, "slice", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2529 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2530 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2531 value = ast2obj_expr_context(o->v.Subscript.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2532 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2533 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2534 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2535 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2536 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2537 case Name_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2538 result = PyType_GenericNew(Name_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2539 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2540 value = ast2obj_identifier(o->v.Name.id); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2541 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2542 if (PyObject_SetAttrString(result, "id", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2543 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2544 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2545 value = ast2obj_expr_context(o->v.Name.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2546 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2547 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2548 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2549 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2550 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2551 case List_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2552 result = PyType_GenericNew(List_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2553 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2554 value = ast2obj_list(o->v.List.elts, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2555 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2556 if (PyObject_SetAttrString(result, "elts", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2557 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2558 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2559 value = ast2obj_expr_context(o->v.List.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2560 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2561 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2562 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2563 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2564 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2565 case Tuple_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2566 result = PyType_GenericNew(Tuple_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2567 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2568 value = ast2obj_list(o->v.Tuple.elts, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2569 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2570 if (PyObject_SetAttrString(result, "elts", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2571 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2572 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2573 value = ast2obj_expr_context(o->v.Tuple.ctx); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2574 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2575 if (PyObject_SetAttrString(result, "ctx", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2576 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2577 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2578 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2579 } |
| 36669 | 2580 value = ast2obj_int(o->lineno); |
| 2581 if (!value) goto failed; | |
| 2582 PyObject_SetAttrString(result, "lineno", value); | |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2583 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2584 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2585 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2586 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2587 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2588 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2589 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2590 PyObject* ast2obj_expr_context(expr_context_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2591 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2592 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2593 case Load: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2594 Py_INCREF(Load_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2595 return Load_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2596 case Store: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2597 Py_INCREF(Store_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2598 return Store_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2599 case Del: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2600 Py_INCREF(Del_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2601 return Del_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2602 case AugLoad: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2603 Py_INCREF(AugLoad_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2604 return AugLoad_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2605 case AugStore: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2606 Py_INCREF(AugStore_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2607 return AugStore_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2608 case Param: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2609 Py_INCREF(Param_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2610 return Param_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2611 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2612 return NULL; /* cannot happen */ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2613 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2614 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2615 ast2obj_slice(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2616 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2617 slice_ty o = (slice_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2618 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2619 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2620 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2621 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2622 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2623 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2624 switch (o->kind) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2625 case Ellipsis_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2626 result = PyType_GenericNew(Ellipsis_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2627 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2628 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2629 case Slice_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2630 result = PyType_GenericNew(Slice_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2631 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2632 value = ast2obj_expr(o->v.Slice.lower); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2633 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2634 if (PyObject_SetAttrString(result, "lower", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2635 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2636 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2637 value = ast2obj_expr(o->v.Slice.upper); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2638 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2639 if (PyObject_SetAttrString(result, "upper", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2640 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2641 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2642 value = ast2obj_expr(o->v.Slice.step); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2643 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2644 if (PyObject_SetAttrString(result, "step", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2645 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2646 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2647 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2648 case ExtSlice_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2649 result = PyType_GenericNew(ExtSlice_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2650 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2651 value = ast2obj_list(o->v.ExtSlice.dims, ast2obj_slice); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2652 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2653 if (PyObject_SetAttrString(result, "dims", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2654 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2655 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2656 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2657 case Index_kind: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2658 result = PyType_GenericNew(Index_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2659 if (!result) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2660 value = ast2obj_expr(o->v.Index.value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2661 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2662 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2663 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2664 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2665 break; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2666 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2667 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2668 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2669 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2670 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2671 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2672 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2673 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2674 PyObject* ast2obj_boolop(boolop_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2675 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2676 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2677 case And: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2678 Py_INCREF(And_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2679 return And_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2680 case Or: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2681 Py_INCREF(Or_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2682 return Or_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2683 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2684 return NULL; /* cannot happen */ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2685 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2686 PyObject* ast2obj_operator(operator_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2687 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2688 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2689 case Add: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2690 Py_INCREF(Add_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2691 return Add_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2692 case Sub: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2693 Py_INCREF(Sub_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2694 return Sub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2695 case Mult: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2696 Py_INCREF(Mult_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2697 return Mult_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2698 case Div: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2699 Py_INCREF(Div_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2700 return Div_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2701 case Mod: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2702 Py_INCREF(Mod_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2703 return Mod_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2704 case Pow: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2705 Py_INCREF(Pow_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2706 return Pow_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2707 case LShift: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2708 Py_INCREF(LShift_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2709 return LShift_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2710 case RShift: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2711 Py_INCREF(RShift_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2712 return RShift_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2713 case BitOr: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2714 Py_INCREF(BitOr_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2715 return BitOr_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2716 case BitXor: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2717 Py_INCREF(BitXor_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2718 return BitXor_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2719 case BitAnd: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2720 Py_INCREF(BitAnd_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2721 return BitAnd_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2722 case FloorDiv: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2723 Py_INCREF(FloorDiv_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2724 return FloorDiv_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2725 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2726 return NULL; /* cannot happen */ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2727 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2728 PyObject* ast2obj_unaryop(unaryop_ty o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2729 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2730 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2731 case Invert: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2732 Py_INCREF(Invert_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2733 return Invert_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2734 case Not: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2735 Py_INCREF(Not_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2736 return Not_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2737 case UAdd: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2738 Py_INCREF(UAdd_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2739 return UAdd_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2740 case USub: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2741 Py_INCREF(USub_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2742 return USub_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2743 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2744 return NULL; /* cannot happen */ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2745 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2746 PyObject* ast2obj_cmpop(cmpop_ty o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2747 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2748 switch(o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2749 case Eq: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2750 Py_INCREF(Eq_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2751 return Eq_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2752 case NotEq: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2753 Py_INCREF(NotEq_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2754 return NotEq_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2755 case Lt: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2756 Py_INCREF(Lt_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2757 return Lt_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2758 case LtE: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2759 Py_INCREF(LtE_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2760 return LtE_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2761 case Gt: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2762 Py_INCREF(Gt_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2763 return Gt_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2764 case GtE: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2765 Py_INCREF(GtE_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2766 return GtE_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2767 case Is: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2768 Py_INCREF(Is_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2769 return Is_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2770 case IsNot: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2771 Py_INCREF(IsNot_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2772 return IsNot_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2773 case In: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2774 Py_INCREF(In_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2775 return In_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2776 case NotIn: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2777 Py_INCREF(NotIn_singleton); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2778 return NotIn_singleton; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2779 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2780 return NULL; /* cannot happen */ |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2781 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2782 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2783 ast2obj_comprehension(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2784 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2785 comprehension_ty o = (comprehension_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2786 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2787 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2788 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2789 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2790 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2791 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2792 result = PyType_GenericNew(comprehension_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2793 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2794 value = ast2obj_expr(o->target); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2795 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2796 if (PyObject_SetAttrString(result, "target", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2797 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2798 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2799 value = ast2obj_expr(o->iter); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2800 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2801 if (PyObject_SetAttrString(result, "iter", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2802 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2803 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2804 value = ast2obj_list(o->ifs, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2805 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2806 if (PyObject_SetAttrString(result, "ifs", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2807 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2808 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2809 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2810 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2811 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2812 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2813 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2814 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2815 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2816 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2817 ast2obj_excepthandler(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2818 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2819 excepthandler_ty o = (excepthandler_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2820 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2821 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2822 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2823 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2824 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2825 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2826 result = PyType_GenericNew(excepthandler_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2827 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2828 value = ast2obj_expr(o->type); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2829 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2830 if (PyObject_SetAttrString(result, "type", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2831 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2832 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2833 value = ast2obj_expr(o->name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2834 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2835 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2836 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2837 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2838 value = ast2obj_list(o->body, ast2obj_stmt); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2839 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2840 if (PyObject_SetAttrString(result, "body", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2841 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2842 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2843 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2844 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2845 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2846 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2847 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2848 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2849 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2850 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2851 ast2obj_arguments(void* _o) |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2852 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2853 arguments_ty o = (arguments_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2854 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2855 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2856 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2857 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2858 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2859 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2860 result = PyType_GenericNew(arguments_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2861 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2862 value = ast2obj_list(o->args, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2863 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2864 if (PyObject_SetAttrString(result, "args", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2865 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2866 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2867 value = ast2obj_identifier(o->vararg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2868 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2869 if (PyObject_SetAttrString(result, "vararg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2870 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2871 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2872 value = ast2obj_identifier(o->kwarg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2873 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2874 if (PyObject_SetAttrString(result, "kwarg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2875 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2876 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2877 value = ast2obj_list(o->defaults, ast2obj_expr); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2878 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2879 if (PyObject_SetAttrString(result, "defaults", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2880 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2881 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2882 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2883 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2884 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2885 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2886 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2887 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2888 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2889 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2890 ast2obj_keyword(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2891 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2892 keyword_ty o = (keyword_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2893 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2894 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2895 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2896 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2897 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2898 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2899 result = PyType_GenericNew(keyword_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2900 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2901 value = ast2obj_identifier(o->arg); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2902 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2903 if (PyObject_SetAttrString(result, "arg", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2904 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2905 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2906 value = ast2obj_expr(o->value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2907 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2908 if (PyObject_SetAttrString(result, "value", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2909 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2910 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2911 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2912 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2913 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2914 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2915 return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2916 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2917 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2918 PyObject* |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2919 ast2obj_alias(void* _o) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2920 { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2921 alias_ty o = (alias_ty)_o; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2922 PyObject *result = NULL, *value = NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2923 if (!o) { |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2924 Py_INCREF(Py_None); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2925 return Py_None; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2926 } |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2927 |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2928 result = PyType_GenericNew(alias_type, NULL, NULL); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2929 if (!result) return NULL; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2930 value = ast2obj_identifier(o->name); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2931 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2932 if (PyObject_SetAttrString(result, "name", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2933 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2934 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2935 value = ast2obj_identifier(o->asname); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2936 if (!value) goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2937 if (PyObject_SetAttrString(result, "asname", value) == -1) |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2938 goto failed; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2939 Py_DECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2940 return result; |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2941 failed: |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2942 Py_XDECREF(value); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2943 Py_XDECREF(result); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
2944 return NULL; |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2945 } |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2946 |
|
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
2947 |
| 36669 | 2948 PyMODINIT_FUNC |
| 2949 init_ast(void) | |
| 2950 { | |
| 2951 PyObject *m, *d; | |
| 2952 if (!init_types()) return; | |
| 2953 m = Py_InitModule3("_ast", NULL, NULL); | |
| 2954 if (!m) return; | |
| 2955 d = PyModule_GetDict(m); | |
| 2956 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; | |
| 2957 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) | |
| 2958 return; | |
|
36726
bbf16fd024df
from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents:
36712
diff
changeset
|
2959 if (PyModule_AddStringConstant(m, "__version__", "42649") < 0) |
| 36707 | 2960 return; |
| 36669 | 2961 if(PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; |
| 2962 if(PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) | |
| 2963 return; | |
| 2964 if(PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) | |
| 2965 < 0) return; | |
| 2966 if(PyDict_SetItemString(d, "Expression", (PyObject*)Expression_type) < | |
| 2967 0) return; | |
| 2968 if(PyDict_SetItemString(d, "Suite", (PyObject*)Suite_type) < 0) return; | |
| 2969 if(PyDict_SetItemString(d, "stmt", (PyObject*)stmt_type) < 0) return; | |
| 2970 if(PyDict_SetItemString(d, "FunctionDef", (PyObject*)FunctionDef_type) | |
| 2971 < 0) return; | |
| 2972 if(PyDict_SetItemString(d, "ClassDef", (PyObject*)ClassDef_type) < 0) | |
| 2973 return; | |
| 2974 if(PyDict_SetItemString(d, "Return", (PyObject*)Return_type) < 0) | |
| 2975 return; | |
| 2976 if(PyDict_SetItemString(d, "Delete", (PyObject*)Delete_type) < 0) | |
| 2977 return; | |
| 2978 if(PyDict_SetItemString(d, "Assign", (PyObject*)Assign_type) < 0) | |
| 2979 return; | |
| 2980 if(PyDict_SetItemString(d, "AugAssign", (PyObject*)AugAssign_type) < 0) | |
| 2981 return; | |
| 2982 if(PyDict_SetItemString(d, "Print", (PyObject*)Print_type) < 0) return; | |
| 2983 if(PyDict_SetItemString(d, "For", (PyObject*)For_type) < 0) return; | |
| 2984 if(PyDict_SetItemString(d, "While", (PyObject*)While_type) < 0) return; | |
| 2985 if(PyDict_SetItemString(d, "If", (PyObject*)If_type) < 0) return; | |
|
36695
b6d2f6fd3e11
PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents:
36669
diff
changeset
|
2986 if(PyDict_SetItemString(d, "With", (PyObject*)With_type) < 0) return; |
| 36669 | 2987 if(PyDict_SetItemString(d, "Raise", (PyObject*)Raise_type) < 0) return; |
| 2988 if(PyDict_SetItemString(d, "TryExcept", (PyObject*)TryExcept_type) < 0) | |
| 2989 return; | |
| 2990 if(PyDict_SetItemString(d, "TryFinally", (PyObject*)TryFinally_type) < | |
| 2991 0) return; | |
| 2992 if(PyDict_SetItemString(d, "Assert", (PyObject*)Assert_type) < 0) | |
| 2993 return; | |
| 2994 if(PyDict_SetItemString(d, "Import", (PyObject*)Import_type) < 0) | |
| 2995 return; | |
| 2996 if(PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < | |
| 2997 0) return; | |
| 2998 if(PyDict_SetItemString(d, "Exec", (PyObject*)Exec_type) < 0) return; | |
| 2999 if(PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) | |
| 3000 return; | |
| 3001 if(PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return; | |
| 3002 if(PyDict_SetItemString(d, "Pass", (PyObject*)Pass_type) < 0) return; | |
| 3003 if(PyDict_SetItemString(d, "Break", (PyObject*)Break_type) < 0) return; | |
| 3004 if(PyDict_SetItemString(d, "Continue", (PyObject*)Continue_type) < 0) | |
| 3005 return; | |
| 3006 if(PyDict_SetItemString(d, "expr", (PyObject*)expr_type) < 0) return; | |
| 3007 if(PyDict_SetItemString(d, "BoolOp", (PyObject*)BoolOp_type) < 0) | |
| 3008 return; | |
| 3009 if(PyDict_SetItemString(d, "BinOp", (PyObject*)BinOp_type) < 0) return; | |
| 3010 if(PyDict_SetItemString(d, "UnaryOp", (PyObject*)UnaryOp_type) < 0) | |
| 3011 return; | |
| 3012 if(PyDict_SetItemString(d, "Lambda", (PyObject*)Lambda_type) < 0) | |
| 3013 return; | |
| 3014 if(PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return; | |
| 3015 if(PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return; | |
| 3016 if(PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) | |
| 3017 return; | |
| 3018 if(PyDict_SetItemString(d, "GeneratorExp", | |
| 3019 (PyObject*)GeneratorExp_type) < 0) return; | |
| 3020 if(PyDict_SetItemString(d, "Yield", (PyObject*)Yield_type) < 0) return; | |
| 3021 if(PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) | |
| 3022 return; | |
| 3023 if(PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; | |
| 3024 if(PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return; | |
| 3025 if(PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; | |
| 3026 if(PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; | |
| 3027 if(PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0) | |
| 3028 return; | |
| 3029 if(PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < 0) | |
| 3030 return; | |
| 3031 if(PyDict_SetItemString(d, "Name", (PyObject*)Name_type) < 0) return; | |
| 3032 if(PyDict_SetItemString(d, "List", (PyObject*)List_type) < 0) return; | |
| 3033 if(PyDict_SetItemString(d, "Tuple", (PyObject*)Tuple_type) < 0) return; | |
| 3034 if(PyDict_SetItemString(d, "expr_context", | |
| 3035 (PyObject*)expr_context_type) < 0) return; | |
| 3036 if(PyDict_SetItemString(d, "Load", (PyObject*)Load_type) < 0) return; | |
| 3037 if(PyDict_SetItemString(d, "Store", (PyObject*)Store_type) < 0) return; | |
| 3038 if(PyDict_SetItemString(d, "Del", (PyObject*)Del_type) < 0) return; | |
| 3039 if(PyDict_SetItemString(d, "AugLoad", (PyObject*)AugLoad_type) < 0) | |
| 3040 return; | |
| 3041 if(PyDict_SetItemString(d, "AugStore", (PyObject*)AugStore_type) < 0) | |
| 3042 return; | |
| 3043 if(PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return; | |
| 3044 if(PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return; | |
| 3045 if(PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) | |
| 3046 return; | |
| 3047 if(PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return; | |
| 3048 if(PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) | |
| 3049 return; | |
| 3050 if(PyDict_SetItemString(d, "Index", (PyObject*)Index_type) < 0) return; | |
| 3051 if(PyDict_SetItemString(d, "boolop", (PyObject*)boolop_type) < 0) | |
| 3052 return; | |
| 3053 if(PyDict_SetItemString(d, "And", (PyObject*)And_type) < 0) return; | |
| 3054 if(PyDict_SetItemString(d, "Or", (PyObject*)Or_type) < 0) return; | |
| 3055 if(PyDict_SetItemString(d, "operator", (PyObject*)operator_type) < 0) | |
| 3056 return; | |
| 3057 if(PyDict_SetItemString(d, "Add", (PyObject*)Add_type) < 0) return; | |
| 3058 if(PyDict_SetItemString(d, "Sub", (PyObject*)Sub_type) < 0) return; | |
| 3059 if(PyDict_SetItemString(d, "Mult", (PyObject*)Mult_type) < 0) return; | |
| 3060 if(PyDict_SetItemString(d, "Div", (PyObject*)Div_type) < 0) return; | |
| 3061 if(PyDict_SetItemString(d, "Mod", (PyObject*)Mod_type) < 0) return; | |
| 3062 if(PyDict_SetItemString(d, "Pow", (PyObject*)Pow_type) < 0) return; | |
| 3063 if(PyDict_SetItemString(d, "LShift", (PyObject*)LShift_type) < 0) | |
| 3064 return; | |
| 3065 if(PyDict_SetItemString(d, "RShift", (PyObject*)RShift_type) < 0) | |
| 3066 return; | |
| 3067 if(PyDict_SetItemString(d, "BitOr", (PyObject*)BitOr_type) < 0) return; | |
| 3068 if(PyDict_SetItemString(d, "BitXor", (PyObject*)BitXor_type) < 0) | |
| 3069 return; | |
| 3070 if(PyDict_SetItemString(d, "BitAnd", (PyObject*)BitAnd_type) < 0) | |
| 3071 return; | |
| 3072 if(PyDict_SetItemString(d, "FloorDiv", (PyObject*)FloorDiv_type) < 0) | |
| 3073 return; | |
| 3074 if(PyDict_SetItemString(d, "unaryop", (PyObject*)unaryop_type) < 0) | |
| 3075 return; | |
| 3076 if(PyDict_SetItemString(d, "Invert", (PyObject*)Invert_type) < 0) | |
| 3077 return; | |
| 3078 if(PyDict_SetItemString(d, "Not", (PyObject*)Not_type) < 0) return; | |
| 3079 if(PyDict_SetItemString(d, "UAdd", (PyObject*)UAdd_type) < 0) return; | |
| 3080 if(PyDict_SetItemString(d, "USub", (PyObject*)USub_type) < 0) return; | |
| 3081 if(PyDict_SetItemString(d, "cmpop", (PyObject*)cmpop_type) < 0) return; | |
| 3082 if(PyDict_SetItemString(d, "Eq", (PyObject*)Eq_type) < 0) return; | |
| 3083 if(PyDict_SetItemString(d, "NotEq", (PyObject*)NotEq_type) < 0) return; | |
| 3084 if(PyDict_SetItemString(d, "Lt", (PyObject*)Lt_type) < 0) return; | |
| 3085 if(PyDict_SetItemString(d, "LtE", (PyObject*)LtE_type) < 0) return; | |
| 3086 if(PyDict_SetItemString(d, "Gt", (PyObject*)Gt_type) < 0) return; | |
| 3087 if(PyDict_SetItemString(d, "GtE", (PyObject*)GtE_type) < 0) return; | |
| 3088 if(PyDict_SetItemString(d, "Is", (PyObject*)Is_type) < 0) return; | |
| 3089 if(PyDict_SetItemString(d, "IsNot", (PyObject*)IsNot_type) < 0) return; | |
| 3090 if(PyDict_SetItemString(d, "In", (PyObject*)In_type) < 0) return; | |
| 3091 if(PyDict_SetItemString(d, "NotIn", (PyObject*)NotIn_type) < 0) return; | |
| 3092 if(PyDict_SetItemString(d, "comprehension", | |
| 3093 (PyObject*)comprehension_type) < 0) return; | |
| 3094 if(PyDict_SetItemString(d, "excepthandler", | |
| 3095 (PyObject*)excepthandler_type) < 0) return; | |
| 3096 if(PyDict_SetItemString(d, "arguments", (PyObject*)arguments_type) < 0) | |
| 3097 return; | |
| 3098 if(PyDict_SetItemString(d, "keyword", (PyObject*)keyword_type) < 0) | |
| 3099 return; | |
| 3100 if(PyDict_SetItemString(d, "alias", (PyObject*)alias_type) < 0) return; | |
| 3101 } | |
| 3102 | |
| 35742 | 3103 |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3104 PyObject* PyAST_mod2obj(mod_ty t) |
| 35742 | 3105 { |
|
36660
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3106 init_types(); |
|
3c0b26113df6
Generate code to recursively copy an AST into
Martin v. Löwis <martin@v.loewis.de>
parents:
36174
diff
changeset
|
3107 return ast2obj_mod(t); |
| 35742 | 3108 } |
| 3109 | |
|
35866
9f73dc0953d2
Whoops, checkin consistent versions of *all* files to stop polluting
Neal Norwitz <nnorwitz@gmail.com>
parents:
35862
diff
changeset
|
3110 |
