summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-20 23:49:31 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-20 23:49:31 +0000
commitba772af0a6b36713077799e5c5cbcb375d4ee1c8 (patch)
treefdd4d99a31b59f1bd4f08b5ec7d0b7537339a1c8 /compile.c
parent894352164853a4851f215d1f082a1627c80a43ea (diff)
* compile.c (iseq_compile_each): add debug information to NODE_STR
strings as default. [Feature #11725] * insns.def (freezestring): add new instruction to support adding debug information for dynamically constracted strings. * compile.c (iseq_compile_each): support adding debug information for NODE_DSTR with freezestring instruction. * error.c (rb_error_frozen): change the debug information ID name id_debug_created_info and this field should have a 2 element array containing path and line information. * defs/id.def: ditto. * test/ruby/test_rubyoptions.rb: catch up this fix. * test/ruby/test_iseq.rb: now frozen strings are not same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/compile.c b/compile.c
index e5ec768c94..dfd4330209 100644
--- a/compile.c
+++ b/compile.c
@@ -5233,15 +5233,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN1(ret, line, putstring, node->nd_lit);
}
else {
- if (!iseq->compile_data->option->frozen_string_literal_debug) {
- ADD_INSN1(ret, line, putobject, node->nd_lit); /* already frozen */
- }
- else {
- VALUE str = rb_str_dup(node->nd_lit);
- rb_ivar_set(str, id_debug_created_path, iseq->body->location.path);
- rb_ivar_set(str, id_debug_created_line, INT2FIX(line));
- ADD_INSN1(ret, line, putobject, rb_obj_freeze(str));
- }
+ VALUE str = rb_str_dup(node->nd_lit);
+ VALUE debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line));
+ rb_ivar_set(str, id_debug_created_info, rb_obj_freeze(debug_info));
+ ADD_INSN1(ret, line, putobject, rb_obj_freeze(str));
+ iseq_add_mark_object_compile_time(iseq, str);
}
}
break;
@@ -5254,7 +5250,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
else {
if (iseq->compile_data->option->frozen_string_literal) {
- ADD_SEND (ret, line, idFreeze, INT2FIX(0));
+ VALUE debug_info = Qnil;
+ if (iseq->compile_data->option->frozen_string_literal_debug || RTEST(ruby_debug)) {
+ debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line));
+ iseq_add_mark_object_compile_time(iseq, rb_obj_freeze(debug_info));
+ }
+ ADD_INSN1(ret, line, freezestring, debug_info);
}
}
break;