aboutsummaryrefslogtreecommitdiffstats
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-07 14:39:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-07 14:39:24 +0000
commitedb6f9694c1cfc624614f9975615f02a58f867e1 (patch)
tree0b1cbe1ece7cbc5b5481376e450b32b98ac2df15 /ruby.c
parent8fa10f3086434b2503f2a836016e4760867134aa (diff)
downloadruby-edb6f9694c1cfc624614f9975615f02a58f867e1.tar.gz
ruby.c: dump option
* ruby.c (process_options): dump specified informations all, not only first one. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/ruby.c b/ruby.c
index feae61da64..5dfa252fe3 100644
--- a/ruby.c
+++ b/ruby.c
@@ -114,7 +114,9 @@ enum feature_flag_bits {
enum dump_flag_bits {
dump_version_v,
EACH_DUMPS(DEFINE_DUMP, COMMA),
- dump_flag_count
+ dump_exit_bits = (DUMP_BIT(yydebug) | DUMP_BIT(syntax) |
+ DUMP_BIT(parsetree) | DUMP_BIT(parsetree_with_comment) |
+ DUMP_BIT(insns))
};
typedef struct ruby_cmdline_options ruby_cmdline_options_t;
@@ -1447,6 +1449,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
int i = (int)proc_options(argc, argv, opt, 0);
rb_binding_t *toplevel_binding;
const struct rb_block *base_block;
+ unsigned int dump = opt->dump & dump_exit_bits;
argc -= i;
argv += i;
@@ -1647,7 +1650,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
tree = load_file(parser, opt->script_name, 1, opt);
}
ruby_set_script_name(opt->script_name);
- if (opt->dump & DUMP_BIT(yydebug)) return Qtrue;
+ if (dump & DUMP_BIT(yydebug)) {
+ dump &= ~DUMP_BIT(yydebug);
+ if (!dump) return Qtrue;
+ }
if (opt->ext.enc.index >= 0) {
enc = rb_enc_from_index(opt->ext.enc.index);
@@ -1671,9 +1677,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
process_sflag(&opt->sflag);
opt->xflag = 0;
- if (opt->dump & DUMP_BIT(syntax)) {
+ if (dump & DUMP_BIT(syntax)) {
printf("Syntax OK\n");
- return Qtrue;
+ dump &= ~DUMP_BIT(syntax);
+ if (!dump) return Qtrue;
}
if (opt->do_print) {
@@ -1687,10 +1694,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_define_global_function("chomp", rb_f_chomp, -1);
}
- if (opt->dump & DUMP_BIT(parsetree) || opt->dump & DUMP_BIT(parsetree_with_comment)) {
- rb_io_write(rb_stdout, rb_parser_dump_tree(tree, opt->dump & DUMP_BIT(parsetree_with_comment)));
+ if (dump & (DUMP_BIT(parsetree)|DUMP_BIT(parsetree_with_comment))) {
+ rb_io_write(rb_stdout, rb_parser_dump_tree(tree, dump & DUMP_BIT(parsetree_with_comment)));
rb_io_flush(rb_stdout);
- return Qtrue;
+ dump &= ~DUMP_BIT(parsetree)&~DUMP_BIT(parsetree_with_comment);
+ if (!dump) return Qtrue;
}
{
@@ -1702,11 +1710,13 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
iseq = rb_iseq_new_main(tree, opt->script_name, path, vm_block_iseq(base_block));
}
- if (opt->dump & DUMP_BIT(insns)) {
+ if (dump & DUMP_BIT(insns)) {
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
rb_io_flush(rb_stdout);
- return Qtrue;
+ dump &= ~DUMP_BIT(insns);
+ if (!dump) return Qtrue;
}
+ if (opt->dump & dump_exit_bits) return Qtrue;
rb_define_readonly_boolean("$-p", opt->do_print);
rb_define_readonly_boolean("$-l", opt->do_line);