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