summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2023-06-17 10:21:37 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2023-06-17 16:41:08 +0900
commit19c62b400d3458c4525f174515bcb616af7dfdfe (patch)
tree59a687fc1573a545cc21f6b529724cd7821a0df8 /iseq.c
parente5ae7a16b49d4cf7c7069aeb01ed5c4e58152055 (diff)
Replace parser & node compile_option from Hash to bit field
This commit reduces dependency to CRuby object.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7950
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/iseq.c b/iseq.c
index 6d8596528e..0878ba9f84 100644
--- a/iseq.c
+++ b/iseq.c
@@ -741,6 +741,15 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
#undef SET_COMPILE_OPTION_NUM
}
+static VALUE
+make_compile_option_from_ast(const rb_ast_body_t *ast)
+{
+ VALUE opt = rb_obj_hide(rb_ident_hash_new());
+ if (ast->frozen_string_literal >= 0) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("frozen_string_literal"), RBOOL(ast->frozen_string_literal));
+ if (ast->coverage_enabled >= 0) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), RBOOL(ast->coverage_enabled));
+ return opt;
+}
+
static void
rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
{
@@ -908,7 +917,7 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
else {
new_opt = COMPILE_OPTION_DEFAULT;
}
- if (ast && ast->compile_option) rb_iseq_make_compile_option(&new_opt, ast->compile_option);
+ if (ast) rb_iseq_make_compile_option(&new_opt, make_compile_option_from_ast(ast));
VALUE script_lines = Qnil;