aboutsummaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorDamien George2019-08-23 11:20:50 +1000
committerDamien George2019-08-28 12:47:58 +1000
commitaf20c2ead3e9bb397fdf89e316aa78b56f165013 (patch)
tree99cc8c752d6347dc9f0d6dccb6e11384626bd278 /ports
parent8e3e05761e1143a2502c7eca07c1b22bac192c84 (diff)
py: Add global default_emit_opt variable to make emit kind persistent.
mp_compile no longer takes an emit_opt argument, rather this setting is now provided by the global default_emit_opt variable. Now, when -X emit=native is passed as a command-line option, the emitter will be set for all compiled modules (included imports), not just the top-level script. In the future there could be a way to also set this variable from a script. Fixes issue #4267.
Diffstat (limited to 'ports')
-rw-r--r--ports/bare-arm/main.c2
-rw-r--r--ports/javascript/main.c2
-rw-r--r--ports/minimal/main.c2
-rw-r--r--ports/nrf/main.c2
-rw-r--r--ports/qemu-arm/main.c2
-rw-r--r--ports/unix/main.c9
6 files changed, 13 insertions, 6 deletions
diff --git a/ports/bare-arm/main.c b/ports/bare-arm/main.c
index b96fb47ac..418394410 100644
--- a/ports/bare-arm/main.c
+++ b/ports/bare-arm/main.c
@@ -13,7 +13,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
qstr source_name = lex->source_name;
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
- mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
+ mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true);
mp_call_function_0(module_fun);
nlr_pop();
} else {
diff --git a/ports/javascript/main.c b/ports/javascript/main.c
index f8ef0e7c5..77b8b873a 100644
--- a/ports/javascript/main.c
+++ b/ports/javascript/main.c
@@ -46,7 +46,7 @@ int do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
qstr source_name = lex->source_name;
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
- mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, false);
+ mp_obj_t module_fun = mp_compile(&parse_tree, source_name, false);
mp_call_function_0(module_fun);
nlr_pop();
} else {
diff --git a/ports/minimal/main.c b/ports/minimal/main.c
index 5e145dc82..adc1dad0c 100644
--- a/ports/minimal/main.c
+++ b/ports/minimal/main.c
@@ -16,7 +16,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
qstr source_name = lex->source_name;
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
- mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
+ mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true);
mp_call_function_0(module_fun);
nlr_pop();
} else {
diff --git a/ports/nrf/main.c b/ports/nrf/main.c
index e1ffce938..29dd34f69 100644
--- a/ports/nrf/main.c
+++ b/ports/nrf/main.c
@@ -81,7 +81,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
if (nlr_push(&nlr) == 0) {
qstr source_name = lex->source_name;
mp_parse_tree_t pn = mp_parse(lex, input_kind);
- mp_obj_t module_fun = mp_compile(&pn, source_name, MP_EMIT_OPT_NONE, true);
+ mp_obj_t module_fun = mp_compile(&pn, source_name, true);
mp_call_function_0(module_fun);
nlr_pop();
} else {
diff --git a/ports/qemu-arm/main.c b/ports/qemu-arm/main.c
index 4cdd14828..41bf9457b 100644
--- a/ports/qemu-arm/main.c
+++ b/ports/qemu-arm/main.c
@@ -18,7 +18,7 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
qstr source_name = lex->source_name;
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
- mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
+ mp_obj_t module_fun = mp_compile(&parse_tree, source_name, true);
mp_call_function_0(module_fun);
nlr_pop();
} else {
diff --git a/ports/unix/main.c b/ports/unix/main.c
index c8f083350..65a4dd8a1 100644
--- a/ports/unix/main.c
+++ b/ports/unix/main.c
@@ -138,7 +138,7 @@ STATIC int execute_from_lexer(int source_kind, const void *source, mp_parse_inpu
}
#endif
- mp_obj_t module_fun = mp_compile(&parse_tree, source_name, emit_opt, is_repl);
+ mp_obj_t module_fun = mp_compile(&parse_tree, source_name, is_repl);
if (!compile_only) {
// execute it
@@ -456,6 +456,13 @@ MP_NOINLINE int main_(int argc, char **argv) {
mp_init();
+ #if MICROPY_EMIT_NATIVE
+ // Set default emitter options
+ MP_STATE_VM(default_emit_opt) = emit_opt;
+ #else
+ (void)emit_opt;
+ #endif
+
#if MICROPY_VFS_POSIX
{
// Mount the host FS at the root of our internal VFS