Implement ROMable modules. Add math module.
mp_module_obj_t can now be put in ROM.
Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.
math module has basic math functions. For STM port, these are not yet
implemented (they are just stub functions).
diff --git a/py/runtime.c b/py/runtime.c
index 9d41f05..7034ce1 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -92,13 +92,13 @@
// built-in types
{ MP_QSTR_bool, (mp_obj_t)&bool_type },
#if MICROPY_ENABLE_FLOAT
- { MP_QSTR_complex, (mp_obj_t)&complex_type },
+ { MP_QSTR_complex, (mp_obj_t)&mp_type_complex },
#endif
{ MP_QSTR_dict, (mp_obj_t)&dict_type },
{ MP_QSTR_enumerate, (mp_obj_t)&enumerate_type },
{ MP_QSTR_filter, (mp_obj_t)&filter_type },
#if MICROPY_ENABLE_FLOAT
- { MP_QSTR_float, (mp_obj_t)&float_type },
+ { MP_QSTR_float, (mp_obj_t)&mp_type_float },
#endif
{ MP_QSTR_int, (mp_obj_t)&int_type },
{ MP_QSTR_list, (mp_obj_t)&list_type },
@@ -203,7 +203,9 @@
//sys_path = mp_obj_new_list(0, NULL);
//rt_store_attr(m_sys, MP_QSTR_path, sys_path);
- mp_module_micropython_init();
+ // we pre-import the micropython module
+ // probably shouldn't do this, so we are compatible with CPython
+ rt_store_name(MP_QSTR_micropython, (mp_obj_t)&mp_module_micropython);
// TODO: wastes one mp_code_t structure in mem
next_unique_code_id = 1; // 0 indicates "no code"
@@ -586,9 +588,9 @@
}
return mp_obj_new_int(lhs_val);
#if MICROPY_ENABLE_FLOAT
- } else if (MP_OBJ_IS_TYPE(rhs, &float_type)) {
+ } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_float)) {
return mp_obj_float_binary_op(op, lhs_val, rhs);
- } else if (MP_OBJ_IS_TYPE(rhs, &complex_type)) {
+ } else if (MP_OBJ_IS_TYPE(rhs, &mp_type_complex)) {
return mp_obj_complex_binary_op(op, lhs_val, 0, rhs);
#endif
}