summaryrefslogtreecommitdiffstatshomepage
path: root/unix/main.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-06-03 10:46:36 +0100
committerDamien George <damien.p.george@gmail.com>2014-06-03 10:46:36 +0100
commit07995e947967b7159cf88c48c2f09463015c1d45 (patch)
tree7affa52a8ac05faa07ec777a319015731a5abc73 /unix/main.c
parent509c7a7854f24c202832d8fb1369130bf8908261 (diff)
parent411732e93bcbeb529bc5f9722015b61c63eef3c5 (diff)
downloadmicropython-07995e947967b7159cf88c48c2f09463015c1d45.tar.gz
micropython-07995e947967b7159cf88c48c2f09463015c1d45.zip
Merge pull request #649 from pfalcon/multi-opt
Support multiple bytecode optimisation levels
Diffstat (limited to 'unix/main.c')
-rw-r--r--unix/main.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/unix/main.c b/unix/main.c
index 992ea1fec5..7c3fbf6aa1 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
@@ -188,6 +189,7 @@ int usage(char **argv) {
"usage: %s [<opts>] [-X <implopt>] [-c <command>] [<filename>]\n"
"Options:\n"
"-v : verbose (trace various operations); can be multiple\n"
+"-O[N] : apply bytecode optimizations of level N\n"
"\n"
"Implementation specific options:\n", argv[0]
);
@@ -346,9 +348,13 @@ int main(int argc, char **argv) {
a += 1;
} else if (strcmp(argv[a], "-v") == 0) {
mp_verbose_flag++;
- } else if (strcmp(argv[a], "-O") == 0) {
- // optimisation; sets __debug__ to False
- mp_set_debug(false);
+ } else if (strncmp(argv[a], "-O", 2) == 0) {
+ if (isdigit(argv[a][2])) {
+ mp_optimise_value = argv[a][2] & 0xf;
+ } else {
+ mp_optimise_value = 0;
+ for (char *p = argv[a] + 1; *p && *p == 'O'; p++, mp_optimise_value++);
+ }
} else {
return usage(argv);
}