File tree Expand file tree Collapse file tree 4 files changed +19
-16
lines changed
Expand file tree Collapse file tree 4 files changed +19
-16
lines changed Original file line number Diff line number Diff line change 3232#include "py/runtime0.h"
3333#include "py/runtime.h"
3434#include "py/stackctrl.h"
35- #include "py/frozenmod.h"
3635#include "py/mphal.h"
3736#include "py/gc.h"
3837#include "lib/utils/pyexec.h"
@@ -49,8 +48,7 @@ STATIC void mp_reset(void) {
4948 mp_obj_list_init (mp_sys_path , 0 );
5049 mp_obj_list_init (mp_sys_argv , 0 );
5150#if MICROPY_MODULE_FROZEN
52- mp_lexer_t * lex = mp_find_frozen_module ("main" , 4 );
53- mp_parse_compile_execute (lex , MP_PARSE_FILE_INPUT , mp_globals_get (), mp_locals_get ());
51+ pyexec_frozen_module ("main" );
5452#endif
5553}
5654
Original file line number Diff line number Diff line change 2727#include <stdlib.h>
2828#include <stdio.h>
2929#include <stdint.h>
30+ #include <string.h>
3031
3132#include "py/nlr.h"
3233#include "py/compile.h"
3334#include "py/runtime.h"
3435#include "py/repl.h"
3536#include "py/gc.h"
37+ #include "py/frozenmod.h"
3638#include "py/mphal.h"
3739#if defined(USE_DEVICE_MODE )
3840#include "irq.h"
@@ -476,6 +478,19 @@ int pyexec_file(const char *filename) {
476478 return parse_compile_execute (lex , MP_PARSE_FILE_INPUT , 0 );
477479}
478480
481+ #if MICROPY_MODULE_FROZEN
482+ int pyexec_frozen_module (const char * name ) {
483+ mp_lexer_t * lex = mp_find_frozen_module (name , strlen (name ));
484+
485+ if (lex == NULL ) {
486+ printf ("could not find module '%s'\n" , name );
487+ return false;
488+ }
489+
490+ return parse_compile_execute (lex , MP_PARSE_FILE_INPUT , 0 );
491+ }
492+ #endif
493+
479494mp_obj_t pyb_set_repl_info (mp_obj_t o_value ) {
480495 repl_display_debugging_info = mp_obj_get_int (o_value );
481496 return mp_const_none ;
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ extern pyexec_mode_kind_t pyexec_mode_kind;
3939int pyexec_raw_repl (void );
4040int pyexec_friendly_repl (void );
4141int pyexec_file (const char * filename );
42+ int pyexec_frozen_module (const char * name );
4243void pyexec_event_repl_init (void );
4344int pyexec_event_repl_process_char (int c );
4445
Original file line number Diff line number Diff line change 2222#include "uart.h"
2323#include "pin.h"
2424
25- #if MICROPY_MODULE_FROZEN
26- #include "py/compile.h"
27- #include "py/frozenmod.h"
28- #endif
29-
3025extern uint32_t _heap_start ;
3126
3227void flash_error (int n ) {
@@ -306,10 +301,7 @@ int main(void) {
306301#endif
307302
308303#if MICROPY_MODULE_FROZEN
309- {
310- mp_lexer_t * lex = mp_find_frozen_module ("boot" , 4 );
311- mp_parse_compile_execute (lex , MP_PARSE_FILE_INPUT , mp_globals_get (), mp_locals_get ());
312- }
304+ pyexec_frozen_module ("boot" );
313305#else
314306 if (!pyexec_file ("/boot.py" )) {
315307 flash_error (4 );
@@ -321,10 +313,7 @@ int main(void) {
321313
322314 // run main script
323315#if MICROPY_MODULE_FROZEN
324- {
325- mp_lexer_t * lex = mp_find_frozen_module ("main" , 4 );
326- mp_parse_compile_execute (lex , MP_PARSE_FILE_INPUT , mp_globals_get (), mp_locals_get ());
327- }
316+ pyexec_frozen_module ("main" );
328317#else
329318 {
330319 vstr_t * vstr = vstr_new ();
You can’t perform that action at this time.
0 commit comments