restore async scope flag to previous bit position
This commit is contained in:
parent
f40c2cb454
commit
b65d9e7828
3 changed files with 21 additions and 9 deletions
|
|
@ -222,6 +222,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
|
|||
#define mp_arg_parse_all_kw_array(n_pos, n_kw, args, n_allowed, allowed, out_vals) \
|
||||
(mp_fun_table.arg_parse_all_kw_array((n_pos), (n_kw), (args), (n_allowed), (allowed), (out_vals)))
|
||||
|
||||
// CIRCUITPY-CHANGE: .is_async
|
||||
#define MP_DYNRUNTIME_INIT_ENTRY \
|
||||
mp_obj_t old_globals = mp_fun_table.swap_globals(self->context->module.globals); \
|
||||
mp_raw_code_truncated_t rc; \
|
||||
|
|
@ -229,6 +230,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
|
|||
rc.proto_fun_indicator[1] = MP_PROTO_FUN_INDICATOR_RAW_CODE_1; \
|
||||
rc.kind = MP_CODE_NATIVE_VIPER; \
|
||||
rc.is_generator = 0; \
|
||||
rc.is_async = 0; \
|
||||
(void)rc;
|
||||
|
||||
#define MP_DYNRUNTIME_INIT_EXIT \
|
||||
|
|
|
|||
|
|
@ -192,6 +192,14 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
|
|||
const uint8_t *bc = proto_fun;
|
||||
mp_obj_t fun = mp_obj_new_fun_bc(def_args, bc, context, NULL);
|
||||
MP_BC_PRELUDE_SIG_DECODE(bc);
|
||||
// CIRCUITPY-CHANGE: distinguish generators and async
|
||||
// A coroutine is MP_SCOPE_FLAG_ASYNC | MP_SCOPE_FLAG_GENERATOR,
|
||||
// so check for ASYNC first.
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
if (scope_flags & MP_SCOPE_FLAG_ASYNC) {
|
||||
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_coro_wrap;
|
||||
} else
|
||||
#endif
|
||||
if (scope_flags & MP_SCOPE_FLAG_GENERATOR) {
|
||||
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
|
||||
}
|
||||
|
|
@ -234,7 +242,7 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
|
|||
fun = mp_obj_new_fun_bc(def_args, rc->fun_data, context, rc->children);
|
||||
// check for generator functions and if so change the type of the object
|
||||
// CIRCUITPY-CHANGE: distinguish generators and async
|
||||
// A generator is MP_SCOPE_FLAG_ASYNC | MP_SCOPE_FLAG_GENERATOR,
|
||||
// A coroutine is MP_SCOPE_FLAG_ASYNC | MP_SCOPE_FLAG_GENERATOR,
|
||||
// so check for ASYNC first.
|
||||
#if MICROPY_PY_ASYNC_AWAIT
|
||||
if ((rc->is_async) != 0) {
|
||||
|
|
|
|||
|
|
@ -28,22 +28,24 @@
|
|||
|
||||
// These constants are used by:
|
||||
// - mp_raw_code_t::is_generator (only MP_SCOPE_FLAG_GENERATOR)
|
||||
// CIRCUITPY-CHANGE: distinguish generator and async
|
||||
// - mp_raw_code_t::is_generator (only MP_SCOPE_FLAG_ASYNC)
|
||||
// - scope_t::scope_flags (16 bits)
|
||||
// - MP_BC_PRELUDE_SIG_ENCODE macro, masked by MP_SCOPE_FLAG_ALL_SIG (4 bits)
|
||||
// - tools/mpy_ld.py, when generating mpy files (maximum 7 bits)
|
||||
#define MP_SCOPE_FLAG_ALL_SIG (0x0f)
|
||||
#define MP_SCOPE_FLAG_ALL_SIG (0x1f)
|
||||
#define MP_SCOPE_FLAG_GENERATOR (0x01)
|
||||
#define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
|
||||
#define MP_SCOPE_FLAG_VARARGS (0x04)
|
||||
#define MP_SCOPE_FLAG_DEFKWARGS (0x08)
|
||||
#define MP_SCOPE_FLAG_REFGLOBALS (0x10) // used only if native emitter enabled
|
||||
#define MP_SCOPE_FLAG_HASCONSTS (0x20) // used only if native emitter enabled
|
||||
#define MP_SCOPE_FLAG_VIPERRET_POS (6) // 3 bits used for viper return type, to pass from compiler to native emitter
|
||||
#define MP_SCOPE_FLAG_VIPERRELOC (0x10) // used only when loading viper from .mpy
|
||||
#define MP_SCOPE_FLAG_VIPERRODATA (0x20) // used only when loading viper from .mpy
|
||||
#define MP_SCOPE_FLAG_VIPERBSS (0x40) // used only when loading viper from .mpy
|
||||
// CIRCUITPY-CHANGE: FLAG_ASYNC
|
||||
#define MP_SCOPE_FLAG_ASYNC (0x80)
|
||||
#define MP_SCOPE_FLAG_ASYNC (0x10)
|
||||
#define MP_SCOPE_FLAG_REFGLOBALS (0x20) // used only if native emitter enabled
|
||||
#define MP_SCOPE_FLAG_HASCONSTS (0x40) // used only if native emitter enabled
|
||||
#define MP_SCOPE_FLAG_VIPERRET_POS (7) // 3 bits used for viper return type, to pass from compiler to native emitter
|
||||
#define MP_SCOPE_FLAG_VIPERRELOC (0x20) // used only when loading viper from .mpy
|
||||
#define MP_SCOPE_FLAG_VIPERRODATA (0x40) // used only when loading viper from .mpy
|
||||
#define MP_SCOPE_FLAG_VIPERBSS (0x80) // used only when loading viper from .mpy
|
||||
|
||||
// types for native (viper) function signature
|
||||
#define MP_NATIVE_TYPE_OBJ (0x00)
|
||||
|
|
|
|||
Loading…
Reference in a new issue