File indexing completed on 2025-11-19 09:50:45
0001 #ifndef Py_INTERNAL_COMPILE_H
0002 #define Py_INTERNAL_COMPILE_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006
0007 #ifndef Py_BUILD_CORE
0008 # error "this header requires Py_BUILD_CORE define"
0009 #endif
0010
0011 #include "pycore_symtable.h" // _Py_SourceLocation
0012 #include "pycore_instruction_sequence.h"
0013
0014 struct _arena;
0015 struct _mod;
0016
0017
0018 PyAPI_FUNC(PyCodeObject*) _PyAST_Compile(
0019 struct _mod *mod,
0020 PyObject *filename,
0021 PyCompilerFlags *flags,
0022 int optimize,
0023 struct _arena *arena);
0024
0025
0026 extern int _PyCompile_AstOptimize(
0027 struct _mod *mod,
0028 PyObject *filename,
0029 PyCompilerFlags *flags,
0030 int optimize,
0031 struct _arena *arena);
0032
0033 struct _Py_SourceLocation;
0034
0035 extern int _PyAST_Optimize(
0036 struct _mod *,
0037 struct _arena *arena,
0038 int optimize,
0039 int ff_features);
0040
0041
0042 typedef struct {
0043 PyObject *u_name;
0044 PyObject *u_qualname;
0045
0046
0047
0048
0049
0050 PyObject *u_consts;
0051 PyObject *u_names;
0052 PyObject *u_varnames;
0053 PyObject *u_cellvars;
0054 PyObject *u_freevars;
0055 PyObject *u_fasthidden;
0056
0057
0058
0059 Py_ssize_t u_argcount;
0060 Py_ssize_t u_posonlyargcount;
0061 Py_ssize_t u_kwonlyargcount;
0062
0063 int u_firstlineno;
0064 } _PyCompile_CodeUnitMetadata;
0065
0066
0067
0068 int _PyCompile_EnsureArrayLargeEnough(
0069 int idx,
0070 void **array,
0071 int *alloc,
0072 int default_alloc,
0073 size_t item_size);
0074
0075 int _PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj);
0076
0077
0078
0079 PyAPI_FUNC(int) _PyCompile_OpcodeIsValid(int opcode);
0080 PyAPI_FUNC(int) _PyCompile_OpcodeHasArg(int opcode);
0081 PyAPI_FUNC(int) _PyCompile_OpcodeHasConst(int opcode);
0082 PyAPI_FUNC(int) _PyCompile_OpcodeHasName(int opcode);
0083 PyAPI_FUNC(int) _PyCompile_OpcodeHasJump(int opcode);
0084 PyAPI_FUNC(int) _PyCompile_OpcodeHasFree(int opcode);
0085 PyAPI_FUNC(int) _PyCompile_OpcodeHasLocal(int opcode);
0086 PyAPI_FUNC(int) _PyCompile_OpcodeHasExc(int opcode);
0087
0088 PyAPI_FUNC(PyObject*) _PyCompile_GetUnaryIntrinsicName(int index);
0089 PyAPI_FUNC(PyObject*) _PyCompile_GetBinaryIntrinsicName(int index);
0090
0091
0092
0093
0094 PyAPI_FUNC(PyObject*) _PyCompile_CleanDoc(PyObject *doc);
0095
0096
0097 PyAPI_FUNC(PyObject*) _PyCompile_CodeGen(
0098 PyObject *ast,
0099 PyObject *filename,
0100 PyCompilerFlags *flags,
0101 int optimize,
0102 int compile_mode);
0103
0104
0105 PyAPI_FUNC(PyObject*) _PyCompile_OptimizeCfg(
0106 PyObject *instructions,
0107 PyObject *consts,
0108 int nlocals);
0109
0110
0111 PyAPI_FUNC(PyCodeObject*)
0112 _PyCompile_Assemble(_PyCompile_CodeUnitMetadata *umd, PyObject *filename,
0113 PyObject *instructions);
0114
0115 #ifdef __cplusplus
0116 }
0117 #endif
0118 #endif