diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-22 23:59:20 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-22 23:59:20 +0000 |
commit | 0d028743aa12ef935b27fdbaf0a5ad3ca62d7628 (patch) | |
tree | fef0f48e45badbc8bdab625721f314b01c77288d /py/runtime.c | |
parent | f64086f80f1493c7f5009e99f4bd1fba47332cd3 (diff) | |
download | micropython-0d028743aa12ef935b27fdbaf0a5ad3ca62d7628.tar.gz micropython-0d028743aa12ef935b27fdbaf0a5ad3ca62d7628.zip |
py: Initialise loaded_module map in rt_init.
STM port crashes without this re-init. There should not be any state in
the core py/ code that relies on pre-initialised data.
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c index 7937a65b83..d6b2bf7826 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -34,6 +34,7 @@ static mp_map_t *map_locals; static mp_map_t *map_globals; static mp_map_t map_builtins; +static mp_map_t map_loaded_modules; // TODO: expose as sys.modules typedef enum { MP_CODE_NONE, @@ -83,6 +84,9 @@ void rt_init(void) { // init built-in hash table mp_map_init(&map_builtins, 3); + // init loaded modules table + mp_map_init(&map_loaded_modules, 3); + // built-in exceptions (TODO, make these proper classes) mp_map_add_qstr(&map_builtins, MP_QSTR_AttributeError, mp_obj_new_exception(MP_QSTR_AttributeError)); mp_map_add_qstr(&map_builtins, MP_QSTR_IndexError, mp_obj_new_exception(MP_QSTR_IndexError)); @@ -953,6 +957,10 @@ void rt_globals_set(mp_map_t *m) { map_globals = m; } +mp_map_t *rt_loaded_modules_get(void) { + return &map_loaded_modules; +} + // these must correspond to the respective enum void *const rt_fun_table[RT_F_NUMBER_OF] = { rt_load_const_dec, |