summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-08 07:52:19 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-08 07:52:19 +0000
commit93b6f8d6195564d0884ee00f536a951f4c26288c (patch)
treeab922f8c850c7dda9d155e52b078026b6006dcb3 /vm_insnhelper.c
parent8637eac4066dedd2c716f385e22a9d31100b68c7 (diff)
* compile.c, insns.def (checkmatch):
remove checkincludearray instruction and add new instruction checkmatch. This change is to solve [Bug #4438] "rescue args type check omitted". * iseq.c: increment ISEQ_MAJOR_VERSION because removal of checkincludearray instruction. * vm_core.h: add several definitions for the checkmatch instruction. * vm_insnhelper.c (check_match): added. * bootstraptest/test_exception.rb: add a test. * test/ruby/test_exception.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index b9c5e115c1..bb39b848cf 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1848,3 +1848,22 @@ rb_vm_using_modules(NODE *cref, VALUE klass)
}
}
+static VALUE
+check_match(VALUE pattern, VALUE target, enum vm_check_match_type type)
+{
+ switch (type) {
+ case VM_CHECKMATCH_TYPE_WHEN:
+ return pattern;
+ case VM_CHECKMATCH_TYPE_CASE:
+ return rb_funcall2(pattern, idEqq, 1, &target);
+ case VM_CHECKMATCH_TYPE_RESCUE: {
+ if (!rb_obj_is_kind_of(pattern, rb_cModule)) {
+ rb_raise(rb_eTypeError, "class or module required for rescue clause");
+ }
+ return RTEST(rb_funcall2(pattern, idEqq, 1, &target));
+ }
+ default:
+ rb_bug("check_match: unreachable");
+ }
+}
+