2020#include "lexer.h"
2121#include "lexerstm.h"
2222#include "parse.h"
23- #include "compile.h"
2423#include "obj.h"
24+ #include "compile.h"
2525#include "runtime0.h"
2626#include "runtime.h"
2727#include "repl.h"
@@ -489,25 +489,22 @@ void do_repl(void) {
489489 mp_lexer_free (lex );
490490
491491 if (pn != MP_PARSE_NODE_NULL ) {
492- bool comp_ok = mp_compile (pn , true);
493- if (comp_ok ) {
494- mp_obj_t module_fun = rt_make_function_from_id (1 );
495- if (module_fun != mp_const_none ) {
496- nlr_buf_t nlr ;
497- uint32_t start = sys_tick_counter ;
498- if (nlr_push (& nlr ) == 0 ) {
499- rt_call_function_0 (module_fun );
500- nlr_pop ();
501- // optional timing
502- if (0 ) {
503- uint32_t ticks = sys_tick_counter - start ; // TODO implement a function that does this properly
504- printf ("(took %lu ms)\n" , ticks );
505- }
506- } else {
507- // uncaught exception
508- mp_obj_print ((mp_obj_t )nlr .ret_val );
509- printf ("\n" );
492+ mp_obj_t module_fun = mp_compile (pn , true);
493+ if (module_fun != mp_const_none ) {
494+ nlr_buf_t nlr ;
495+ uint32_t start = sys_tick_counter ;
496+ if (nlr_push (& nlr ) == 0 ) {
497+ rt_call_function_0 (module_fun );
498+ nlr_pop ();
499+ // optional timing
500+ if (0 ) {
501+ uint32_t ticks = sys_tick_counter - start ; // TODO implement a function that does this properly
502+ printf ("(took %lu ms)\n" , ticks );
510503 }
504+ } else {
505+ // uncaught exception
506+ mp_obj_print ((mp_obj_t )nlr .ret_val );
507+ printf ("\n" );
511508 }
512509 }
513510 }
@@ -532,12 +529,7 @@ bool do_file(const char *filename) {
532529 return false;
533530 }
534531
535- bool comp_ok = mp_compile (pn , false);
536- if (!comp_ok ) {
537- return false;
538- }
539-
540- mp_obj_t module_fun = rt_make_function_from_id (1 );
532+ mp_obj_t module_fun = mp_compile (pn , false);
541533 if (module_fun == mp_const_none ) {
542534 return false;
543535 }
@@ -1133,17 +1125,15 @@ int main(void) {
11331125 printf ("pars;al=%u\n" , m_get_total_bytes_allocated ());
11341126 sys_tick_delay_ms (1000 );
11351127 //parse_node_show(pn, 0);
1136- bool comp_ok = mp_compile (pn , false);
1128+ mp_obj_t module_fun = mp_compile (pn , false);
11371129 printf ("comp;al=%u\n" , m_get_total_bytes_allocated ());
11381130 sys_tick_delay_ms (1000 );
11391131
1140- if (! comp_ok ) {
1132+ if (module_fun == mp_const_none ) {
11411133 printf ("compile error\n" );
11421134 } else {
11431135 // execute it!
11441136
1145- mp_obj_t module_fun = rt_make_function_from_id (1 );
1146-
11471137 // flash once
11481138 led_state (PYB_LED_G1 , 1 );
11491139 sys_tick_delay_ms (100 );
0 commit comments