summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/ast_opt.c1
-rw-r--r--Python/bltinmodule.c5
-rw-r--r--Python/compile.c33
-rw-r--r--Python/future.c17
-rw-r--r--Python/pythonrun.c5
-rw-r--r--Python/symtable.c3
6 files changed, 15 insertions, 49 deletions
diff --git a/Python/ast_opt.c b/Python/ast_opt.c
index c76b428..64fa067 100644
--- a/Python/ast_opt.c
+++ b/Python/ast_opt.c
@@ -1,6 +1,7 @@
/* AST Optimizer */
#include "Python.h"
#include "pycore_ast.h" // _PyAST_GetDocString()
+#include "pycore_compile.h" // _PyASTOptimizeState
static int
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index fd9b97f..afe0f82 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -4,6 +4,7 @@
#include <ctype.h>
#include "pycore_ast.h" // _PyAST_Validate()
#undef Yield /* undefine macro conflicting with <winbase.h> */
+#include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_object.h" // _Py_AddToAllObjects()
#include "pycore_pyerrors.h" // _PyErr_NoMemory()
#include "pycore_pystate.h" // _PyThreadState_GET()
@@ -839,8 +840,8 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
PyArena_Free(arena);
goto error;
}
- result = (PyObject*)PyAST_CompileObject(mod, filename,
- &cf, optimize, arena);
+ result = (PyObject*)_PyAST_Compile(mod, filename,
+ &cf, optimize, arena);
PyArena_Free(arena);
}
goto finally;
diff --git a/Python/compile.c b/Python/compile.c
index 27274ec..bed2a1c 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1,7 +1,7 @@
/*
* This file compiles an abstract syntax tree (AST) into Python bytecode.
*
- * The primary entry point is PyAST_Compile(), which returns a
+ * The primary entry point is _PyAST_Compile(), which returns a
* PyCodeObject. The compiler makes several passes to build the code
* object:
* 1. Checks for future statements. See future.c
@@ -23,6 +23,7 @@
#include "Python.h"
#include "pycore_ast.h" // _PyAST_GetDocString()
+#include "pycore_compile.h" // _PyFuture_FromAST()
#include "pycore_pymem.h" // _PyMem_IsPtrFreed()
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_symtable.h" // PySTEntryObject
@@ -350,8 +351,8 @@ compiler_init(struct compiler *c)
}
PyCodeObject *
-PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
- int optimize, PyArena *arena)
+_PyAST_Compile(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
+ int optimize, PyArena *arena)
{
struct compiler c;
PyCodeObject *co = NULL;
@@ -373,7 +374,7 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
Py_INCREF(filename);
c.c_filename = filename;
c.c_arena = arena;
- c.c_future = PyFuture_FromASTObject(mod, filename);
+ c.c_future = _PyFuture_FromAST(mod, filename);
if (c.c_future == NULL)
goto finally;
if (!flags) {
@@ -409,21 +410,6 @@ PyAST_CompileObject(mod_ty mod, PyObject *filename, PyCompilerFlags *flags,
return co;
}
-PyCodeObject *
-PyAST_CompileEx(mod_ty mod, const char *filename_str, PyCompilerFlags *flags,
- int optimize, PyArena *arena)
-{
- PyObject *filename;
- PyCodeObject *co;
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL)
- return NULL;
- co = PyAST_CompileObject(mod, filename, flags, optimize, arena);
- Py_DECREF(filename);
- return co;
-
-}
-
static void
compiler_free(struct compiler *c)
{
@@ -6758,15 +6744,6 @@ assemble(struct compiler *c, int addNone)
return co;
}
-#undef PyAST_Compile
-PyCodeObject *
-PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags,
- PyArena *arena)
-{
- return PyAST_CompileEx(mod, filename, flags, -1, arena);
-}
-
-
/* Replace LOAD_CONST c1, LOAD_CONST c2 ... LOAD_CONST cn, BUILD_TUPLE n
with LOAD_CONST (c1, c2, ... cn).
The consts table must still be in list form so that the
diff --git a/Python/future.c b/Python/future.c
index 37e7a22..05ade8e 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -116,7 +116,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, PyObject *filename)
PyFutureFeatures *
-PyFuture_FromASTObject(mod_ty mod, PyObject *filename)
+_PyFuture_FromAST(mod_ty mod, PyObject *filename)
{
PyFutureFeatures *ff;
@@ -134,18 +134,3 @@ PyFuture_FromASTObject(mod_ty mod, PyObject *filename)
}
return ff;
}
-
-
-PyFutureFeatures *
-PyFuture_FromAST(mod_ty mod, const char *filename_str)
-{
- PyFutureFeatures *ff;
- PyObject *filename;
-
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL)
- return NULL;
- ff = PyFuture_FromASTObject(mod, filename);
- Py_DECREF(filename);
- return ff;
-}
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 02fd8b0..e16835b 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -13,6 +13,7 @@
#include "pycore_ast.h" // PyAST_mod2obj
#undef Yield /* undefine macro conflicting with <winbase.h> */
+#include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_interp.h" // PyInterpreterState.importlib
#include "pycore_object.h" // _PyDebug_PrintTotalRefs()
#include "pycore_pyerrors.h" // _PyErr_Fetch
@@ -1224,7 +1225,7 @@ run_mod(mod_ty mod, PyObject *filename, PyObject *globals, PyObject *locals,
PyCompilerFlags *flags, PyArena *arena)
{
PyThreadState *tstate = _PyThreadState_GET();
- PyCodeObject *co = PyAST_CompileObject(mod, filename, flags, -1, arena);
+ PyCodeObject *co = _PyAST_Compile(mod, filename, flags, -1, arena);
if (co == NULL)
return NULL;
@@ -1301,7 +1302,7 @@ Py_CompileStringObject(const char *str, PyObject *filename, int start,
PyArena_Free(arena);
return result;
}
- co = PyAST_CompileObject(mod, filename, flags, optimize, arena);
+ co = _PyAST_Compile(mod, filename, flags, optimize, arena);
PyArena_Free(arena);
return (PyObject *)co;
}
diff --git a/Python/symtable.c b/Python/symtable.c
index 7887440..a149e28 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -1,8 +1,9 @@
#include "Python.h"
#include "pycore_ast.h" // identifier, stmt_ty
+#undef Yield /* undefine macro conflicting with <winbase.h> */
+#include "pycore_compile.h" // _Py_Mangle()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_symtable.h" // PySTEntryObject
-#undef Yield /* undefine macro conflicting with <winbase.h> */
#include "structmember.h" // PyMemberDef
/* error strings used for warnings */