diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-25 21:59:14 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-25 22:07:25 +0100 |
commit | c9fc62072330421dbbcfa316569b51601a7f0349 (patch) | |
tree | d7044bdc0e84396822fea1e24f4220d8917ca847 /py/runtime.c | |
parent | e5a3759ff5478392f914ba7a7346da60d9735bf4 (diff) |
py: Implement compile builtin, enabled only on unix port.
This should be pretty compliant with CPython, except perhaps for some
corner cases to do with globals/locals context.
Addresses issue #879.
Diffstat (limited to 'py/runtime.c')
-rw-r--r-- | py/runtime.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c index f701e0a8d..6cb5c7e19 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1189,6 +1189,13 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i nlr_raise(module_fun); } + // for compile only + if (MICROPY_PY_BUILTINS_COMPILE && globals == NULL) { + mp_globals_set(old_globals); + mp_locals_set(old_locals); + return module_fun; + } + // complied successfully, execute it nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { |