2000-07-09 00:20:36 +00:00
|
|
|
#ifndef Py_COMPILE_H
|
|
|
|
#define Py_COMPILE_H
|
2006-02-28 23:09:08 +00:00
|
|
|
|
2011-09-28 23:04:08 +00:00
|
|
|
#ifndef Py_LIMITED_API
|
2006-02-28 23:09:08 +00:00
|
|
|
#include "code.h"
|
|
|
|
|
2000-07-09 00:20:36 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1990-12-20 15:06:42 +00:00
|
|
|
/* Public interface */
|
1991-04-03 19:00:55 +00:00
|
|
|
struct _node; /* Declare the existence of this type */
|
2002-12-11 14:04:59 +00:00
|
|
|
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
2017-05-23 04:36:03 +00: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 | \
|
|
|
|
CO_FUTURE_GENERATOR_STOP)
|
|
|
|
#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
|
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
typedef struct {
|
|
|
|
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
|
|
|
|
} PyCompilerFlags;
|
|
|
|
#endif
|
1993-07-28 09:05:47 +00:00
|
|
|
|
2001-02-27 19:07:02 +00:00
|
|
|
/* Future feature support */
|
|
|
|
|
|
|
|
typedef struct {
|
2005-10-20 19:59:25 +00:00
|
|
|
int ff_features; /* flags set by future statements */
|
|
|
|
int ff_lineno; /* line number of last future statement */
|
2001-02-27 19:07:02 +00:00
|
|
|
} PyFutureFeatures;
|
|
|
|
|
|
|
|
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
2001-07-15 21:08:29 +00:00
|
|
|
#define FUTURE_GENERATORS "generators"
|
2001-08-08 05:00:18 +00:00
|
|
|
#define FUTURE_DIVISION "division"
|
2006-04-21 10:40:58 +00:00
|
|
|
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
|
2006-02-28 19:02:24 +00:00
|
|
|
#define FUTURE_WITH_STATEMENT "with_statement"
|
2008-03-20 23:02:08 +00:00
|
|
|
#define FUTURE_PRINT_FUNCTION "print_function"
|
2008-03-26 22:34:47 +00:00
|
|
|
#define FUTURE_UNICODE_LITERALS "unicode_literals"
|
2009-04-01 05:08:41 +00:00
|
|
|
#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
|
2015-05-09 15:44:30 +00:00
|
|
|
#define FUTURE_GENERATOR_STOP "generator_stop"
|
2001-08-08 05:00:18 +00:00
|
|
|
|
2005-10-20 19:59:25 +00:00
|
|
|
struct _mod; /* Declare the existence of this type */
|
2010-12-04 10:26:46 +00:00
|
|
|
#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
|
2010-12-27 01:49:31 +00:00
|
|
|
PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
|
2010-12-27 02:39:20 +00:00
|
|
|
struct _mod *mod,
|
2010-12-27 01:49:31 +00:00
|
|
|
const char *filename, /* decoded from the filesystem encoding */
|
|
|
|
PyCompilerFlags *flags,
|
|
|
|
int optimize,
|
|
|
|
PyArena *arena);
|
2013-08-26 20:28:21 +00: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 19:59:25 +00:00
|
|
|
|
2011-09-28 23:04:08 +00:00
|
|
|
/* _Py_Mangle is defined in compile.c */
|
|
|
|
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
2005-10-20 19:59:25 +00:00
|
|
|
|
2013-11-23 22:49:22 +00:00
|
|
|
#define PY_INVALID_STACK_EFFECT INT_MAX
|
|
|
|
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
|
|
|
|
|
2017-12-25 10:47:50 +00:00
|
|
|
PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, int optimize);
|
2017-12-14 07:47:20 +00:00
|
|
|
|
1993-07-28 09:05:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2011-09-28 23:04:08 +00:00
|
|
|
|
2010-12-03 20:14:31 +00:00
|
|
|
#endif /* !Py_LIMITED_API */
|
2011-09-28 23:04:08 +00:00
|
|
|
|
|
|
|
/* These definitions must match corresponding definitions in graminit.h.
|
|
|
|
There's code in compile.c that checks that they are the same. */
|
|
|
|
#define Py_single_input 256
|
|
|
|
#define Py_file_input 257
|
|
|
|
#define Py_eval_input 258
|
|
|
|
|
|
|
|
#endif /* !Py_COMPILE_H */
|