aboutsummaryrefslogtreecommitdiff
path: root/stm
diff options
context:
space:
mode:
authorDamien George2014-01-03 14:22:03 +0000
committerDamien George2014-01-03 14:22:03 +0000
commit1fb031744f5584d1bd0c88d28fbe7e261832c7a8 (patch)
tree5489409a916abae056054524be162dc0d10ab80b /stm
parent14f945c2cab2b44fcb75675eb1ec8eea8774660b (diff)
Change mp_compile so that it returns a function object for the module.
Diffstat (limited to 'stm')
-rw-r--r--stm/audio.c1
-rw-r--r--stm/lcd.c1
-rw-r--r--stm/main.c48
-rw-r--r--stm/pybwlan.c1
-rw-r--r--stm/timer.c1
5 files changed, 19 insertions, 33 deletions
diff --git a/stm/audio.c b/stm/audio.c
index 38e0012b4..34adefbcd 100644
--- a/stm/audio.c
+++ b/stm/audio.c
@@ -8,7 +8,6 @@
#include "misc.h"
#include "mpconfig.h"
#include "parse.h"
-#include "compile.h"
#include "obj.h"
#include "runtime.h"
diff --git a/stm/lcd.c b/stm/lcd.c
index 9f5a157d0..70d1a2642 100644
--- a/stm/lcd.c
+++ b/stm/lcd.c
@@ -5,7 +5,6 @@
#include "misc.h"
#include "mpconfig.h"
#include "parse.h"
-#include "compile.h"
#include "obj.h"
#include "runtime.h"
diff --git a/stm/main.c b/stm/main.c
index f16ce252d..e8db2be2c 100644
--- a/stm/main.c
+++ b/stm/main.c
@@ -20,8 +20,8 @@
#include "lexer.h"
#include "lexerstm.h"
#include "parse.h"
-#include "compile.h"
#include "obj.h"
+#include "compile.h"
#include "runtime0.h"
#include "runtime.h"
#include "repl.h"
@@ -489,25 +489,22 @@ void do_repl(void) {
mp_lexer_free(lex);
if (pn != MP_PARSE_NODE_NULL) {
- bool comp_ok = mp_compile(pn, true);
- if (comp_ok) {
- mp_obj_t module_fun = rt_make_function_from_id(1);
- if (module_fun != mp_const_none) {
- nlr_buf_t nlr;
- uint32_t start = sys_tick_counter;
- if (nlr_push(&nlr) == 0) {
- rt_call_function_0(module_fun);
- nlr_pop();
- // optional timing
- if (0) {
- uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly
- printf("(took %lu ms)\n", ticks);
- }
- } else {
- // uncaught exception
- mp_obj_print((mp_obj_t)nlr.ret_val);
- printf("\n");
+ mp_obj_t module_fun = mp_compile(pn, true);
+ if (module_fun != mp_const_none) {
+ nlr_buf_t nlr;
+ uint32_t start = sys_tick_counter;
+ if (nlr_push(&nlr) == 0) {
+ rt_call_function_0(module_fun);
+ nlr_pop();
+ // optional timing
+ if (0) {
+ uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly
+ printf("(took %lu ms)\n", ticks);
}
+ } else {
+ // uncaught exception
+ mp_obj_print((mp_obj_t)nlr.ret_val);
+ printf("\n");
}
}
}
@@ -532,12 +529,7 @@ bool do_file(const char *filename) {
return false;
}
- bool comp_ok = mp_compile(pn, false);
- if (!comp_ok) {
- return false;
- }
-
- mp_obj_t module_fun = rt_make_function_from_id(1);
+ mp_obj_t module_fun = mp_compile(pn, false);
if (module_fun == mp_const_none) {
return false;
}
@@ -1133,17 +1125,15 @@ soft_reset:
printf("pars;al=%u\n", m_get_total_bytes_allocated());
sys_tick_delay_ms(1000);
//parse_node_show(pn, 0);
- bool comp_ok = mp_compile(pn, false);
+ mp_obj_t module_fun = mp_compile(pn, false);
printf("comp;al=%u\n", m_get_total_bytes_allocated());
sys_tick_delay_ms(1000);
- if (!comp_ok) {
+ if (module_fun == mp_const_none) {
printf("compile error\n");
} else {
// execute it!
- mp_obj_t module_fun = rt_make_function_from_id(1);
-
// flash once
led_state(PYB_LED_G1, 1);
sys_tick_delay_ms(100);
diff --git a/stm/pybwlan.c b/stm/pybwlan.c
index 6341d0676..6988f1c84 100644
--- a/stm/pybwlan.c
+++ b/stm/pybwlan.c
@@ -18,7 +18,6 @@
#include "misc.h"
#include "lexer.h"
#include "parse.h"
-#include "compile.h"
#include "obj.h"
#include "map.h"
#include "runtime.h"
diff --git a/stm/timer.c b/stm/timer.c
index 28148b0c1..2605d4b4b 100644
--- a/stm/timer.c
+++ b/stm/timer.c
@@ -9,7 +9,6 @@
#include "misc.h"
#include "mpconfig.h"
#include "parse.h"
-#include "compile.h"
#include "obj.h"
#include "runtime.h"