mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
2e865ba81e
commit
9c065a4bfb
1 changed files with 24 additions and 13 deletions
37
ruby.c
37
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)) {
|
||||
if ((opt->features ^ DEFAULT_FEATURES) & COMPILATION_FEATURES) {
|
||||
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)) {
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue