diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-04 15:57:35 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-04 15:57:35 +0000 |
commit | eb7bfcb28697f6fb2d4d933bc39233aa15423a20 (patch) | |
tree | 54b38d50cac986fba791fb0eb00804069c41e9c3 /py/objclass.c | |
parent | e67ed5d285bb2ae7b83eb8be3ee488ab08fa4db1 (diff) | |
download | micropython-eb7bfcb28697f6fb2d4d933bc39233aa15423a20.tar.gz micropython-eb7bfcb28697f6fb2d4d933bc39233aa15423a20.zip |
Split qstr into pools, and put initial pool in ROM.
Qstr's are now split into a linked-list of qstr pools. This has 2
benefits: the first pool can be in ROM (huge benefit, since we no longer
use RAM for the core qstrs), and subsequent pools use m_new for the next
pool instead of m_renew (thus avoiding a huge single table for all the
qstrs).
Still would be better to use a hash table, but this scheme takes us part
of the way (eventually convert the pools to hash tables).
Also fixed bug with import.
Also improved the way the module code is referenced (not magic number 1
anymore).
Diffstat (limited to 'py/objclass.c')
-rw-r--r-- | py/objclass.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/py/objclass.c b/py/objclass.c index 203923a722..f223c5ff25 100644 --- a/py/objclass.c +++ b/py/objclass.c @@ -6,6 +6,7 @@ #include "nlr.h" #include "misc.h" #include "mpconfig.h" +#include "mpqstr.h" #include "obj.h" #include "runtime.h" #include "map.h" @@ -25,7 +26,7 @@ mp_obj_t class_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) { mp_obj_t o = mp_obj_new_instance(self_in); // look for __init__ function - mp_map_elem_t *init_fn = mp_qstr_map_lookup(self->locals, qstr_from_str_static("__init__"), false); + mp_map_elem_t *init_fn = mp_qstr_map_lookup(self->locals, MP_QSTR___init__, false); if (init_fn != NULL) { // call __init__ function @@ -40,13 +41,13 @@ mp_obj_t class_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) { m_del(mp_obj_t, args2, n_args + 1); } if (init_ret != mp_const_none) { - nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_TypeError, "__init__() should return None, not '%s'", mp_obj_get_type_str(init_ret))); + nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "__init__() should return None, not '%s'", mp_obj_get_type_str(init_ret))); } } else { // TODO if (n_args != 0) { - nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_TypeError, "function takes 0 positional arguments but %d were given", (void*)(machine_int_t)n_args)); + nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "function takes 0 positional arguments but %d were given", (void*)(machine_int_t)n_args)); } } |