Skip to content

Commit 644f4dc

Browse files
iabdalkaderdpgeorge
authored andcommitted
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.
1 parent 58b56b9 commit 644f4dc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

shared/runtime/pyexec.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ int pyexec_system_exit = 0;
5050
STATIC bool repl_display_debugging_info = 0;
5151
#endif
5252

53-
#define EXEC_FLAG_PRINT_EOF (1)
54-
#define EXEC_FLAG_ALLOW_DEBUGGING (2)
55-
#define EXEC_FLAG_IS_REPL (4)
56-
#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8)
57-
#define EXEC_FLAG_SOURCE_IS_VSTR (16)
58-
#define EXEC_FLAG_SOURCE_IS_FILENAME (32)
59-
#define EXEC_FLAG_SOURCE_IS_READER (64)
53+
#define EXEC_FLAG_PRINT_EOF (1 << 0)
54+
#define EXEC_FLAG_ALLOW_DEBUGGING (1 << 1)
55+
#define EXEC_FLAG_IS_REPL (1 << 2)
56+
#define EXEC_FLAG_SOURCE_IS_RAW_CODE (1 << 3)
57+
#define EXEC_FLAG_SOURCE_IS_VSTR (1 << 4)
58+
#define EXEC_FLAG_SOURCE_IS_FILENAME (1 << 5)
59+
#define EXEC_FLAG_SOURCE_IS_READER (1 << 6)
6060

6161
// parses, compiles and executes the code in the lexer
6262
// frees the lexer before returning
6363
// EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output
6464
// EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code
6565
// EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile)
66-
STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, int exec_flags) {
66+
STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, mp_uint_t exec_flags) {
6767
int ret = 0;
6868
#if MICROPY_REPL_INFO
6969
uint32_t start = 0;
@@ -135,6 +135,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
135135
if (exec_flags & EXEC_FLAG_PRINT_EOF) {
136136
mp_hal_stdout_tx_strn("\x04", 1);
137137
}
138+
138139
// check for SystemExit
139140
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))) {
140141
// at the moment, the value of SystemExit is unused

0 commit comments

Comments
 (0)