py: Make globals and locals proper dictionary objects.
Finishes addressing issue #424.
In the end this was a very neat refactor that now makes things a lot
more consistent across the py code base. It allowed some
simplifications in certain places, now that everything is a dict object.
Also converted builtins tables to dictionaries. This will be useful
when we need to turn builtins into a proper module.
diff --git a/py/builtinevex.c b/py/builtinevex.c
index 4aafbdb..0a92819 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -54,8 +54,8 @@
STATIC mp_obj_t mp_builtin_exec(uint n_args, const mp_obj_t *args) {
// Unconditional getting/setting assumes that these operations
// are cheap, which is the case when this comment was written.
- mp_map_t *old_globals = mp_globals_get();
- mp_map_t *old_locals = mp_locals_get();
+ mp_obj_dict_t *old_globals = mp_globals_get();
+ mp_obj_dict_t *old_locals = mp_locals_get();
if (n_args > 1) {
mp_obj_t globals = args[1];
mp_obj_t locals;
@@ -64,8 +64,8 @@
} else {
locals = globals;
}
- mp_globals_set(mp_obj_dict_get_map(globals));
- mp_locals_set(mp_obj_dict_get_map(locals));
+ mp_globals_set(globals);
+ mp_locals_set(locals);
}
mp_obj_t res = parse_compile_execute(args[0], MP_PARSE_FILE_INPUT);
// TODO if the above call throws an exception, then we never get to reset the globals/locals