summaryrefslogtreecommitdiff
path: root/insns.def
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
commitb2da3824c5cc03658c652ed810ee0e322bd62b80 (patch)
tree6889f0e7778c43813320ce40dadf72818d643309 /insns.def
parentd1e63172c6ecf2606ff9a947d917117eb6923436 (diff)
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 'insns.def')
-rw-r--r--insns.def22
1 files changed, 20 insertions, 2 deletions
diff --git a/insns.def b/insns.def
index 70062c983c..1b069ce37d 100644
--- a/insns.def
+++ b/insns.def
@@ -356,10 +356,11 @@ concatstrings
DEFINE_INSN
tostring
()
-(VALUE val)
+(VALUE val, VALUE str)
(VALUE val)
{
- val = rb_obj_as_string(val);
+ VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
+ val = rb_obj_as_string_result(str, val);
}
/**
@@ -1038,6 +1039,23 @@ branchnil
}
}
+/**
+ @c jump
+ @e if val is type, set PC to (PC + dst).
+ @j もし val が type ならば、PC を (PC + dst) にする。
+ */
+DEFINE_INSN
+branchiftype
+(rb_num_t type, OFFSET dst)
+(VALUE val)
+()
+{
+ if (TYPE(val) == (int)type) {
+ RUBY_VM_CHECK_INTS(th);
+ JUMP(dst);
+ }
+}
+
/**********************************************************/
/* for optimize */