Mercurial > cpython-lru_cache-weakref
comparison Python/Python-ast.c @ 40215:1cce0526d9b0
Jiwon Seo's PEP 3102 implementation.
See SF#1549670.
The compiler package has not yet been updated.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 27 Oct 2006 23:31:49 +0000 |
| parents | 7a0ad110e91e |
| children | 54cd47788811 |
comparison
equal
deleted
inserted
replaced
| 40214:d0bd8a8afb01 | 40215:1cce0526d9b0 |
|---|---|
| 331 static PyTypeObject *arguments_type; | 331 static PyTypeObject *arguments_type; |
| 332 static PyObject* ast2obj_arguments(void*); | 332 static PyObject* ast2obj_arguments(void*); |
| 333 static char *arguments_fields[]={ | 333 static char *arguments_fields[]={ |
| 334 "args", | 334 "args", |
| 335 "vararg", | 335 "vararg", |
| 336 "kwonlyargs", | |
| 336 "kwarg", | 337 "kwarg", |
| 337 "defaults", | 338 "defaults", |
| 339 "kw_defaults", | |
| 338 }; | 340 }; |
| 339 static PyTypeObject *keyword_type; | 341 static PyTypeObject *keyword_type; |
| 340 static PyObject* ast2obj_keyword(void*); | 342 static PyObject* ast2obj_keyword(void*); |
| 341 static char *keyword_fields[]={ | 343 static char *keyword_fields[]={ |
| 342 "arg", | 344 "arg", |
| 706 comprehension_fields, 3); | 708 comprehension_fields, 3); |
| 707 if (!comprehension_type) return 0; | 709 if (!comprehension_type) return 0; |
| 708 excepthandler_type = make_type("excepthandler", AST_type, | 710 excepthandler_type = make_type("excepthandler", AST_type, |
| 709 excepthandler_fields, 5); | 711 excepthandler_fields, 5); |
| 710 if (!excepthandler_type) return 0; | 712 if (!excepthandler_type) return 0; |
| 711 arguments_type = make_type("arguments", AST_type, arguments_fields, 4); | 713 arguments_type = make_type("arguments", AST_type, arguments_fields, 6); |
| 712 if (!arguments_type) return 0; | 714 if (!arguments_type) return 0; |
| 713 keyword_type = make_type("keyword", AST_type, keyword_fields, 2); | 715 keyword_type = make_type("keyword", AST_type, keyword_fields, 2); |
| 714 if (!keyword_type) return 0; | 716 if (!keyword_type) return 0; |
| 715 alias_type = make_type("alias", AST_type, alias_fields, 2); | 717 alias_type = make_type("alias", AST_type, alias_fields, 2); |
| 716 if (!alias_type) return 0; | 718 if (!alias_type) return 0; |
| 1826 p->col_offset = col_offset; | 1828 p->col_offset = col_offset; |
| 1827 return p; | 1829 return p; |
| 1828 } | 1830 } |
| 1829 | 1831 |
| 1830 arguments_ty | 1832 arguments_ty |
| 1831 arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * | 1833 arguments(asdl_seq * args, identifier vararg, asdl_seq * kwonlyargs, identifier |
| 1832 defaults, PyArena *arena) | 1834 kwarg, asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) |
| 1833 { | 1835 { |
| 1834 arguments_ty p; | 1836 arguments_ty p; |
| 1835 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); | 1837 p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); |
| 1836 if (!p) { | 1838 if (!p) { |
| 1837 PyErr_NoMemory(); | 1839 PyErr_NoMemory(); |
| 1838 return NULL; | 1840 return NULL; |
| 1839 } | 1841 } |
| 1840 p->args = args; | 1842 p->args = args; |
| 1841 p->vararg = vararg; | 1843 p->vararg = vararg; |
| 1844 p->kwonlyargs = kwonlyargs; | |
| 1842 p->kwarg = kwarg; | 1845 p->kwarg = kwarg; |
| 1843 p->defaults = defaults; | 1846 p->defaults = defaults; |
| 1847 p->kw_defaults = kw_defaults; | |
| 1844 return p; | 1848 return p; |
| 1845 } | 1849 } |
| 1846 | 1850 |
| 1847 keyword_ty | 1851 keyword_ty |
| 1848 keyword(identifier arg, expr_ty value, PyArena *arena) | 1852 keyword(identifier arg, expr_ty value, PyArena *arena) |
| 2905 value = ast2obj_identifier(o->vararg); | 2909 value = ast2obj_identifier(o->vararg); |
| 2906 if (!value) goto failed; | 2910 if (!value) goto failed; |
| 2907 if (PyObject_SetAttrString(result, "vararg", value) == -1) | 2911 if (PyObject_SetAttrString(result, "vararg", value) == -1) |
| 2908 goto failed; | 2912 goto failed; |
| 2909 Py_DECREF(value); | 2913 Py_DECREF(value); |
| 2914 value = ast2obj_list(o->kwonlyargs, ast2obj_expr); | |
| 2915 if (!value) goto failed; | |
| 2916 if (PyObject_SetAttrString(result, "kwonlyargs", value) == -1) | |
| 2917 goto failed; | |
| 2918 Py_DECREF(value); | |
| 2910 value = ast2obj_identifier(o->kwarg); | 2919 value = ast2obj_identifier(o->kwarg); |
| 2911 if (!value) goto failed; | 2920 if (!value) goto failed; |
| 2912 if (PyObject_SetAttrString(result, "kwarg", value) == -1) | 2921 if (PyObject_SetAttrString(result, "kwarg", value) == -1) |
| 2913 goto failed; | 2922 goto failed; |
| 2914 Py_DECREF(value); | 2923 Py_DECREF(value); |
| 2915 value = ast2obj_list(o->defaults, ast2obj_expr); | 2924 value = ast2obj_list(o->defaults, ast2obj_expr); |
| 2916 if (!value) goto failed; | 2925 if (!value) goto failed; |
| 2917 if (PyObject_SetAttrString(result, "defaults", value) == -1) | 2926 if (PyObject_SetAttrString(result, "defaults", value) == -1) |
| 2927 goto failed; | |
| 2928 Py_DECREF(value); | |
| 2929 value = ast2obj_list(o->kw_defaults, ast2obj_expr); | |
| 2930 if (!value) goto failed; | |
| 2931 if (PyObject_SetAttrString(result, "kw_defaults", value) == -1) | |
| 2918 goto failed; | 2932 goto failed; |
| 2919 Py_DECREF(value); | 2933 Py_DECREF(value); |
| 2920 return result; | 2934 return result; |
| 2921 failed: | 2935 failed: |
| 2922 Py_XDECREF(value); | 2936 Py_XDECREF(value); |
| 2992 if (!m) return; | 3006 if (!m) return; |
| 2993 d = PyModule_GetDict(m); | 3007 d = PyModule_GetDict(m); |
| 2994 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; | 3008 if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; |
| 2995 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) | 3009 if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) |
| 2996 return; | 3010 return; |
| 2997 if (PyModule_AddStringConstant(m, "__version__", "51631") < 0) | 3011 if (PyModule_AddStringConstant(m, "__version__", "51773") < 0) |
| 2998 return; | 3012 return; |
| 2999 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; | 3013 if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; |
| 3000 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) | 3014 if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) |
| 3001 return; | 3015 return; |
| 3002 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) | 3016 if (PyDict_SetItemString(d, "Interactive", (PyObject*)Interactive_type) |
