summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-09-27 23:08:10 +1000
committerDamien George <damien.p.george@gmail.com>2016-09-27 23:08:10 +1000
commit0c595fa0947c837e837b495aecd0ae04a4b64d2f (patch)
tree4d98fd2264a9e751832effde2130526b9047b633 /py
parentc71edaed73e7c000747b58da8d9c8c807b519d07 (diff)
downloadmicropython-0c595fa0947c837e837b495aecd0ae04a4b64d2f.tar.gz
micropython-0c595fa0947c837e837b495aecd0ae04a4b64d2f.zip
py/objfun: Use if instead of switch to check return value of VM execute.
It's simpler and improves code coverage.
Diffstat (limited to 'py')
-rw-r--r--py/objfun.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/py/objfun.c b/py/objfun.c
index fd51dd589d..405f38127a 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -266,23 +266,14 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
#endif
mp_obj_t result;
- switch (vm_return_kind) {
- case MP_VM_RETURN_NORMAL:
- // return value is in *sp
- result = *code_state->sp;
- break;
-
- case MP_VM_RETURN_EXCEPTION:
- // return value is in state[n_state - 1]
- result = code_state->state[n_state - 1];
- break;
-
- case MP_VM_RETURN_YIELD: // byte-code shouldn't yield
- default:
- assert(0);
- result = mp_const_none;
- vm_return_kind = MP_VM_RETURN_NORMAL;
- break;
+ if (vm_return_kind == MP_VM_RETURN_NORMAL) {
+ // return value is in *sp
+ result = *code_state->sp;
+ } else {
+ // must be an exception because normal functions can't yield
+ assert(vm_return_kind == MP_VM_RETURN_EXCEPTION);
+ // return value is in fastn[0]==state[n_state - 1]
+ result = code_state->state[n_state - 1];
}
// free the state if it was allocated on the heap