* compile.c (iseq_compile_each): fix splat condition in NODE_WHEN.
[Bug #2226] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2939d61f28
commit
8b261b413c
@ -1,3 +1,8 @@
|
|||||||
|
Sat Apr 17 09:19:27 2010 wanabe <s.wanabe@gmail.com>
|
||||||
|
|
||||||
|
* compile.c (iseq_compile_each): fix splat condition in NODE_WHEN.
|
||||||
|
[Bug #2226]
|
||||||
|
|
||||||
Sat Apr 17 08:57:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Apr 17 08:57:41 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/smtp.rb (Net::SMTP#rcptto_list): continue when at least
|
* lib/net/smtp.rb (Net::SMTP#rcptto_list): continue when at least
|
||||||
|
46
compile.c
46
compile.c
@ -3129,40 +3129,30 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||||||
ADD_INSNL(body_seq, nd_line(node), jump, endlabel);
|
ADD_INSNL(body_seq, nd_line(node), jump, endlabel);
|
||||||
|
|
||||||
vals = node->nd_head;
|
vals = node->nd_head;
|
||||||
if (vals && nd_type(vals) == NODE_ARRAY) {
|
if (!vals) {
|
||||||
|
rb_bug("NODE_WHEN: must be NODE_ARRAY, but 0");
|
||||||
|
}
|
||||||
|
switch (nd_type(vals)) {
|
||||||
|
case NODE_ARRAY:
|
||||||
while (vals) {
|
while (vals) {
|
||||||
val = vals->nd_head;
|
val = vals->nd_head;
|
||||||
COMPILE(ret, "when2", val);
|
COMPILE(ret, "when2", val);
|
||||||
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
||||||
vals = vals->nd_next;
|
vals = vals->nd_next;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (nd_type(vals) == NODE_SPLAT ||
|
case NODE_SPLAT:
|
||||||
nd_type(vals) == NODE_ARGSCAT ||
|
case NODE_ARGSCAT:
|
||||||
nd_type(vals) == NODE_ARGSPUSH) {
|
case NODE_ARGSPUSH:
|
||||||
|
ADD_INSN(ret, nd_line(vals), putnil);
|
||||||
NODE *val = vals->nd_head;
|
COMPILE(ret, "when2/cond splat", vals);
|
||||||
|
ADD_INSN1(ret, nd_line(vals), checkincludearray, Qfalse);
|
||||||
if (nd_type(vals) == NODE_ARGSCAT || nd_type(vals) == NODE_ARGSPUSH) {
|
ADD_INSN(ret, nd_line(vals), pop);
|
||||||
NODE *vs = vals->nd_head;
|
ADD_INSNL(ret, nd_line(vals), branchif, l1);
|
||||||
val = vals->nd_body;
|
break;
|
||||||
|
default:
|
||||||
while (vs) {
|
rb_bug("NODE_WHEN: unknown node (%s)",
|
||||||
NODE* val = vs->nd_head;
|
ruby_node_name(nd_type(vals)));
|
||||||
COMPILE(ret, "when/argscat", val);
|
|
||||||
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
|
||||||
vs = vs->nd_next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ADD_INSN(ret, nd_line(val), putnil);
|
|
||||||
COMPILE(ret, "when2/splat", val);
|
|
||||||
ADD_INSN1(ret, nd_line(val), checkincludearray, Qfalse);
|
|
||||||
ADD_INSN(ret, nd_line(val), pop);
|
|
||||||
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rb_bug("err");
|
|
||||||
}
|
}
|
||||||
node = node->nd_next;
|
node = node->nd_next;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,26 @@ class TestCase < Test::Unit::TestCase
|
|||||||
else
|
else
|
||||||
assert(false)
|
assert(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
case
|
||||||
|
when *[], false
|
||||||
|
assert(false)
|
||||||
|
else
|
||||||
|
assert(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
case
|
||||||
|
when *false, []
|
||||||
|
assert(true)
|
||||||
|
else
|
||||||
|
assert(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_raise(NameError) do
|
||||||
|
case
|
||||||
|
when false, *x, false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_deoptimization
|
def test_deoptimization
|
||||||
|
Loading…
x
Reference in New Issue
Block a user