aboutsummaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George2014-03-08 15:24:39 +0000
committerDamien George2014-03-08 15:24:39 +0000
commit0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366 (patch)
treeeb1d8e50037139646f935df99da56764fcafb4f1 /py/runtime.c
parent8fd7d7e102372a3fe067030aa0f2049f744b1567 (diff)
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).
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 9d41f059f..7034ce13c 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -92,13 +92,13 @@ STATIC const mp_builtin_elem_t builtin_table[] = {
// 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 @@ void rt_init(void) {
//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 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
}
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
}