From f4f95b98d4ca0608f5b5c59d1ece23a4dccd6011 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 20 Apr 2008 05:44:47 +0000 Subject: * compile.c (iseq_compile_each): fix for splat in when and rescue. a patch from wanabe in [ruby-dev:34429]. [ruby-core:14537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ compile.c | 65 ++++++++++++++++++++++++++++++++++++++------------------------- version.h | 6 +++--- 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index f83adfb83d..a68149a328 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Apr 20 14:44:45 2008 Nobuyoshi Nakada + + * compile.c (iseq_compile_each): fix for splat in when and rescue. + a patch from wanabe in [ruby-dev:34429]. + [ruby-core:14537] + Sun Apr 20 13:55:37 2008 Tanaka Akira * io.c (copy_stream_fallback): write directly (bypassing write method) diff --git a/compile.c b/compile.c index 03e17ad05d..002ea9f262 100644 --- a/compile.c +++ b/compile.c @@ -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), diff --git a/version.h b/version.h index 5202bb1159..918fbad281 100644 --- a/version.h +++ b/version.h @@ -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[]; -- cgit v1.2.3