diff options
| author | Damien George | 2014-01-03 14:03:48 +0000 |
|---|---|---|
| committer | Damien George | 2014-01-03 14:03:48 +0000 |
| commit | 66028ab6dcd1b2ec9504c3473d817649935a4a1e (patch) | |
| tree | c441ee4d665b3218e235dec24dd5a66a6fe050ef /py/builtin.c | |
| parent | aae7847508e2a9555ad3276c5cd4f42b2e66686c (diff) | |
Basic implementation of import.
import works for simple cases. Still work to do on finding the right
script, and setting globals/locals correctly when running an imported
function.
Diffstat (limited to 'py/builtin.c')
| -rw-r--r-- | py/builtin.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/py/builtin.c b/py/builtin.c index 2b94163f1..d29a2bf8c 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -16,30 +16,20 @@ mp_obj_t mp_builtin___build_class__(mp_obj_t o_class_fun, mp_obj_t o_class_name) { // we differ from CPython: we set the new __locals__ object here - mp_map_t *old_locals = rt_get_map_locals(); + mp_map_t *old_locals = rt_locals_get(); mp_map_t *class_locals = mp_map_new(MP_MAP_QSTR, 0); - rt_set_map_locals(class_locals); + rt_locals_set(class_locals); // call the class code rt_call_function_1(o_class_fun, (mp_obj_t)0xdeadbeef); // restore old __locals__ object - rt_set_map_locals(old_locals); + rt_locals_set(old_locals); // create and return the new class return mp_obj_new_class(class_locals); } -mp_obj_t mp_builtin___import__(int n, mp_obj_t *args) { - printf("import:\n"); - for (int i = 0; i < n; i++) { - printf(" "); - mp_obj_print(args[i]); - printf("\n"); - } - return mp_const_none; -} - mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { if (o != mp_const_none) { mp_obj_print(o); |
