From 644f4dcc94ad4eb3005e652b8502192dd2494ba7 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Fri, 31 Dec 2021 17:01:03 +0200 Subject: [PATCH] shared/runtime/pyexec: Cleanup EXEC_FLAG flag constants. - Cleanup pyexec flags definitions so it's clear they are different. - Use mp_uint_t for exec_flags because it should be unsigned. --- shared/runtime/pyexec.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index 2dceb647c3..5f05c1da3e 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -50,20 +50,20 @@ int pyexec_system_exit = 0; STATIC bool repl_display_debugging_info = 0; #endif -#define EXEC_FLAG_PRINT_EOF (1) -#define EXEC_FLAG_ALLOW_DEBUGGING (2) -#define EXEC_FLAG_IS_REPL (4) -#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) -#define EXEC_FLAG_SOURCE_IS_VSTR (16) -#define EXEC_FLAG_SOURCE_IS_FILENAME (32) -#define EXEC_FLAG_SOURCE_IS_READER (64) +#define EXEC_FLAG_PRINT_EOF (1 << 0) +#define EXEC_FLAG_ALLOW_DEBUGGING (1 << 1) +#define EXEC_FLAG_IS_REPL (1 << 2) +#define EXEC_FLAG_SOURCE_IS_RAW_CODE (1 << 3) +#define EXEC_FLAG_SOURCE_IS_VSTR (1 << 4) +#define EXEC_FLAG_SOURCE_IS_FILENAME (1 << 5) +#define EXEC_FLAG_SOURCE_IS_READER (1 << 6) // parses, compiles and executes the code in the lexer // frees the lexer before returning // EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output // EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code // EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile) -STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, int exec_flags) { +STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, mp_uint_t exec_flags) { int ret = 0; #if MICROPY_REPL_INFO uint32_t start = 0; @@ -135,6 +135,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input if (exec_flags & EXEC_FLAG_PRINT_EOF) { 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))) { // at the moment, the value of SystemExit is unused