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