summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-19 05:58:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-19 05:58:31 +0000
commit9c065a4bfb96d9d482b54e7831e26d01ace77b0d (patch)
tree4175ed2dd4885abf62123fb33f756a3ec6025795 /ruby.c
parent2e865ba81e66c30f729e7243fb0b47f3eea39521 (diff)
ruby.c: set compile options at once
* ruby.c (process_options): set instruction compilation options at once, and set disabled options to false explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/ruby.c b/ruby.c
index 0d5137bd1f..faf3afe090 100644
--- a/ruby.c
+++ b/ruby.c
@@ -114,6 +114,22 @@ static void init_ids(struct cmdline_options *);
#define src_encoding_index GET_VM()->src_encoding_index
+enum {
+ COMPILATION_FEATURES = (
+ 0
+ | FEATURE_BIT(frozen_string_literal)
+ | FEATURE_BIT(frozen_string_literal_debug)
+ ),
+ DEFAULT_FEATURES = (
+ ~0U
+#if DISABLE_RUBYGEMS
+ & ~FEATURE_BIT(gems)
+#endif
+ & ~FEATURE_BIT(frozen_string_literal)
+ & ~FEATURE_BIT(frozen_string_literal_debug)
+ )
+};
+
static struct cmdline_options *
cmdline_options_init(struct cmdline_options *opt)
{
@@ -122,12 +138,7 @@ cmdline_options_init(struct cmdline_options *opt)
opt->src.enc.index = src_encoding_index;
opt->ext.enc.index = -1;
opt->intern.enc.index = -1;
- opt->features = ~0U;
-#if DISABLE_RUBYGEMS
- opt->features &= ~FEATURE_BIT(gems);
-#endif
- opt->features &= ~FEATURE_BIT(frozen_string_literal);
- opt->features &= ~FEATURE_BIT(frozen_string_literal_debug);
+ opt->features = DEFAULT_FEATURES;
return opt;
}
@@ -1473,15 +1484,15 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
rb_define_module("DidYouMean");
}
ruby_init_prelude();
- if (opt->features & FEATURE_BIT(frozen_string_literal)) {
- VALUE option = rb_hash_new();
- rb_hash_aset(option, ID2SYM(rb_intern_const("frozen_string_literal")), Qtrue);
- rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option);
- }
- if (opt->features & FEATURE_BIT(frozen_string_literal_debug)) {
+ if ((opt->features ^ DEFAULT_FEATURES) & COMPILATION_FEATURES) {
VALUE option = rb_hash_new();
- rb_hash_aset(option, ID2SYM(rb_intern_const("frozen_string_literal_debug")), Qtrue);
+#define SET_COMPILE_OPTION(h, o, name) \
+ rb_hash_aset((h), ID2SYM(rb_intern_const(#name)), \
+ ((o)->features & FEATURE_BIT(name) ? Qtrue : Qfalse));
+ SET_COMPILE_OPTION(option, opt, frozen_string_literal);
+ SET_COMPILE_OPTION(option, opt, frozen_string_literal_debug);
rb_funcallv(rb_cISeq, rb_intern_const("compile_option="), 1, &option);
+#undef SET_COMPILE_OPTION
}
#if UTF8_PATH
opt->script_name = str_conv_enc(opt->script_name, rb_utf8_encoding(), lenc);