shared/runtime/pyexec: Add helper function to execute a vstr.

Add `pyexec_vstr()` to execute Python code from a vstr source.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-02-27 09:03:17 +01:00 committed by Damien George
parent dbda43b9e1
commit f187c77da8
2 changed files with 6 additions and 0 deletions

View file

@ -720,6 +720,11 @@ int pyexec_frozen_module(const char *name, bool allow_keyboard_interrupt) {
}
#endif
int pyexec_vstr(vstr_t *str, bool allow_keyboard_interrupt) {
mp_uint_t exec_flags = allow_keyboard_interrupt ? 0 : EXEC_FLAG_NO_INTERRUPT;
return parse_compile_execute(str, MP_PARSE_FILE_INPUT, exec_flags | EXEC_FLAG_SOURCE_IS_VSTR);
}
#if MICROPY_REPL_INFO
mp_obj_t pyb_set_repl_info(mp_obj_t o_value) {
repl_display_debugging_info = mp_obj_get_int(o_value);

View file

@ -42,6 +42,7 @@ int pyexec_friendly_repl(void);
int pyexec_file(const char *filename);
int pyexec_file_if_exists(const char *filename);
int pyexec_frozen_module(const char *name, bool allow_keyboard_interrupt);
int pyexec_vstr(vstr_t *str, bool allow_keyboard_interrupt);
void pyexec_event_repl_init(void);
int pyexec_event_repl_process_char(int c);
extern uint8_t pyexec_repl_active;