зеркало из https://github.com/github/ruby.git
Copy compile options from AST directly without intermediate Hash
This commit is contained in:
Родитель
1fbc8cdf06
Коммит
4c040fe850
24
iseq.c
24
iseq.c
|
@ -747,20 +747,15 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
|
||||||
#undef SET_COMPILE_OPTION_NUM
|
#undef SET_COMPILE_OPTION_NUM
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static rb_compile_option_t *
|
||||||
make_compile_option_from_ast(const rb_ast_body_t *ast)
|
set_compile_option_from_ast(rb_compile_option_t *option, const rb_ast_body_t *ast)
|
||||||
{
|
{
|
||||||
VALUE opt = rb_obj_hide(rb_ident_hash_new());
|
#define SET_COMPILE_OPTION(o, a, mem) \
|
||||||
if (ast->frozen_string_literal >= 0) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("frozen_string_literal"), RBOOL(ast->frozen_string_literal));
|
((a)->mem < 0 ? 0 : ((o)->mem = (a)->mem > 0))
|
||||||
if (ast->coverage_enabled >= 0) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), RBOOL(ast->coverage_enabled));
|
SET_COMPILE_OPTION(option, ast, frozen_string_literal);
|
||||||
return opt;
|
SET_COMPILE_OPTION(option, ast, coverage_enabled);
|
||||||
}
|
#undef SET_COMPILE_OPTION
|
||||||
|
return option;
|
||||||
static void
|
|
||||||
rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
|
|
||||||
{
|
|
||||||
Check_Type(opt, T_HASH);
|
|
||||||
set_compile_option_from_hash(option, opt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -919,8 +914,7 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
|
||||||
if (!option) option = &COMPILE_OPTION_DEFAULT;
|
if (!option) option = &COMPILE_OPTION_DEFAULT;
|
||||||
if (ast) {
|
if (ast) {
|
||||||
new_opt = *option;
|
new_opt = *option;
|
||||||
rb_iseq_make_compile_option(&new_opt, make_compile_option_from_ast(ast));
|
option = set_compile_option_from_ast(&new_opt, ast);
|
||||||
option = &new_opt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE script_lines = Qnil;
|
VALUE script_lines = Qnil;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче