|
|
|
|
|
|
|
|
#ifndef Py_LIMITED_API |
|
|
#ifndef Py_CODE_H |
|
|
#define Py_CODE_H |
|
|
#ifdef __cplusplus |
|
|
extern "C" { |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef uint16_t _Py_CODEUNIT; |
|
|
|
|
|
#ifdef WORDS_BIGENDIAN |
|
|
# define _Py_OPCODE(word) ((word) >> 8) |
|
|
# define _Py_OPARG(word) ((word) & 255) |
|
|
# define _Py_MAKECODEUNIT(opcode, oparg) (((opcode)<<8)|(oparg)) |
|
|
#else |
|
|
# define _Py_OPCODE(word) ((word) & 255) |
|
|
# define _Py_OPARG(word) ((word) >> 8) |
|
|
# define _Py_MAKECODEUNIT(opcode, oparg) ((opcode)|((oparg)<<8)) |
|
|
#endif |
|
|
|
|
|
|
|
|
#define _Py_SET_OPCODE(word, opcode) (((unsigned char *)&(word))[0] = (opcode)) |
|
|
|
|
|
|
|
|
|
|
|
#define _PyCode_DEF(SIZE) { \ |
|
|
PyObject_VAR_HEAD \ |
|
|
\ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\ |
|
|
\ |
|
|
\ |
|
|
\ |
|
|
\ |
|
|
PyObject *co_consts; \ |
|
|
PyObject *co_names; \ |
|
|
PyObject *co_exceptiontable; |
|
|
\ |
|
|
int co_flags; \ |
|
|
short co_warmup; \ |
|
|
short _co_linearray_entry_size; \ |
|
|
\ |
|
|
\ |
|
|
int co_argcount; \ |
|
|
int co_posonlyargcount; \ |
|
|
int co_kwonlyargcount; \ |
|
|
int co_stacksize; \ |
|
|
int co_firstlineno; \ |
|
|
\ |
|
|
|
|
|
\ |
|
|
int co_nlocalsplus; |
|
|
\ |
|
|
int co_nlocals; \ |
|
|
int co_nplaincellvars; \ |
|
|
int co_ncellvars; \ |
|
|
int co_nfreevars; \ |
|
|
\ |
|
|
PyObject *co_localsplusnames; \ |
|
|
PyObject *co_localspluskinds; |
|
|
\ |
|
|
PyObject *co_filename; \ |
|
|
PyObject *co_name; \ |
|
|
PyObject *co_qualname; \ |
|
|
PyObject *co_linetable; \ |
|
|
PyObject *co_weakreflist; \ |
|
|
PyObject *_co_code; \ |
|
|
char *_co_linearray; \ |
|
|
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 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) ((op)->co_nfreevars) |
|
|
#define _PyCode_CODE(CO) ((_Py_CODEUNIT *)(CO)->co_code_adaptive) |
|
|
#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT)) |
|
|
|
|
|
|
|
|
PyAPI_FUNC(PyCodeObject *) PyCode_New( |
|
|
int, int, int, int, int, PyObject *, PyObject *, |
|
|
PyObject *, PyObject *, PyObject *, PyObject *, |
|
|
PyObject *, PyObject *, PyObject *, int, PyObject *, |
|
|
PyObject *); |
|
|
|
|
|
PyAPI_FUNC(PyCodeObject *) PyCode_NewWithPosOnlyArgs( |
|
|
int, int, int, int, int, int, PyObject *, PyObject *, |
|
|
PyObject *, PyObject *, PyObject *, PyObject *, |
|
|
PyObject *, PyObject *, PyObject *, int, PyObject *, |
|
|
PyObject *); |
|
|
|
|
|
|
|
|
|
|
|
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 *); |
|
|
|
|
|
|
|
|
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) _PyCode_GetExtra(PyObject *code, Py_ssize_t index, |
|
|
void **extra); |
|
|
PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index, |
|
|
void *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 |
|
|
|