mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 11:40:18 +01:00
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).
This commit is contained in:
12
py/runtime.c
12
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user