|
#ifndef Py_CPYTHON_CODE_H |
|
# error "this header file must not be included directly" |
|
#endif |
|
|
|
typedef uint16_t _Py_CODEUNIT; |
|
|
|
#ifdef WORDS_BIGENDIAN |
|
# define _Py_OPCODE(word) ((word) >> 8) |
|
# define _Py_OPARG(word) ((word) & 255) |
|
#else |
|
# define _Py_OPCODE(word) ((word) & 255) |
|
# define _Py_OPARG(word) ((word) >> 8) |
|
#endif |
|
|
|
typedef struct _PyOpcache _PyOpcache; |
|
|
|
|
|
struct PyCodeObject { |
|
PyObject_HEAD |
|
int co_argcount; |
|
int co_posonlyargcount; |
|
int co_kwonlyargcount; |
|
int co_nlocals; |
|
int co_stacksize; |
|
int co_flags; |
|
int co_firstlineno; |
|
PyObject *co_code; |
|
PyObject *co_consts; |
|
PyObject *co_names; |
|
PyObject *co_varnames; |
|
PyObject *co_freevars; |
|
PyObject *co_cellvars; |
|
|
|
|
|
|
|
|
|
|
|
Py_ssize_t *co_cell2arg; |
|
PyObject *co_filename; |
|
PyObject *co_name; |
|
PyObject *co_linetable; |
|
|
|
void *co_zombieframe; |
|
PyObject *co_weakreflist; |
|
|
|
|
|
|
|
void *co_extra; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char *co_opcache_map; |
|
_PyOpcache *co_opcache; |
|
int co_opcache_flag; |
|
unsigned char co_opcache_size; |
|
}; |
|
|
|
|
|
#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_NOFREE 0x0040 |
|
|
|
|
|
|
|
#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_CELL_NOT_AN_ARG (-1) |
|
|
|
|
|
|
|
|
|
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD |
|
|
|
#define CO_MAXBLOCKS 20 |
|
|
|
PyAPI_DATA(PyTypeObject) PyCode_Type; |
|
|
|
#define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type) |
|
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) |
|
|
|
|
|
PyAPI_FUNC(PyCodeObject *) PyCode_New( |
|
int, int, int, int, int, PyObject *, PyObject *, |
|
PyObject *, PyObject *, PyObject *, PyObject *, |
|
PyObject *, PyObject *, int, PyObject *); |
|
|
|
PyAPI_FUNC(PyCodeObject *) PyCode_NewWithPosOnlyArgs( |
|
int, int, int, int, int, int, PyObject *, PyObject *, |
|
PyObject *, PyObject *, PyObject *, PyObject *, |
|
PyObject *, PyObject *, int, PyObject *); |
|
|
|
|
|
|
|
PyAPI_FUNC(PyCodeObject *) |
|
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); |
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); |
|
|
|
|
|
struct _opaque { |
|
int computed_line; |
|
const char *lo_next; |
|
const char *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) _PyCode_GetExtra(PyObject *code, Py_ssize_t index, |
|
void **extra); |
|
PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index, |
|
void *extra); |
|
|
|
|
|
int _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds); |
|
|
|
|
|
void PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range); |
|
|
|
|
|
int PyLineTable_NextAddressRange(PyCodeAddressRange *range); |
|
int PyLineTable_PreviousAddressRange(PyCodeAddressRange *range); |
|
|
|
|
|
|