annotate Python/Python-ast.c @ 40937:6aa1be5dd009

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