compile.h 2.9 KB

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