2000-07-08 21:20:36 -03:00
|
|
|
#ifndef Py_COMPILE_H
|
|
|
|
#define Py_COMPILE_H
|
2006-02-28 19:09:08 -04:00
|
|
|
|
2011-09-28 20:04:08 -03:00
|
|
|
#ifndef Py_LIMITED_API
|
2006-02-28 19:09:08 -04:00
|
|
|
#include "code.h"
|
|
|
|
|
2000-07-08 21:20:36 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1990-12-20 11:06:42 -04:00
|
|
|
/* Public interface */
|
1991-04-03 15:00:55 -04:00
|
|
|
struct _node; /* Declare the existence of this type */
|
2002-12-11 10:04:59 -04:00
|
|
|
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
2017-05-23 01:36:03 -03:00
|
|
|
/* XXX (ncoghlan): Unprefixed type name in a public API! */
|
|
|
|
|
|
|
|
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
|
|
|
|
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
|
|
|
|
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
|
2018-01-26 12:20:18 -04:00
|
|
|
CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
|
2017-05-23 01:36:03 -03:00
|
|
|
#define PyCF_MASK_OBSOLETE (CO_NESTED)
|
|
|
|
#define PyCF_SOURCE_IS_UTF8 0x0100
|
|
|
|
#define PyCF_DONT_IMPLY_DEDENT 0x0200
|
|
|
|
#define PyCF_ONLY_AST 0x0400
|
|
|
|
#define PyCF_IGNORE_COOKIE 0x0800
|
2019-01-31 07:40:27 -04:00
|
|
|
#define PyCF_TYPE_COMMENTS 0x1000
|
2019-05-21 17:12:03 -03:00
|
|
|
#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
|
2017-05-23 01:36:03 -03:00
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
typedef struct {
|
|
|
|
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
|
2019-03-07 16:38:08 -04:00
|
|
|
int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */
|
2017-05-23 01:36:03 -03:00
|
|
|
} PyCompilerFlags;
|
2019-06-12 21:36:03 -03:00
|
|
|
|
|
|
|
#define _PyCompilerFlags_INIT \
|
|
|
|
(PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
|
2017-05-23 01:36:03 -03:00
|
|
|
#endif
|
1993-07-28 06:05:47 -03:00
|
|
|
|
2001-02-27 15:07:02 -04:00
|
|
|
/* Future feature support */
|
|
|
|
|
|
|
|
typedef struct {
|
2005-10-20 16:59:25 -03:00
|
|
|
int ff_features; /* flags set by future statements */
|
|
|
|
int ff_lineno; /* line number of last future statement */
|
2001-02-27 15:07:02 -04:00
|
|
|
} PyFutureFeatures;
|
|
|
|
|
|
|
|
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
2001-07-15 18:08:29 -03:00
|
|
|
#define FUTURE_GENERATORS "generators"
|
2001-08-08 02:00:18 -03:00
|
|
|
#define FUTURE_DIVISION "division"
|
2006-04-21 07:40:58 -03:00
|
|
|
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
|
2006-02-28 15:02:24 -04:00
|
|
|
#define FUTURE_WITH_STATEMENT "with_statement"
|
2008-03-20 20:02:08 -03:00
|
|
|
#define FUTURE_PRINT_FUNCTION "print_function"
|
2008-03-26 19:34:47 -03:00
|
|
|
#define FUTURE_UNICODE_LITERALS "unicode_literals"
|
2009-04-01 02:08:41 -03:00
|
|
|
#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
|
2015-05-09 12:44:30 -03:00
|
|
|
#define FUTURE_GENERATOR_STOP "generator_stop"
|
2018-01-26 12:20:18 -04:00
|
|
|
#define FUTURE_ANNOTATIONS "annotations"
|
2001-08-08 02:00:18 -03:00
|
|
|
|
2005-10-20 16:59:25 -03:00
|
|
|
struct _mod; /* Declare the existence of this type */
|
2010-12-04 06:26:46 -04:00
|
|
|
#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
|
2010-12-26 21:49:31 -04:00
|
|
|
PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
|
2010-12-26 22:39:20 -04:00
|
|
|
struct _mod *mod,
|
2010-12-26 21:49:31 -04:00
|
|
|
const char *filename, /* decoded from the filesystem encoding */
|
|
|
|
PyCompilerFlags *flags,
|
|
|
|
int optimize,
|
|
|
|
PyArena *arena);
|
2013-08-26 17:28:21 -03:00
|
|
|
PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject(
|
|
|
|
struct _mod *mod,
|
|
|
|
PyObject *filename,
|
|
|
|
PyCompilerFlags *flags,
|
|
|
|
int optimize,
|
|
|
|
PyArena *arena);
|
|
|
|
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(
|
|
|
|
struct _mod * mod,
|
|
|
|
const char *filename /* decoded from the filesystem encoding */
|
|
|
|
);
|
|
|
|
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject(
|
|
|
|
struct _mod * mod,
|
|
|
|
PyObject *filename
|
|
|
|
);
|
2005-10-20 16:59:25 -03:00
|
|
|
|
2011-09-28 20:04:08 -03:00
|
|
|
/* _Py_Mangle is defined in compile.c */
|
|
|
|
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
2005-10-20 16:59:25 -03:00
|
|
|
|
2013-11-23 18:49:22 -04:00
|
|
|
#define PY_INVALID_STACK_EFFECT INT_MAX
|
|
|
|
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
|
2018-09-18 03:54:26 -03:00
|
|
|
PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump);
|
2013-11-23 18:49:22 -04:00
|
|
|
|
2017-12-25 06:47:50 -04:00
|
|
|
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, int optimize);
|
2017-12-14 03:47:20 -04:00
|
|
|
|
1993-07-28 06:05:47 -03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2011-09-28 20:04:08 -03:00
|
|
|
|
2010-12-03 16:14:31 -04:00
|
|
|
#endif /* !Py_LIMITED_API */
|
2011-09-28 20:04:08 -03:00
|
|
|
|
2019-01-31 07:40:27 -04:00
|
|
|
/* These definitions must match corresponding definitions in graminit.h. */
|
2011-09-28 20:04:08 -03:00
|
|
|
#define Py_single_input 256
|
|
|
|
#define Py_file_input 257
|
|
|
|
#define Py_eval_input 258
|
2019-01-31 07:40:27 -04:00
|
|
|
#define Py_func_type_input 345
|
2011-09-28 20:04:08 -03:00
|
|
|
|
|
|
|
#endif /* !Py_COMPILE_H */
|