mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-43244: Add pycore_compile.h header file (GH-25000)
Remove the compiler functions using "struct _mod" type, because the public AST C API was removed: * PyAST_Compile() * PyAST_CompileEx() * PyAST_CompileObject() * PyFuture_FromAST() * PyFuture_FromASTObject() These functions were undocumented and excluded from the limited C API. Rename functions: * PyAST_CompileObject() => _PyAST_Compile() * PyFuture_FromASTObject() => _PyFuture_FromAST() Moreover, _PyFuture_FromAST() is no longer exported (replace PyAPI_FUNC() with extern). _PyAST_Compile() remains exported for test_peg_generator. Remove also compatibility functions: * PyAST_Compile() * PyAST_CompileEx() * PyFuture_FromAST()
This commit is contained in:
parent
f0a6fde882
commit
a81fca6ec8
15 changed files with 87 additions and 84 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue