summaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-04 15:57:35 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-04 15:57:35 +0000
commiteb7bfcb28697f6fb2d4d933bc39233aa15423a20 (patch)
tree54b38d50cac986fba791fb0eb00804069c41e9c3 /py/builtinimport.c
parente67ed5d285bb2ae7b83eb8be3ee488ab08fa4db1 (diff)
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/builtinimport.c')
-rw-r--r--py/builtinimport.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 47dbf2121..90a0fc339 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -58,7 +58,9 @@ mp_obj_t mp_builtin___import__(int n, mp_obj_t *args) {
return mp_const_none;
}
- if (!mp_compile(pn, false)) {
+ mp_obj_t module_fun = mp_compile(pn, false);
+
+ if (module_fun == mp_const_none) {
// TODO handle compile error correctly
rt_locals_set(old_locals);
rt_globals_set(old_globals);
@@ -66,7 +68,6 @@ mp_obj_t mp_builtin___import__(int n, mp_obj_t *args) {
}
// complied successfully, execute it
- mp_obj_t module_fun = rt_make_function_from_id(1); // TODO we should return from mp_compile the unique_code_id for the module
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
rt_call_function_0(module_fun);