jpayne@69
|
1 #ifndef Py_COMPILE_H
|
jpayne@69
|
2 #define Py_COMPILE_H
|
jpayne@69
|
3
|
jpayne@69
|
4 #ifndef Py_LIMITED_API
|
jpayne@69
|
5 #include "code.h"
|
jpayne@69
|
6
|
jpayne@69
|
7 #ifdef __cplusplus
|
jpayne@69
|
8 extern "C" {
|
jpayne@69
|
9 #endif
|
jpayne@69
|
10
|
jpayne@69
|
11 /* Public interface */
|
jpayne@69
|
12 struct _node; /* Declare the existence of this type */
|
jpayne@69
|
13 PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
jpayne@69
|
14 /* XXX (ncoghlan): Unprefixed type name in a public API! */
|
jpayne@69
|
15
|
jpayne@69
|
16 #define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
|
jpayne@69
|
17 CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
|
jpayne@69
|
18 CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
|
jpayne@69
|
19 CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
|
jpayne@69
|
20 #define PyCF_MASK_OBSOLETE (CO_NESTED)
|
jpayne@69
|
21 #define PyCF_SOURCE_IS_UTF8 0x0100
|
jpayne@69
|
22 #define PyCF_DONT_IMPLY_DEDENT 0x0200
|
jpayne@69
|
23 #define PyCF_ONLY_AST 0x0400
|
jpayne@69
|
24 #define PyCF_IGNORE_COOKIE 0x0800
|
jpayne@69
|
25 #define PyCF_TYPE_COMMENTS 0x1000
|
jpayne@69
|
26 #define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
|
jpayne@69
|
27
|
jpayne@69
|
28 #ifndef Py_LIMITED_API
|
jpayne@69
|
29 typedef struct {
|
jpayne@69
|
30 int cf_flags; /* bitmask of CO_xxx flags relevant to future */
|
jpayne@69
|
31 int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */
|
jpayne@69
|
32 } PyCompilerFlags;
|
jpayne@69
|
33
|
jpayne@69
|
34 #define _PyCompilerFlags_INIT \
|
jpayne@69
|
35 (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
|
jpayne@69
|
36 #endif
|
jpayne@69
|
37
|
jpayne@69
|
38 /* Future feature support */
|
jpayne@69
|
39
|
jpayne@69
|
40 typedef struct {
|
jpayne@69
|
41 int ff_features; /* flags set by future statements */
|
jpayne@69
|
42 int ff_lineno; /* line number of last future statement */
|
jpayne@69
|
43 } PyFutureFeatures;
|
jpayne@69
|
44
|
jpayne@69
|
45 #define FUTURE_NESTED_SCOPES "nested_scopes"
|
jpayne@69
|
46 #define FUTURE_GENERATORS "generators"
|
jpayne@69
|
47 #define FUTURE_DIVISION "division"
|
jpayne@69
|
48 #define FUTURE_ABSOLUTE_IMPORT "absolute_import"
|
jpayne@69
|
49 #define FUTURE_WITH_STATEMENT "with_statement"
|
jpayne@69
|
50 #define FUTURE_PRINT_FUNCTION "print_function"
|
jpayne@69
|
51 #define FUTURE_UNICODE_LITERALS "unicode_literals"
|
jpayne@69
|
52 #define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
|
jpayne@69
|
53 #define FUTURE_GENERATOR_STOP "generator_stop"
|
jpayne@69
|
54 #define FUTURE_ANNOTATIONS "annotations"
|
jpayne@69
|
55
|
jpayne@69
|
56 struct _mod; /* Declare the existence of this type */
|
jpayne@69
|
57 #define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
|
jpayne@69
|
58 PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
|
jpayne@69
|
59 struct _mod *mod,
|
jpayne@69
|
60 const char *filename, /* decoded from the filesystem encoding */
|
jpayne@69
|
61 PyCompilerFlags *flags,
|
jpayne@69
|
62 int optimize,
|
jpayne@69
|
63 PyArena *arena);
|
jpayne@69
|
64 PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject(
|
jpayne@69
|
65 struct _mod *mod,
|
jpayne@69
|
66 PyObject *filename,
|
jpayne@69
|
67 PyCompilerFlags *flags,
|
jpayne@69
|
68 int optimize,
|
jpayne@69
|
69 PyArena *arena);
|
jpayne@69
|
70 PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(
|
jpayne@69
|
71 struct _mod * mod,
|
jpayne@69
|
72 const char *filename /* decoded from the filesystem encoding */
|
jpayne@69
|
73 );
|
jpayne@69
|
74 PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject(
|
jpayne@69
|
75 struct _mod * mod,
|
jpayne@69
|
76 PyObject *filename
|
jpayne@69
|
77 );
|
jpayne@69
|
78
|
jpayne@69
|
79 /* _Py_Mangle is defined in compile.c */
|
jpayne@69
|
80 PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
jpayne@69
|
81
|
jpayne@69
|
82 #define PY_INVALID_STACK_EFFECT INT_MAX
|
jpayne@69
|
83 PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
|
jpayne@69
|
84 PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump);
|
jpayne@69
|
85
|
jpayne@69
|
86 PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, int optimize);
|
jpayne@69
|
87
|
jpayne@69
|
88 #ifdef __cplusplus
|
jpayne@69
|
89 }
|
jpayne@69
|
90 #endif
|
jpayne@69
|
91
|
jpayne@69
|
92 #endif /* !Py_LIMITED_API */
|
jpayne@69
|
93
|
jpayne@69
|
94 /* These definitions must match corresponding definitions in graminit.h. */
|
jpayne@69
|
95 #define Py_single_input 256
|
jpayne@69
|
96 #define Py_file_input 257
|
jpayne@69
|
97 #define Py_eval_input 258
|
jpayne@69
|
98 #define Py_func_type_input 345
|
jpayne@69
|
99
|
jpayne@69
|
100 #endif /* !Py_COMPILE_H */
|