summaryrefslogtreecommitdiff
path: root/insns.def
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 /insns.def
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 'insns.def')
-rw-r--r--insns.def74
1 files changed, 34 insertions, 40 deletions
diff --git a/insns.def b/insns.def
index 12cbed730d..b2f17c5fef 100644
--- a/insns.def
+++ b/insns.def
@@ -541,46 +541,6 @@ splatarray
/**
@c put
- @e check value is included in ary
- @j 配列 ary に要素 obj が入っているかどうかチェック。case/when で利用する。
- */
-DEFINE_INSN
-checkincludearray
-(VALUE flag)
-(VALUE obj, VALUE ary)
-(VALUE obj, VALUE result)
-{
- int i;
- result = Qfalse;
-
- if (!RB_TYPE_P(ary, T_ARRAY)) {
- ary = rb_Array(ary);
- }
-
- if (flag == Qtrue) {
- /* NODE_CASE */
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- /* TODO: fix me (use another method dispatch) */
- if (RTEST(rb_funcall2(RARRAY_PTR(ary)[i], idEqq, 1, &obj))) {
- result = Qtrue;
- break;
- }
- }
- }
- else {
- obj = Qfalse;
- /* NODE_WHEN */
- for (i = 0; i < RARRAY_LEN(ary); i++) {
- if (RTEST(RARRAY_PTR(ary)[i])) {
- obj = result = Qtrue;
- break;
- }
- }
- }
-}
-
-/**
- @c put
@e put new Hash.
@j 新しいハッシュをスタックトップの n 個を初期値として生成する。
n はキーと値のペアなので 2 の倍数でなければならない。
@@ -859,6 +819,40 @@ defined
/**
@c setting
+ @e check `target' matches `pattern'.
+ `flag & VM_CHECKMATCH_TYPE_MASK' describe how to check pattern.
+ VM_CHECKMATCH_TYPE_WHEN: ignore target and check pattern is truthy.
+ VM_CHECKMATCH_TYPE_CASE: check `patten === target'.
+ VM_CHECKMATCH_TYPE_RESCUE: check `pattern.kind_op?(Module) && pattern == target'.
+ if `flag & VM_CHECKMATCH_ARRAY' is not 0, then `patten' is array of patterns.
+ @j see above comments.
+ */
+DEFINE_INSN
+checkmatch
+(rb_num_t flag)
+(VALUE target, VALUE pattern)
+(VALUE result)
+{
+ result = Qfalse;
+
+ if (flag & VM_CHECKMATCH_ARRAY) {
+ int i;
+ for (i = 0; i < RARRAY_LEN(pattern); i++) {
+ if (RTEST(check_match(RARRAY_PTR(pattern)[i], target, flag & VM_CHECKMATCH_TYPE_MASK))) {
+ result = Qtrue;
+ break;
+ }
+ }
+ }
+ else {
+ if (RTEST(check_match(pattern, target, flag & VM_CHECKMATCH_TYPE_MASK))) {
+ result = Qtrue;
+ }
+ }
+}
+
+/**
+ @c setting
@e trace
@j trace 用の命令。
*/