summaryrefslogtreecommitdiffstatshomepage
path: root/py/compile.c
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-03 22:55:16 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-03 22:55:16 +0000
commit97334c85d0b53ef1648eb76ec6e9e2b1efab1f97 (patch)
treed10f6b6b7ca3394e6f7dc31ca55e0df2b39abe02 /py/compile.c
parent25f417c08c2cdb5c4a7564d1e69766c0448d7984 (diff)
parentb7aa72710ee6798c6d2bc2632be24206e526fc1e (diff)
downloadmicropython-97334c85d0b53ef1648eb76ec6e9e2b1efab1f97.tar.gz
micropython-97334c85d0b53ef1648eb76ec6e9e2b1efab1f97.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'py/compile.c')
-rw-r--r--py/compile.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/py/compile.c b/py/compile.c
index b00ab7ef64..68ac20804d 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -10,9 +10,11 @@
#include "lexer.h"
#include "parse.h"
#include "scope.h"
-#include "compile.h"
#include "runtime0.h"
#include "emit.h"
+#include "obj.h"
+#include "compile.h"
+#include "runtime.h"
// TODO need to mangle __attr names
@@ -3016,7 +3018,7 @@ void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
}
}
-bool mp_compile(mp_parse_node_t pn, bool is_repl) {
+mp_obj_t mp_compile(mp_parse_node_t pn, bool is_repl) {
compiler_t *comp = m_new(compiler_t, 1);
comp->qstr___class__ = qstr_from_str_static("__class__");
@@ -3146,7 +3148,19 @@ bool mp_compile(mp_parse_node_t pn, bool is_repl) {
}
}
+ bool had_error = comp->had_error;
m_del_obj(compiler_t, comp);
- return !comp->had_error;
+ if (had_error) {
+ // TODO return a proper error message
+ return mp_const_none;
+ } else {
+#if MICROPY_EMIT_CPYTHON
+ // can't create code, so just return true
+ return mp_const_true;
+#else
+ // return function that executes the outer module
+ return rt_make_function_from_id(1);
+#endif
+ }
}