aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-18 02:27:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-18 02:27:13 +0000
commite994503d851aa18c010dee6a1eb718c14a97276c (patch)
tree6889f0e7778c43813320ce40dadf72818d643309 /compile.c
parenta0d40a1de2d5e5ee0c121e6b6aded91b3d6c3a25 (diff)
downloadruby-e994503d851aa18c010dee6a1eb718c14a97276c.tar.gz
refinements in string interpolation
* compile.c (iseq_compile_each0): insert to_s method call, so that refinements activated at the caller should take place. [Feature #13812] * insns.def (tostring): fix up converted object to a string, infect and fallback. * insns.def (branchiftype): new instruction for conversion. branches if TOS is an instance of the given type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 5cf7f750fc..0e3abd71f7 100644
--- a/compile.c
+++ b/compile.c
@@ -6180,7 +6180,15 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp
ADD_INSN(ret, line, pop);
}
else {
+ const unsigned int flag = VM_CALL_FCALL;
+ LABEL *isstr = NEW_LABEL(line);
+ ADD_INSN(ret, line, dup);
+ ADD_INSN2(ret, line, branchiftype, INT2FIX(T_STRING), isstr);
+ LABEL_REF(isstr);
+ ADD_INSN(ret, line, dup);
+ ADD_SEND_R(ret, line, idTo_s, INT2FIX(0), NULL, INT2FIX(flag), NULL);
ADD_INSN(ret, line, tostring);
+ ADD_LABEL(ret, isstr);
}
break;
}