py/runtime: Factor out exception raising helpers.

Introduce mp_raise_msg(), mp_raise_ValueError(), mp_raise_TypeError()
instead of previous pattern nlr_raise(mp_obj_new_exception_msg(...)).
Save few bytes on each call, which are many.
This commit is contained in:
Paul Sokolovsky
2016-08-12 21:26:12 +03:00
parent af9889f99a
commit 9e1b61dedd
3 changed files with 54 additions and 47 deletions

View File

@@ -1390,6 +1390,18 @@ void *m_malloc_fail(size_t num_bytes) {
}
}
NORETURN void mp_not_implemented(const char *msg) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_NotImplementedError, msg));
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) {
nlr_raise(mp_obj_new_exception_msg(exc_type, msg));
}
NORETURN void mp_raise_ValueError(const char *msg) {
mp_raise_msg(&mp_type_ValueError, msg);
}
NORETURN void mp_raise_TypeError(const char *msg) {
mp_raise_msg(&mp_type_TypeError, msg);
}
NORETURN void mp_not_implemented(const char *msg) {
mp_raise_msg(&mp_type_NotImplementedError, msg);
}