summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-03 14:22:03 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-03 14:22:03 +0000
commit1fb031744f5584d1bd0c88d28fbe7e261832c7a8 (patch)
tree5489409a916abae056054524be162dc0d10ab80b /unix/main.c
parent14f945c2cab2b44fcb75675eb1ec8eea8774660b (diff)
downloadmicropython-1fb031744f5584d1bd0c88d28fbe7e261832c7a8.tar.gz
micropython-1fb031744f5584d1bd0c88d28fbe7e261832c7a8.zip
Change mp_compile so that it returns a function object for the module.
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/unix/main.c b/unix/main.c
index c23a8e54c4..1aa3331202 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -9,8 +9,8 @@
#include "lexer.h"
#include "lexerunix.h"
#include "parse.h"
-#include "compile.h"
#include "obj.h"
+#include "compile.h"
#include "runtime0.h"
#include "runtime.h"
#include "repl.h"
@@ -85,19 +85,16 @@ static void do_repl(void) {
if (pn != MP_PARSE_NODE_NULL) {
//mp_parse_node_show(pn, 0);
- 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;
- if (nlr_push(&nlr) == 0) {
- rt_call_function_0(module_fun);
- nlr_pop();
- } 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;
+ if (nlr_push(&nlr) == 0) {
+ rt_call_function_0(module_fun);
+ nlr_pop();
+ } else {
+ // uncaught exception
+ mp_obj_print((mp_obj_t)nlr.ret_val);
+ printf("\n");
}
}
}
@@ -142,7 +139,7 @@ void do_file(const char *file) {
//printf("----------------\n");
//parse_node_show(pn, 0);
//printf("----------------\n");
- bool comp_ok = mp_compile(pn, false);
+ mp_obj_t module_fun = mp_compile(pn, false);
//printf("----------------\n");
#if MICROPY_EMIT_CPYTHON
@@ -150,19 +147,16 @@ void do_file(const char *file) {
printf("compile error\n");
}
#else
- if (1 && comp_ok) {
+ if (1 && module_fun != mp_const_none) {
// execute it
- mp_obj_t module_fun = rt_make_function_from_id(1);
- if (module_fun != mp_const_none) {
- nlr_buf_t nlr;
- if (nlr_push(&nlr) == 0) {
- rt_call_function_0(module_fun);
- nlr_pop();
- } else {
- // uncaught exception
- mp_obj_print((mp_obj_t)nlr.ret_val);
- printf("\n");
- }
+ nlr_buf_t nlr;
+ if (nlr_push(&nlr) == 0) {
+ rt_call_function_0(module_fun);
+ nlr_pop();
+ } else {
+ // uncaught exception
+ mp_obj_print((mp_obj_t)nlr.ret_val);
+ printf("\n");
}
}
#endif