summaryrefslogtreecommitdiff
path: root/py/emitglue.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-02-09 17:38:25 +1100
committerDamien George <damien@micropython.org>2024-02-16 12:48:02 +1100
commit5e3006f1172d0eabbbefeb3268dfb942ec7cf9cd (patch)
tree9ad4455beb4711980134e44acd0d2bdf798b74b4 /py/emitglue.c
parent416465d81e911b088836f4e7c37fac2bc0f67917 (diff)
py/emitglue: Simplify mp_raw_code_t's kind and scope_flags members.
To simplify their access and reduce code size. The `scope_flags` member is only ever used to determine if a function is a generator or not, so make it reflect that fact as a bool type. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/emitglue.c')
-rw-r--r--py/emitglue.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/emitglue.c b/py/emitglue.c
index 0ec126fe9..c0003c5cd 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -71,7 +71,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
uint16_t scope_flags) {
rc->kind = MP_CODE_BYTECODE;
- rc->scope_flags = scope_flags;
+ rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
rc->fun_data = code;
#if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
rc->fun_data_len = len;
@@ -133,7 +133,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
#endif
rc->kind = kind;
- rc->scope_flags = scope_flags;
+ rc->is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0;
rc->fun_data = fun_data;
#if MICROPY_PERSISTENT_CODE_SAVE || MICROPY_DEBUG_PRINTERS
@@ -191,7 +191,7 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
case MP_CODE_NATIVE_VIPER:
fun = mp_obj_new_fun_native(def_args, rc->fun_data, context, rc->children);
// Check for a generator function, and if so change the type of the object
- if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
+ if (rc->is_generator) {
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
}
break;
@@ -206,7 +206,7 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, const mp_module
assert(rc->kind == MP_CODE_BYTECODE);
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
- if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
+ if (rc->is_generator) {
((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
}