summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-07-12 22:41:10 +1000
committerDamien George <damien@micropython.org>2022-07-12 22:48:07 +1000
commit893a5c83412d75c1da8c429d4809650660c2ee94 (patch)
tree35500407eb86616daf280c0cdafeab165470875a /py
parentd84220b8c62003b4714e0fa514a46ff5139148dc (diff)
py/vm: In YIELD_FROM opcode, expand helper macros and remove them.
The GENERATOR_EXIT_IF_NEEDED macro is only used once and it's easier to read and understand the code if this macro body is written in the code. Then the comment just before it makes more sense. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
-rw-r--r--py/vm.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/py/vm.c b/py/vm.c
index 9157fc7d1..80e271845 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -1188,9 +1188,6 @@ yield:
ENTRY(MP_BC_YIELD_FROM): {
MARK_EXC_IP_SELECTIVE();
-//#define EXC_MATCH(exc, type) mp_obj_is_type(exc, type)
-#define EXC_MATCH(exc, type) mp_obj_exception_match(exc, type)
-#define GENERATOR_EXIT_IF_NEEDED(t) if (t != MP_OBJ_NULL && EXC_MATCH(t, MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) { mp_obj_t raise_t = mp_make_raise_obj(t); RAISE(raise_t); }
mp_vm_return_kind_t ret_kind;
mp_obj_t send_value = POP();
mp_obj_t t_exc = MP_OBJ_NULL;
@@ -1214,11 +1211,14 @@ yield:
SET_TOP(ret_value);
// If we injected GeneratorExit downstream, then even
// if it was swallowed, we re-raise GeneratorExit
- GENERATOR_EXIT_IF_NEEDED(t_exc);
+ if (t_exc != MP_OBJ_NULL && mp_obj_exception_match(t_exc, MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) {
+ mp_obj_t raise_t = mp_make_raise_obj(t_exc);
+ RAISE(raise_t);
+ }
DISPATCH();
} else {
assert(ret_kind == MP_VM_RETURN_EXCEPTION);
- assert(!EXC_MATCH(ret_value, MP_OBJ_FROM_PTR(&mp_type_StopIteration)));
+ assert(!mp_obj_exception_match(ret_value, MP_OBJ_FROM_PTR(&mp_type_StopIteration)));
// Pop exhausted gen
sp--;
RAISE(ret_value);