mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 21:20:13 +01:00
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).
This commit is contained in:
13
py/obj.c
13
py/obj.c
@@ -7,6 +7,7 @@
|
||||
#include "nlr.h"
|
||||
#include "misc.h"
|
||||
#include "mpconfig.h"
|
||||
#include "mpqstr.h"
|
||||
#include "obj.h"
|
||||
#include "runtime0.h"
|
||||
#include "runtime.h"
|
||||
@@ -144,7 +145,7 @@ machine_float_t mp_obj_get_float(mp_obj_t arg) {
|
||||
} else if (MP_OBJ_IS_TYPE(arg, &float_type)) {
|
||||
return mp_obj_float_get(arg);
|
||||
} else {
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_TypeError, "can't convert %s to float", mp_obj_get_type_str(arg)));
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "can't convert %s to float", mp_obj_get_type_str(arg)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +165,7 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
|
||||
} else if (MP_OBJ_IS_TYPE(arg, &complex_type)) {
|
||||
mp_obj_complex_get(arg, real, imag);
|
||||
} else {
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_TypeError, "can't convert %s to complex", mp_obj_get_type_str(arg)));
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "can't convert %s to complex", mp_obj_get_type_str(arg)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -188,11 +189,11 @@ mp_obj_t *mp_obj_get_array_fixed_n(mp_obj_t o_in, machine_int_t n) {
|
||||
mp_obj_list_get(o_in, &seq_len, &seq_items);
|
||||
}
|
||||
if (seq_len != n) {
|
||||
nlr_jump(mp_obj_new_exception_msg_2_args(rt_q_IndexError, "requested length %d but object has length %d", (void*)n, (void*)(machine_uint_t)seq_len));
|
||||
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_IndexError, "requested length %d but object has length %d", (void*)n, (void*)(machine_uint_t)seq_len));
|
||||
}
|
||||
return seq_items;
|
||||
} else {
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_TypeError, "object '%s' is not a tuple or list", mp_obj_get_type_str(o_in)));
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "object '%s' is not a tuple or list", mp_obj_get_type_str(o_in)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,10 +205,10 @@ uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index)
|
||||
i += len;
|
||||
}
|
||||
if (i < 0 || i >= len) {
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(rt_q_IndexError, "%s index out of range", type->name));
|
||||
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_IndexError, "%s index out of range", type->name));
|
||||
}
|
||||
return i;
|
||||
} else {
|
||||
nlr_jump(mp_obj_new_exception_msg_2_args(rt_q_TypeError, "%s indices must be integers, not %s", type->name, mp_obj_get_type_str(index)));
|
||||
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_TypeError, "%s indices must be integers, not %s", type->name, mp_obj_get_type_str(index)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user