[前][次][番号順一覧][スレッド一覧]

ruby-changes:4599

From: ko1@a...
Date: Sun, 20 Apr 2008 14:45:01 +0900 (JST)
Subject: [ruby-changes:4599] nobu - Ruby:r16093 (trunk): * compile.c (iseq_compile_each): fix for splat in when and rescue.

nobu	2008-04-20 14:44:47 +0900 (Sun, 20 Apr 2008)

  New Revision: 16093

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/version.h

  Log:
    * 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]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=16093&r2=16092&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/compile.c?r1=16093&r2=16092&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16093&r2=16092&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16092)
+++ ChangeLog	(revision 16093)
@@ -1,3 +1,9 @@
+Sun Apr 20 14:44:45 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@f...>
 
 	* io.c (copy_stream_fallback): write directly (bypassing write method)
Index: compile.c
===================================================================
--- compile.c	(revision 16092)
+++ compile.c	(revision 16093)
@@ -2779,26 +2779,19 @@
 
 	    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 @@
 	    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),
Index: version.h
===================================================================
--- version.h	(revision 16092)
+++ version.h	(revision 16093)
@@ -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[];

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]