diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-06 11:48:15 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-06 11:48:15 +0100 |
commit | 65cad12d388423f7d9b04a5ae3d7c1b5b176a2da (patch) | |
tree | f88eeb76a6ccb42931ab7b887507e41c695887e3 /unix/main.c | |
parent | deed087e2c083821f22a849fdb4de62004bd010f (diff) | |
download | micropython-65cad12d388423f7d9b04a5ae3d7c1b5b176a2da.tar.gz micropython-65cad12d388423f7d9b04a5ae3d7c1b5b176a2da.zip |
py: Add option to compiler to specify default code emitter.
Also add command line option to unix port to select emitter.
Diffstat (limited to 'unix/main.c')
-rw-r--r-- | unix/main.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/unix/main.c b/unix/main.c index b4a1646c28..3ebd9ab82b 100644 --- a/unix/main.c +++ b/unix/main.c @@ -28,6 +28,9 @@ #include <readline/history.h> #endif +// Default emit options +uint emit_opt = MP_EMIT_OPT_NONE; + #if MICROPY_ENABLE_GC // Heap size of GC heap (if enabled) // Make it larger on a 64 bit machine, because pointers are larger. @@ -76,7 +79,7 @@ STATIC void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind printf("----------------\n"); */ - mp_obj_t module_fun = mp_compile(pn, source_name, is_repl); + mp_obj_t module_fun = mp_compile(pn, source_name, emit_opt, is_repl); if (module_fun == mp_const_none) { // compile error @@ -221,6 +224,10 @@ int usage(char **argv) { "Implementation specific options:\n", argv[0] ); int impl_opts_cnt = 0; + printf( +" emit={bytecode,native,viper} -- set the default code emitter\n" +); + impl_opts_cnt++; #if MICROPY_ENABLE_GC printf( " heapsize=<n> -- set the heap size for the GC\n" @@ -265,6 +272,12 @@ void pre_process_options(int argc, char **argv) { exit(usage(argv)); } if (0) { + } else if (strcmp(argv[a + 1], "emit=bytecode") == 0) { + emit_opt = MP_EMIT_OPT_BYTE_CODE; + } else if (strcmp(argv[a + 1], "emit=native") == 0) { + emit_opt = MP_EMIT_OPT_NATIVE_PYTHON; + } else if (strcmp(argv[a + 1], "emit=viper") == 0) { + emit_opt = MP_EMIT_OPT_VIPER; #if MICROPY_ENABLE_GC } else if (strncmp(argv[a + 1], "heapsize=", sizeof("heapsize=") - 1) == 0) { heap_size = strtol(argv[a + 1] + sizeof("heapsize=") - 1, NULL, 0); |