Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 35742:1c4d192f1568 legacy-trunk
Merge ast-branch to head
This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.
The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Thu, 20 Oct 2005 19:59:25 +0000 |
| parents | f0951fdaed37 |
| children | eb15cdd4a2f1 |
line wrap: on
line diff
--- a/Python/import.c Thu Oct 20 19:06:35 2005 +0000 +++ b/Python/import.c Thu Oct 20 19:59:25 2005 +0000 @@ -3,10 +3,11 @@ #include "Python.h" -#include "node.h" -#include "token.h" +#include "Python-ast.h" +#include "pythonrun.h" #include "errcode.h" #include "marshal.h" +#include "code.h" #include "compile.h" #include "eval.h" #include "osdefs.h" @@ -766,17 +767,17 @@ /* Parse a source file and return the corresponding code object */ static PyCodeObject * -parse_source_module(char *pathname, FILE *fp) +parse_source_module(const char *pathname, FILE *fp) { - PyCodeObject *co; - node *n; + PyCodeObject *co = NULL; + mod_ty mod; - n = PyParser_SimpleParseFile(fp, pathname, Py_file_input); - if (n == NULL) - return NULL; - co = PyNode_Compile(n, pathname); - PyNode_Free(n); - + mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, + NULL); + if (mod) { + co = PyAST_Compile(mod, pathname, NULL); + free_mod(mod); + } return co; }
