Commit 8dbbbbc7 authored by Damien George's avatar Damien George
Browse files

Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.

qstr_init is always called exactly before mp_init, so makes sense to
just have mp_init call it.  Similarly with
mp_init_emergency_exception_buf.  Doing this makes the ports simpler and
less error prone (ie they can no longer forget to call these).
parent 8362bffb
...@@ -53,7 +53,6 @@ void do_str(const char *src) { ...@@ -53,7 +53,6 @@ void do_str(const char *src) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
qstr_init();
mp_init(); mp_init();
do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\n')"); do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\n')");
mp_deinit(); mp_deinit();
......
...@@ -70,8 +70,13 @@ const mp_obj_module_t mp_module___main__ = { ...@@ -70,8 +70,13 @@ const mp_obj_module_t mp_module___main__ = {
}; };
void mp_init(void) { void mp_init(void) {
qstr_init();
mp_stack_ctrl_init(); mp_stack_ctrl_init();
#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
mp_init_emergency_exception_buf();
#endif
// call port specific initialization if any // call port specific initialization if any
#ifdef MICROPY_PORT_INIT_FUNC #ifdef MICROPY_PORT_INIT_FUNC
MICROPY_PORT_INIT_FUNC; MICROPY_PORT_INIT_FUNC;
......
...@@ -53,7 +53,6 @@ void do_str(const char *src) { ...@@ -53,7 +53,6 @@ void do_str(const char *src) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
qstr_init();
mp_init(); mp_init();
do_str("print('hello world!')"); do_str("print('hello world!')");
mp_deinit(); mp_deinit();
......
...@@ -59,7 +59,6 @@ end: ...@@ -59,7 +59,6 @@ end:
int main() { int main() {
const char a[] = {"sim"}; const char a[] = {"sim"};
qstr_init();
mp_init(); mp_init();
int r = tinytest_main(1, (const char **) a, groups); int r = tinytest_main(1, (const char **) a, groups);
mp_deinit(); mp_deinit();
......
...@@ -310,9 +310,14 @@ soft_reset: ...@@ -310,9 +310,14 @@ soft_reset:
// GC init // GC init
gc_init(&_heap_start, &_heap_end); gc_init(&_heap_start, &_heap_end);
#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
mp_init_emergency_exception_buf(); // Micro Python init
#endif mp_init();
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash));
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib));
mp_obj_list_init(mp_sys_argv, 0);
// Change #if 0 to #if 1 if you want REPL on UART_6 (or another uart) // Change #if 0 to #if 1 if you want REPL on UART_6 (or another uart)
// as well as on USB VCP // as well as on USB VCP
...@@ -328,17 +333,7 @@ soft_reset: ...@@ -328,17 +333,7 @@ soft_reset:
pyb_stdio_uart = NULL; pyb_stdio_uart = NULL;
#endif #endif
// Micro Python init
qstr_init();
mp_init();
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash));
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib));
mp_obj_list_init(mp_sys_argv, 0);
readline_init(); readline_init();
pin_init(); pin_init();
extint_init(); extint_init();
......
...@@ -267,7 +267,7 @@ soft_reset: ...@@ -267,7 +267,7 @@ soft_reset:
// GC init // GC init
gc_init(&_heap_start, (void*)HEAP_END); gc_init(&_heap_start, (void*)HEAP_END);
qstr_init(); // Micro Python init
mp_init(); mp_init();
readline_init(); readline_init();
......
...@@ -87,7 +87,6 @@ void do_file(const char *file) { ...@@ -87,7 +87,6 @@ void do_file(const char *file) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
qstr_init();
mp_init(); mp_init();
if (argc == 2) { if (argc == 2) {
......
...@@ -278,11 +278,7 @@ int main(int argc, char **argv) { ...@@ -278,11 +278,7 @@ int main(int argc, char **argv) {
char *heap = malloc(heap_size); char *heap = malloc(heap_size);
gc_init(heap, heap + heap_size); gc_init(heap, heap + heap_size);
#endif #endif
#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
mp_init_emergency_exception_buf();
#endif
qstr_init();
mp_init(); mp_init();
char *home = getenv("HOME"); char *home = getenv("HOME");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment