diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-03 14:22:03 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-03 14:22:03 +0000 |
commit | 1fb031744f5584d1bd0c88d28fbe7e261832c7a8 (patch) | |
tree | 5489409a916abae056054524be162dc0d10ab80b /py | |
parent | 14f945c2cab2b44fcb75675eb1ec8eea8774660b (diff) | |
download | micropython-1fb031744f5584d1bd0c88d28fbe7e261832c7a8.tar.gz micropython-1fb031744f5584d1bd0c88d28fbe7e261832c7a8.zip |
Change mp_compile so that it returns a function object for the module.
Diffstat (limited to 'py')
-rw-r--r-- | py/builtinimport.c | 2 | ||||
-rw-r--r-- | py/compile.c | 20 | ||||
-rw-r--r-- | py/compile.h | 2 | ||||
-rw-r--r-- | py/emitbc.c | 1 | ||||
-rw-r--r-- | py/emitcpy.c | 1 | ||||
-rw-r--r-- | py/emitpass1.c | 1 |
6 files changed, 19 insertions, 8 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c index f1479ab123..47dbf21216 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -11,8 +11,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 "map.h" 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 + } } diff --git a/py/compile.h b/py/compile.h index e283442bb0..770c2524da 100644 --- a/py/compile.h +++ b/py/compile.h @@ -1 +1 @@ -bool mp_compile(mp_parse_node_t pn, bool is_repl); +mp_obj_t mp_compile(mp_parse_node_t pn, bool is_repl); diff --git a/py/emitbc.c b/py/emitbc.c index 790fe3e4e5..dc1988582c 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -9,7 +9,6 @@ #include "mpconfig.h" #include "lexer.h" #include "parse.h" -#include "compile.h" #include "scope.h" #include "runtime0.h" #include "emit.h" diff --git a/py/emitcpy.c b/py/emitcpy.c index b107c0bf11..652617cc88 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -9,7 +9,6 @@ #include "mpconfig.h" #include "lexer.h" #include "parse.h" -#include "compile.h" #include "scope.h" #include "runtime0.h" #include "emit.h" diff --git a/py/emitpass1.c b/py/emitpass1.c index 4ed0549727..1c11241e0d 100644 --- a/py/emitpass1.c +++ b/py/emitpass1.c @@ -9,7 +9,6 @@ #include "mpconfig.h" #include "lexer.h" #include "parse.h" -#include "compile.h" #include "scope.h" #include "runtime0.h" #include "emit.h" |