kopia lustrzana https://github.com/micropython/micropython
runtime/abort: Add support for vm_abort in standard runtime.
Signed-off-by: John Smith <jsmith@jsmith.cz>pull/14419/head
rodzic
64f28dc1eb
commit
efe6c3edd7
|
@ -45,6 +45,9 @@
|
|||
|
||||
pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL;
|
||||
int pyexec_system_exit = 0;
|
||||
#if MICROPY_ENABLE_VM_ABORT
|
||||
int pyexec_abort = 0;
|
||||
#endif
|
||||
|
||||
#if MICROPY_REPL_INFO
|
||||
static bool repl_display_debugging_info = 0;
|
||||
|
@ -80,6 +83,10 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
|
|||
nlr_buf_t nlr;
|
||||
nlr.ret_val = NULL;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
#if MICROPY_ENABLE_VM_ABORT
|
||||
nlr_set_abort(&nlr);
|
||||
#endif
|
||||
|
||||
mp_obj_t module_fun;
|
||||
#if MICROPY_MODULE_FROZEN_MPY
|
||||
if (exec_flags & EXEC_FLAG_SOURCE_IS_RAW_CODE) {
|
||||
|
@ -143,15 +150,22 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
|
|||
mp_hal_stdout_tx_strn("\x04", 1);
|
||||
}
|
||||
|
||||
// check for SystemExit
|
||||
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
|
||||
#if MICROPY_ENABLE_VM_ABORT
|
||||
if (nlr.ret_val == NULL) { // abort
|
||||
ret = pyexec_abort;
|
||||
} else
|
||||
#endif
|
||||
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) { // system exit
|
||||
// at the moment, the value of SystemExit is unused
|
||||
ret = pyexec_system_exit;
|
||||
} else {
|
||||
} else { // other exception
|
||||
mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
#if MICROPY_ENABLE_VM_ABORT
|
||||
nlr_set_abort(NULL);
|
||||
#endif
|
||||
|
||||
#if MICROPY_REPL_INFO
|
||||
// display debugging info if wanted
|
||||
|
|
|
@ -40,6 +40,13 @@ extern pyexec_mode_kind_t pyexec_mode_kind;
|
|||
// It will reset to 0 at the start of each execution (eg each REPL entry).
|
||||
extern int pyexec_system_exit;
|
||||
|
||||
#if MICROPY_ENABLE_VM_ABORT
|
||||
// Set this to the value (eg PYEXEC_FORCED_EXIT) that will be propagated through
|
||||
// the pyexec functions if the VM is aborted for immediate exit.
|
||||
// It will reset to 0 at the start of each execution (eg each REPL entry).
|
||||
extern int pyexec_abort;
|
||||
#endif
|
||||
|
||||
#define PYEXEC_FORCED_EXIT (0x100)
|
||||
|
||||
int pyexec_raw_repl(void);
|
||||
|
|
Ładowanie…
Reference in New Issue