39 #if MICROPY_DEBUG_VERBOSE // print debugging info 40 #define DEBUG_PRINT (1) 41 #define DEBUG_printf DEBUG_printf 42 #else // don't print debugging info 43 #define DEBUG_PRINT (0) 44 #define DEBUG_printf(...) (void)0 47 #define PATH_SEP_CHAR '/' 58 #if MICROPY_MODULE_FROZEN 73 #if MICROPY_PERSISTENT_CODE_LOAD 111 for (
size_t i = 0; i < path_num; i++) {
132 #if MICROPY_ENABLE_COMPILER 134 #if MICROPY_PY___FILE__ 145 #if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_MODULE_FROZEN_MPY 147 #if MICROPY_PY___FILE__ 161 mp_globals_set(mod_globals);
162 mp_locals_set(mod_globals);
171 mp_globals_set(old_globals);
172 mp_locals_set(old_locals);
175 mp_globals_set(old_globals);
176 mp_locals_set(old_locals);
183 #if MICROPY_MODULE_FROZEN || MICROPY_PERSISTENT_CODE_LOAD || MICROPY_ENABLE_COMPILER 189 #if MICROPY_MODULE_FROZEN 196 #if MICROPY_MODULE_FROZEN_STR 198 do_load_from_lexer(module_obj, modref);
205 #if MICROPY_MODULE_FROZEN_MPY 207 do_execute_raw_code(module_obj, modref);
214 #if MICROPY_PERSISTENT_CODE_LOAD 215 if (file_str[file->
len - 3] ==
'm') {
217 do_execute_raw_code(module_obj, raw_code);
223 #if MICROPY_ENABLE_COMPILER 226 do_load_from_lexer(module_obj, lex);
237 const char *p = *end;
250 for (
size_t i = 0; i < n_args; i++) {
284 #if MICROPY_CPYTHON_COMPAT 290 mp_map_t *globals_map = &mp_globals_get()->map;
292 bool is_pkg = (elem !=
NULL);
304 const char *p = this_name + this_name_l;
316 if (p == this_name) {
320 uint new_mod_l = (mod_len == 0 ? (
size_t)(p - this_name) : (
size_t)(p - this_name) + 1 + mod_len);
321 char *new_mod =
alloca(new_mod_l);
322 memcpy(new_mod, this_name, p - this_name);
324 new_mod[p - this_name] =
'.';
325 memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len);
341 char *p =
strchr(mod_str,
'.');
361 for (i = 1; i <= mod_len; i++) {
362 if (i == mod_len || mod_str[i] ==
'.') {
366 DEBUG_printf(
"Previous path: =%.*s=\n", vstr_len(&path), vstr_str(&path));
370 if (vstr_len(&path) == 0) {
379 DEBUG_printf(
"Current path: %.*s\n", vstr_len(&path), vstr_str(&path));
382 #if MICROPY_MODULE_WEAK_LINKS 390 module_obj = el->
value;
401 "no module named '%q'", mod_name));
425 #if MICROPY_CPYTHON_COMPAT 434 DEBUG_printf(
"%.*s is dir\n", vstr_len(&path), vstr_str(&path));
438 size_t orig_path_len = path.len;
446 path.len = orig_path_len;
459 outer_module_obj = module_obj;
461 top_module_obj = module_obj;
472 return top_module_obj;
qstr mp_obj_str_get_qstr(mp_obj_t self_in)
qstr qstr_from_strn(const char *str, size_t len)
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg)
const char * qstr_str(qstr q)
void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest)
#define MICROPY_ERROR_REPORTING_TERSE
void vstr_add_strn(vstr_t *vstr, const char *str, size_t len)
mp_raw_code_t * mp_raw_code_load_file(const char *filename)
STATIC void chop_component(const char *start, const char **end)
const mp_map_t mp_builtin_module_weak_links_map
STATIC void do_load(mp_obj_t module_obj, vstr_t *file)
void vstr_add_char(vstr_t *vstr, unichar chr)
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt,...)
#define MP_OBJ_QSTR_VALUE(o)
void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind)
#define MP_OBJ_FROM_PTR(p)
#define MP_OBJ_NEW_QSTR(qst)
const mp_obj_type_t mp_type_ImportError
mp_import_stat_t mp_import_stat(const char *path)
mp_obj_t mp_module_get(qstr module_name)
mp_obj_dict_t * mp_obj_module_get_globals(mp_obj_t self_in)
#define VSTR_FIXED(vstr, alloc)
mp_obj_t mp_call_function_0(mp_obj_t fun)
void vstr_add_str(vstr_t *vstr, const char *str)
mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals)
#define MP_OBJ_SMALL_INT_VALUE(o)
mp_lexer_t * mp_lexer_new_from_file(const char *filename)
STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path)
mp_map_elem_t * mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind)
#define MICROPY_ERROR_REPORTING
const char * mp_obj_str_get_data(mp_obj_t self_in, size_t *len)
#define MICROPY_ALLOC_PATH_MAX
char * strchr(const char *s, int c)
void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items)
bool mp_obj_is_package(mp_obj_t module)
mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_args, mp_obj_t def_kw_args)
mp_obj_t mp_obj_new_str(const char *data, size_t len, bool make_qstr_if_not_already)
mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index)
STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest)
NORETURN void mp_raise_ValueError(const char *msg)
mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value)
char * vstr_null_terminated_str(vstr_t *vstr)
#define DEBUG_printf(...)
STATIC mp_import_stat_t mp_import_stat_any(const char *path)
void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t value)
mp_import_stat_t mp_frozen_stat(const char *str)
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj, 1, 5, mp_builtin___import__)
mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args)
void * memcpy(void *dst, const void *src, size_t n)
int mp_find_frozen_module(const char *str, size_t len, void **data)
mp_obj_t mp_obj_new_module(qstr module_name)
STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path)
void vstr_ins_byte(vstr_t *vstr, size_t byte_pos, byte b)