3#ifndef __NUITKA_COMPILED_ASYNCGEN_H__
4#define __NUITKA_COMPILED_ASYNCGEN_H__
11#if PYTHON_VERSION >= 0x360
15#include "nuitka/prelude.h"
20struct Nuitka_AsyncgenObject {
30 PyObject *m_yield_from;
40#if PYTHON_VERSION >= 0x380
50 PyCodeObject *m_code_object;
54 Nuitka_ThreadStateFrameType *m_resume_frame;
57 Generator_Status m_status;
59#if PYTHON_VERSION >= 0x370
64 int m_yield_return_index;
67 PyObject *m_finalizer;
70 bool m_hooks_init_done;
85 Py_ssize_t m_closure_given;
89extern PyTypeObject Nuitka_Asyncgen_Type;
91typedef PyObject *(*asyncgen_code)(PyThreadState *tstate,
struct Nuitka_AsyncgenObject *, PyObject *);
93extern PyObject *Nuitka_Asyncgen_New(asyncgen_code code, PyObject *module, PyObject *name, PyObject *qualname,
95 Py_ssize_t closure_given, Py_ssize_t heap_storage_size);
97static inline bool Nuitka_Asyncgen_Check(PyObject *
object) {
return Py_TYPE(
object) == &Nuitka_Asyncgen_Type; }
99static inline void SAVE_ASYNCGEN_EXCEPTION(PyThreadState *tstate,
struct Nuitka_AsyncgenObject *asyncgen) {
108 PRINT_STRING(
"SAVE_ASYNCGEN_EXCEPTION: Enter\n");
109 PRINT_PUBLISHED_EXCEPTION();
112#if PYTHON_VERSION < 0x3b0
113 PyObject *saved_exception_type = EXC_TYPE(tstate);
115 PyObject *saved_exception_value = EXC_VALUE(tstate);
116#if PYTHON_VERSION < 0x3b0
117 PyTracebackObject *saved_exception_traceback = EXC_TRACEBACK(tstate);
120#if PYTHON_VERSION < 0x370
121 EXC_TYPE(tstate) = tstate->frame->f_exc_type;
122 EXC_VALUE(tstate) = tstate->frame->f_exc_value;
123 SET_EXC_TRACEBACK(tstate, tstate->frame->f_exc_traceback);
125#if PYTHON_VERSION < 0x3b0
126 EXC_TYPE(tstate) = asyncgen->m_exc_state.exception_type;
128 EXC_VALUE(tstate) = asyncgen->m_exc_state.exception_value;
129#if PYTHON_VERSION < 0x3b0
130 SET_EXC_TRACEBACK(tstate, asyncgen->m_exc_state.exception_tb);
135 PRINT_STRING(
"SAVE_ASYNCGEN_EXCEPTION: Leave\n");
136 PRINT_PUBLISHED_EXCEPTION();
139#if PYTHON_VERSION < 0x370
140 tstate->frame->f_exc_type = saved_exception_type;
141 tstate->frame->f_exc_value = saved_exception_value;
142 tstate->frame->f_exc_traceback = (PyObject *)saved_exception_traceback;
144#if PYTHON_VERSION < 0x3b0
145 asyncgen->m_exc_state.exception_type = saved_exception_type;
147 asyncgen->m_exc_state.exception_value = saved_exception_value;
148#if PYTHON_VERSION < 0x3b0
149 asyncgen->m_exc_state.exception_tb = (PyTracebackObject *)saved_exception_traceback;
154static inline void RESTORE_ASYNCGEN_EXCEPTION(PyThreadState *tstate,
struct Nuitka_AsyncgenObject *asyncgen) {
158#if PYTHON_VERSION < 0x3b0
159 PyObject *saved_exception_type = EXC_TYPE(tstate);
161 PyObject *saved_exception_value = EXC_VALUE(tstate);
162#if PYTHON_VERSION < 0x3b0
163 PyTracebackObject *saved_exception_traceback = EXC_TRACEBACK(tstate);
167 PRINT_STRING(
"RESTORE_ASYNCGEN_EXCEPTION: Enter\n");
168#if PYTHON_VERSION < 0x3b0
169 PRINT_EXCEPTION(saved_exception_type, saved_exception_value, saved_exception_traceback);
171 _PRINT_EXCEPTION1(saved_exception_value);
175#if PYTHON_VERSION < 0x370
176 EXC_TYPE(tstate) = tstate->frame->f_exc_type;
177 EXC_VALUE(tstate) = tstate->frame->f_exc_value;
178 SET_EXC_TRACEBACK(tstate, tstate->frame->f_exc_traceback);
180 tstate->frame->f_exc_type = saved_exception_type;
181 tstate->frame->f_exc_value = saved_exception_value;
182 tstate->frame->f_exc_traceback = (PyObject *)saved_exception_traceback;
184#if PYTHON_VERSION < 0x3b0
185 EXC_TYPE(tstate) = asyncgen->m_exc_state.exception_type;
187 EXC_VALUE(tstate) = asyncgen->m_exc_state.exception_value;
188#if PYTHON_VERSION < 0x3b0
189 SET_EXC_TRACEBACK(tstate, asyncgen->m_exc_state.exception_tb);
192#if PYTHON_VERSION < 0x3b0
193 asyncgen->m_exc_state.exception_type = saved_exception_type;
195 asyncgen->m_exc_state.exception_value = saved_exception_value;
196#if PYTHON_VERSION < 0x3b0
197 asyncgen->m_exc_state.exception_tb = (PyTracebackObject *)saved_exception_traceback;
202 PRINT_STRING(
"RESTORE_ASYNCGEN_EXCEPTION: Leave\n");
203 PRINT_PUBLISHED_EXCEPTION();
206#if PYTHON_VERSION < 0x3b0
207 CHECK_OBJECT_X(EXC_TYPE(tstate));
209 CHECK_OBJECT_X(EXC_VALUE(tstate));
210#if PYTHON_VERSION < 0x3b0
211 CHECK_OBJECT_X(EXC_TRACEBACK(tstate));
215NUITKA_MAY_BE_UNUSED
static void STORE_ASYNCGEN_EXCEPTION(PyThreadState *tstate,
216 struct Nuitka_AsyncgenObject *asyncgen) {
218#if PYTHON_VERSION < 0x3b0
219 EXC_TYPE_F(asyncgen) = EXC_TYPE(tstate);
220 if (EXC_TYPE_F(asyncgen) == Py_None) {
221 EXC_TYPE_F(asyncgen) = NULL;
223 Py_XINCREF(EXC_TYPE_F(asyncgen));
224 assert(EXC_TYPE_F(asyncgen) == NULL);
226 EXC_VALUE_F(asyncgen) = EXC_VALUE(tstate);
227 Py_XINCREF(EXC_VALUE_F(asyncgen));
228#if PYTHON_VERSION < 0x3b0
229 ASSIGN_EXC_TRACEBACK_F(asyncgen, EXC_TRACEBACK(tstate));
230 Py_XINCREF(EXC_TRACEBACK_F(asyncgen));
234NUITKA_MAY_BE_UNUSED
static void DROP_ASYNCGEN_EXCEPTION(
struct Nuitka_AsyncgenObject *asyncgen) {
235#if PYTHON_VERSION < 0x3b0
236 Py_CLEAR(EXC_TYPE_F(asyncgen));
238 Py_CLEAR(EXC_VALUE_F(asyncgen));
239#if PYTHON_VERSION < 0x3b0
240 Py_CLEAR(EXC_TRACEBACK_F(asyncgen));
246extern int count_active_Nuitka_Asyncgen_Type;
247extern int count_allocated_Nuitka_Asyncgen_Type;
248extern int count_released_Nuitka_Asyncgen_Type;
250extern int count_active_Nuitka_AsyncgenValueWrapper_Type;
251extern int count_allocated_Nuitka_AsyncgenValueWrapper_Type;
252extern int count_released_Nuitka_AsyncgenValueWrapper_Type;
254extern int count_active_Nuitka_AsyncgenAsend_Type;
255extern int count_allocated_Nuitka_AsyncgenAsend_Type;
256extern int count_released_Nuitka_AsyncgenAsend_Type;
258extern int count_active_Nuitka_AsyncgenAthrow_Type;
259extern int count_allocated_Nuitka_AsyncgenAthrow_Type;
260extern int count_released_Nuitka_AsyncgenAthrow_Type;
Definition compiled_cell.h:14
Definition exceptions.h:222
Definition compiled_frame.h:117