From 2dff7ed6a2ccd25e8cfc643a90b5867875c8035d Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 5 Mar 2022 08:02:58 +0900 Subject: [PATCH] mrbc.c: add `--no-optimize` option to disable optimization; close #5661 --- mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index 7732914d7..9de756dcf 100644 --- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c @@ -25,7 +25,8 @@ struct mrbc_args { mrb_bool verbose : 1; mrb_bool remove_lv : 1; mrb_bool no_ext_ops : 1; - uint8_t flags : 4; + mrb_bool no_optimize : 1; + uint8_t flags : 2; }; static void @@ -42,6 +43,7 @@ usage(const char *name) "-s define as static variable", "--remove-lv remove local variables", "--no-ext-ops prohibit using OP_EXTs", + "--no-optimize disable peephole optimization", "--verbose run at verbose mode", "--version print the version", "--copyright print the copyright", @@ -169,6 +171,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args) args->no_ext_ops = TRUE; break; } + else if (strcmp(argv[i] + 2, "no-optimize") == 0) { + args->no_optimize = TRUE; + break; + } return -1; default: return i; @@ -224,6 +230,7 @@ load_file(mrb_state *mrb, struct mrbc_args *args) c->dump_result = TRUE; c->no_exec = TRUE; c->no_ext_ops = args->no_ext_ops; + c->no_optimize = args->no_optimize; if (input[0] == '-' && input[1] == '\0') { infile = stdin; }