| |
|
|
| #ifndef Py_LIMITED_API |
| #ifndef Py_CODE_H |
| #define Py_CODE_H |
|
|
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
|
|
| |
| #define _PY_MONITORING_LOCAL_EVENTS 10 |
| |
| #define _PY_MONITORING_UNGROUPED_EVENTS 15 |
| |
| #define _PY_MONITORING_EVENTS 17 |
|
|
| |
| typedef struct _Py_LocalMonitors { |
| uint8_t tools[_PY_MONITORING_LOCAL_EVENTS]; |
| } _Py_LocalMonitors; |
|
|
| typedef struct _Py_GlobalMonitors { |
| uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS]; |
| } _Py_GlobalMonitors; |
|
|
|
|
| typedef struct { |
| PyObject *_co_code; |
| PyObject *_co_varnames; |
| PyObject *_co_cellvars; |
| PyObject *_co_freevars; |
| } _PyCoCached; |
|
|
| |
| |
| |
| |
| typedef struct { |
| uint8_t bytes_per_entry; |
| uint8_t data[1]; |
| } _PyCoLineInstrumentationData; |
|
|
|
|
| typedef struct { |
| int size; |
| int capacity; |
| struct _PyExecutorObject *executors[1]; |
| } _PyExecutorArray; |
|
|
| |
| |
| |
| typedef struct { |
| |
| _Py_LocalMonitors local_monitors; |
| |
| _Py_LocalMonitors active_monitors; |
| |
| uint8_t *tools; |
| |
| _PyCoLineInstrumentationData *lines; |
| |
| uint8_t *line_tools; |
| |
| |
| uint8_t *per_instruction_opcodes; |
| |
| uint8_t *per_instruction_tools; |
| } _PyCoMonitoringData; |
|
|
| |
| |
| #define _PyCode_DEF(SIZE) { \ |
| PyObject_VAR_HEAD \ |
| \ |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| \ |
| \ |
| \ |
| \ |
| \ |
| PyObject *co_consts; \ |
| PyObject *co_names; \ |
| PyObject *co_exceptiontable; |
| \ |
| int co_flags; \ |
| \ |
| \ |
| int co_argcount; \ |
| int co_posonlyargcount; \ |
| int co_kwonlyargcount; \ |
| int co_stacksize; \ |
| int co_firstlineno; \ |
| \ |
| |
| \ |
| int co_nlocalsplus; \ |
| int co_framesize; \ |
| int co_nlocals; \ |
| int co_ncellvars; \ |
| int co_nfreevars; \ |
| uint32_t co_version; \ |
| \ |
| PyObject *co_localsplusnames; \ |
| PyObject *co_localspluskinds; |
| \ |
| PyObject *co_filename; \ |
| PyObject *co_name; \ |
| PyObject *co_qualname; \ |
| PyObject *co_linetable; \ |
| PyObject *co_weakreflist; \ |
| _PyExecutorArray *co_executors; \ |
| _PyCoCached *_co_cached; \ |
| uintptr_t _co_instrumentation_version; \ |
| _PyCoMonitoringData *_co_monitoring; \ |
| int _co_firsttraceable; \ |
| |
| |
| \ |
| void *co_extra; \ |
| char co_code_adaptive[(SIZE)]; \ |
| } |
|
|
| |
| struct PyCodeObject _PyCode_DEF(1); |
|
|
| |
| #define CO_OPTIMIZED 0x0001 |
| #define CO_NEWLOCALS 0x0002 |
| #define CO_VARARGS 0x0004 |
| #define CO_VARKEYWORDS 0x0008 |
| #define CO_NESTED 0x0010 |
| #define CO_GENERATOR 0x0020 |
|
|
| |
| |
| #define CO_COROUTINE 0x0080 |
| #define CO_ITERABLE_COROUTINE 0x0100 |
| #define CO_ASYNC_GENERATOR 0x0200 |
|
|
| |
| |
| |
| |
| #define CO_FUTURE_DIVISION 0x20000 |
| #define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 |
| #define CO_FUTURE_WITH_STATEMENT 0x80000 |
| #define CO_FUTURE_PRINT_FUNCTION 0x100000 |
| #define CO_FUTURE_UNICODE_LITERALS 0x200000 |
|
|
| #define CO_FUTURE_BARRY_AS_BDFL 0x400000 |
| #define CO_FUTURE_GENERATOR_STOP 0x800000 |
| #define CO_FUTURE_ANNOTATIONS 0x1000000 |
|
|
| #define CO_NO_MONITORING_EVENTS 0x2000000 |
|
|
| |
| |
| |
| #define PY_PARSER_REQUIRES_FUTURE_KEYWORD |
|
|
| #define CO_MAXBLOCKS 21 |
|
|
| PyAPI_DATA(PyTypeObject) PyCode_Type; |
|
|
| #define PyCode_Check(op) Py_IS_TYPE((op), &PyCode_Type) |
|
|
| static inline Py_ssize_t PyCode_GetNumFree(PyCodeObject *op) { |
| assert(PyCode_Check(op)); |
| return op->co_nfreevars; |
| } |
|
|
| static inline int PyUnstable_Code_GetFirstFree(PyCodeObject *op) { |
| assert(PyCode_Check(op)); |
| return op->co_nlocalsplus - op->co_nfreevars; |
| } |
|
|
| Py_DEPRECATED(3.13) static inline int PyCode_GetFirstFree(PyCodeObject *op) { |
| return PyUnstable_Code_GetFirstFree(op); |
| } |
|
|
| |
| PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_New( |
| int, int, int, int, int, PyObject *, PyObject *, |
| PyObject *, PyObject *, PyObject *, PyObject *, |
| PyObject *, PyObject *, PyObject *, int, PyObject *, |
| PyObject *); |
|
|
| PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_NewWithPosOnlyArgs( |
| int, int, int, int, int, int, PyObject *, PyObject *, |
| PyObject *, PyObject *, PyObject *, PyObject *, |
| PyObject *, PyObject *, PyObject *, int, PyObject *, |
| PyObject *); |
| |
| |
| _Py_DEPRECATED_EXTERNALLY(3.12) static inline PyCodeObject * |
| PyCode_New( |
| int a, int b, int c, int d, int e, PyObject *f, PyObject *g, |
| PyObject *h, PyObject *i, PyObject *j, PyObject *k, |
| PyObject *l, PyObject *m, PyObject *n, int o, PyObject *p, |
| PyObject *q) |
| { |
| return PyUnstable_Code_New( |
| a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q); |
| } |
| _Py_DEPRECATED_EXTERNALLY(3.12) static inline PyCodeObject * |
| PyCode_NewWithPosOnlyArgs( |
| int a, int poac, int b, int c, int d, int e, PyObject *f, PyObject *g, |
| PyObject *h, PyObject *i, PyObject *j, PyObject *k, |
| PyObject *l, PyObject *m, PyObject *n, int o, PyObject *p, |
| PyObject *q) |
| { |
| return PyUnstable_Code_NewWithPosOnlyArgs( |
| a, poac, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q); |
| } |
|
|
| |
| PyAPI_FUNC(PyCodeObject *) |
| PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); |
|
|
| |
| |
| |
| PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); |
|
|
| PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *); |
|
|
| #define PY_FOREACH_CODE_EVENT(V) \ |
| V(CREATE) \ |
| V(DESTROY) |
|
|
| typedef enum { |
| #define PY_DEF_EVENT(op) PY_CODE_EVENT_##op, |
| PY_FOREACH_CODE_EVENT(PY_DEF_EVENT) |
| #undef PY_DEF_EVENT |
| } PyCodeEvent; |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef int (*PyCode_WatchCallback)( |
| PyCodeEvent event, |
| PyCodeObject* co); |
|
|
| |
| |
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyCode_AddWatcher(PyCode_WatchCallback callback); |
|
|
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyCode_ClearWatcher(int watcher_id); |
|
|
| |
| struct _opaque { |
| int computed_line; |
| const uint8_t *lo_next; |
| const uint8_t *limit; |
| }; |
|
|
| typedef struct _line_offsets { |
| int ar_start; |
| int ar_end; |
| int ar_line; |
| struct _opaque opaque; |
| } PyCodeAddressRange; |
|
|
| |
| |
| |
| PyAPI_FUNC(int) _PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds); |
|
|
| |
| |
| |
| |
| |
| |
| |
| PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj); |
|
|
| PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, |
| PyObject *names, PyObject *lnotab); |
|
|
| PyAPI_FUNC(int) PyUnstable_Code_GetExtra( |
| PyObject *code, Py_ssize_t index, void **extra); |
| PyAPI_FUNC(int) PyUnstable_Code_SetExtra( |
| PyObject *code, Py_ssize_t index, void *extra); |
| |
| _Py_DEPRECATED_EXTERNALLY(3.12) static inline int |
| _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra) |
| { |
| return PyUnstable_Code_GetExtra(code, index, extra); |
| } |
| _Py_DEPRECATED_EXTERNALLY(3.12) static inline int |
| _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra) |
| { |
| return PyUnstable_Code_SetExtra(code, index, extra); |
| } |
|
|
| |
| |
| PyAPI_FUNC(PyObject *) PyCode_GetCode(PyCodeObject *code); |
| |
| PyAPI_FUNC(PyObject *) PyCode_GetVarnames(PyCodeObject *code); |
| |
| PyAPI_FUNC(PyObject *) PyCode_GetCellvars(PyCodeObject *code); |
| |
| PyAPI_FUNC(PyObject *) PyCode_GetFreevars(PyCodeObject *code); |
|
|
| typedef enum _PyCodeLocationInfoKind { |
| |
| PY_CODE_LOCATION_INFO_SHORT0 = 0, |
| |
| PY_CODE_LOCATION_INFO_ONE_LINE0 = 10, |
| PY_CODE_LOCATION_INFO_ONE_LINE1 = 11, |
| PY_CODE_LOCATION_INFO_ONE_LINE2 = 12, |
|
|
| PY_CODE_LOCATION_INFO_NO_COLUMNS = 13, |
| PY_CODE_LOCATION_INFO_LONG = 14, |
| PY_CODE_LOCATION_INFO_NONE = 15 |
| } _PyCodeLocationInfoKind; |
|
|
| #ifdef __cplusplus |
| } |
| #endif |
| #endif |
| #endif |
|
|