diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-20 05:44:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-20 05:44:47 +0000 |
commit | f4f95b98d4ca0608f5b5c59d1ece23a4dccd6011 (patch) | |
tree | b9a391b9dd1a4ae7138c7f59e37c14a8710de538 | |
parent | 01c433b58ccdbde5b488901e2accda87d931abd9 (diff) | |
download | ruby-f4f95b98d4ca0608f5b5c59d1ece23a4dccd6011.tar.gz |
* compile.c (iseq_compile_each): fix for splat in when and rescue.
a patch from wanabe <s.wanabe AT gmail.com> in [ruby-dev:34429].
[ruby-core:14537]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | compile.c | 65 | ||||
-rw-r--r-- | version.h | 6 |
3 files changed, 48 insertions, 29 deletions
@@ -1,3 +1,9 @@ +Sun Apr 20 14:44:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * compile.c (iseq_compile_each): fix for splat in when and rescue. + a patch from wanabe <s.wanabe AT gmail.com> in [ruby-dev:34429]. + [ruby-core:14537] + Sun Apr 20 13:55:37 2008 Tanaka Akira <akr@fsij.org> * io.c (copy_stream_fallback): write directly (bypassing write method) @@ -2779,26 +2779,19 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) vals = node->nd_head; if (vals) { - if (nd_type(vals) == NODE_ARRAY) { + switch (nd_type(vals)) { + case NODE_ARRAY: special_literals = when_vals(iseq, cond_seq, vals, l1, special_literals); - } - else if (nd_type(vals) == NODE_SPLAT || - nd_type(vals) == NODE_ARGSCAT || - nd_type(vals) == NODE_ARGSPUSH) { - NODE *val = vals->nd_head; + break; + case NODE_SPLAT: + case NODE_ARGSCAT: + case NODE_ARGSPUSH: special_literals = 0; - - if (nd_type(vals) == NODE_ARGSCAT || - nd_type(vals) == NODE_ARGSPUSH) { - when_vals(iseq, cond_seq, vals->nd_head, l1, 0); - val = vals->nd_body; - } - - COMPILE(cond_seq, "when/cond splat", val); - ADD_INSN1(cond_seq, nd_line(val), checkincludearray, Qtrue); - ADD_INSNL(cond_seq, nd_line(val), branchif, l1); - } - else { + COMPILE(cond_seq, "when/cond splat", vals); + ADD_INSN1(cond_seq, nd_line(vals), checkincludearray, Qtrue); + ADD_INSNL(cond_seq, nd_line(vals), branchif, l1); + break; + default: rb_bug("NODE_CASE: unknown node (%s)", ruby_node_name(nd_type(vals))); } @@ -3248,15 +3241,35 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) label_hit = NEW_LABEL(nd_line(node)); narg = resq->nd_args; - while (narg) { - COMPILE(ret, "rescue arg", narg->nd_head); - ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1), - INT2FIX(0)); - ADD_SEND(ret, nd_line(node), ID2SYM(idEqq), INT2FIX(1)); - ADD_INSNL(ret, nd_line(node), branchif, label_hit); - narg = narg->nd_next; + if (narg) { + switch (nd_type(narg)) { + case NODE_ARRAY: + while (narg) { + COMPILE(ret, "rescue arg", narg->nd_head); + ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1), + INT2FIX(0)); + ADD_SEND(ret, nd_line(node), ID2SYM(idEqq), INT2FIX(1)); + ADD_INSNL(ret, nd_line(node), branchif, label_hit); + narg = narg->nd_next; + } + break; + case NODE_SPLAT: + case NODE_ARGSCAT: + case NODE_ARGSPUSH: + ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1), + INT2FIX(0)); + COMPILE(ret, "rescue/cond splat", narg); + ADD_INSN1(ret, nd_line(node), checkincludearray, Qtrue); + ADD_INSN(ret, nd_line(node), swap); + ADD_INSN(ret, nd_line(node), pop); + ADD_INSNL(ret, nd_line(node), branchif, label_hit); + break; + default: + rb_bug("NODE_RESBODY: unknown node (%s)", + ruby_node_name(nd_type(narg))); + } } - if (resq->nd_args == 0) { + else { ADD_INSN1(ret, nd_line(node), putobject, rb_eStandardError); ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(1), @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-04-18" +#define RUBY_RELEASE_DATE "2008-04-20" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080418 +#define RUBY_RELEASE_CODE 20080420 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 18 +#define RUBY_RELEASE_DAY 20 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; |