Debian Codegraph @

src/cpython/compile.rs

raw symbols SCIP
1 #[cfg(not(any(PyPy, Py_3_10)))]
2 use crate::object::PyObject;
3 #[cfg(not(any(PyPy, Py_3_10)))]
4 use crate::pyarena::*;
5 #[cfg(not(any(PyPy, Py_3_10)))]
6 use crate::pythonrun::*;
7 #[cfg(not(any(PyPy, Py_3_10)))]
8 use crate::PyCodeObject;
9 use crate::INT_MAX;
10 #[cfg(not(any(PyPy, Py_3_10)))]
11 use std::ffi::c_char;
12 use std::ffi::c_int;
13
14 // skipped PyCF_MASK
15 // skipped PyCF_MASK_OBSOLETE
16 // skipped PyCF_SOURCE_IS_UTF8
17 // skipped PyCF_DONT_IMPLY_DEDENT
18 // skipped PyCF_ONLY_AST
19 // skipped PyCF_IGNORE_COOKIE
20 // skipped PyCF_TYPE_COMMENTS
21 // skipped PyCF_ALLOW_TOP_LEVEL_AWAIT
22 // skipped PyCF_OPTIMIZED_AST
23 // skipped PyCF_COMPILE_MASK
24
25 #[repr(C)]
26 #[derive(Copy, Clone)]
27 pub struct PyCompilerFlags {
28 pub cf_flags: c_int,
29 #[cfg(Py_3_8)]
30 pub cf_feature_version: c_int,
31 }
32
33 // skipped _PyCompilerFlags_INIT
34
35 // NB this type technically existed in the header until 3.13, when it was
36 // moved to the internal CPython headers.
37 //
38 // We choose not to expose it in the public API past 3.10, as it is
39 // not used in the public API past that point.
40 #[cfg(not(any(PyPy, GraalPy, Py_3_10)))]
41 #[repr(C)]
42 #[derive(Copy, Clone)]
43 pub struct PyFutureFeatures {
44 pub ff_features: c_int,
45 pub ff_lineno: c_int,
46 }
47
48 // FIXME: these constants should probably be &CStr, if they are used at all
49
50 pub const FUTURE_NESTED_SCOPES: &str = "nested_scopes";
51 pub const FUTURE_GENERATORS: &str = "generators";
52 pub const FUTURE_DIVISION: &str = "division";
53 pub const FUTURE_ABSOLUTE_IMPORT: &str = "absolute_import";
54 pub const FUTURE_WITH_STATEMENT: &str = "with_statement";
55 pub const FUTURE_PRINT_FUNCTION: &str = "print_function";
56 pub const FUTURE_UNICODE_LITERALS: &str = "unicode_literals";
57 pub const FUTURE_BARRY_AS_BDFL: &str = "barry_as_FLUFL";
58 pub const FUTURE_GENERATOR_STOP: &str = "generator_stop";
59 pub const FUTURE_ANNOTATIONS: &str = "annotations";
60
61 #[cfg(not(any(PyPy, GraalPy, Py_3_10)))]
62 extern "C" {
63 pub fn PyNode_Compile(arg1: *mut _node, arg2: *const c_char) -> *mut PyCodeObject;
64
65 pub fn PyAST_CompileEx(
66 _mod: *mut _mod,
67 filename: *const c_char,
68 flags: *mut PyCompilerFlags,
69 optimize: c_int,
70 arena: *mut PyArena,
71 ) -> *mut PyCodeObject;
72
73 pub fn PyAST_CompileObject(
74 _mod: *mut _mod,
75 filename: *mut PyObject,
76 flags: *mut PyCompilerFlags,
77 optimize: c_int,
78 arena: *mut PyArena,
79 ) -> *mut PyCodeObject;
80
81 pub fn PyFuture_FromAST(_mod: *mut _mod, filename: *const c_char) -> *mut PyFutureFeatures;
82
83 pub fn PyFuture_FromASTObject(
84 _mod: *mut _mod,
85 filename: *mut PyObject,
86 ) -> *mut PyFutureFeatures;
87 }
88
89 pub const PY_INVALID_STACK_EFFECT: c_int = INT_MAX;
90
91 extern "C" {
92
93 pub fn PyCompile_OpcodeStackEffect(opcode: c_int, oparg: c_int) -> c_int;
94
95 #[cfg(Py_3_8)]
96 pub fn PyCompile_OpcodeStackEffectWithJump(opcode: c_int, oparg: c_int, jump: c_int) -> c_int;
97 }