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

ruby-changes:16298

From: yugui <ko1@a...>
Date: Fri, 11 Jun 2010 13:20:41 +0900 (JST)
Subject: [ruby-changes:16298] Ruby:r28270 (ruby_1_9_2): merges r28123 from trunk into ruby_1_9_2.

yugui	2010-06-11 13:20:27 +0900 (Fri, 11 Jun 2010)

  New Revision: 28270

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28270

  Log:
    merges r28123 from trunk into ruby_1_9_2.
    --
    * compile.c (iseq_compile_each): should consider block on stack,
      if block argument is passed.  [ruby-core:30534]
    
    * parse.c (arg_concat_gen): should append to nd_head, not to
      nd_iter for NODE_BLOCK_PASS.

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/compile.c
    branches/ruby_1_9_2/insns.def
    branches/ruby_1_9_2/parse.y

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28269)
+++ ruby_1_9_2/ChangeLog	(revision 28270)
@@ -1,3 +1,11 @@
+Wed Jun  2 11:40:02 2010  Yukihiro Matsumoto  <matz@r...>
+
+	* compile.c (iseq_compile_each): should consider block on stack,
+	  if block argument is passed.  [ruby-core:30534]
+
+	* parse.c (arg_concat_gen): should append to nd_head, not to
+	  nd_iter for NODE_BLOCK_PASS.
+
 Fri Jun 11 07:34:25 2010  Tanaka Akira  <akr@f...>
 
 	* time.c (find_time_t): test the result of LOCALTIME.
Index: ruby_1_9_2/insns.def
===================================================================
--- ruby_1_9_2/insns.def	(revision 28269)
+++ ruby_1_9_2/insns.def	(revision 28270)
@@ -498,6 +498,7 @@
 (VALUE ary1, VALUE ary2st)
 (VALUE ary)
 {
+    const VALUE *sp = GET_SP();
     const VALUE ary2 = ary2st;
     VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
     VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
Index: ruby_1_9_2/compile.c
===================================================================
--- ruby_1_9_2/compile.c	(revision 28269)
+++ ruby_1_9_2/compile.c	(revision 28270)
@@ -3743,6 +3743,7 @@
 	VALUE argc;
 	unsigned long flag = 0;
 	ID id = node->nd_mid;
+	int boff = 0;
 
 	/*
 	 * a[x] (op)= y
@@ -3771,15 +3772,18 @@
 	    ADD_INSN(ret, nd_line(node), putnil);
 	}
 	COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
-	if (nd_type(node->nd_args->nd_head) != NODE_ZARRAY) {
+	switch (nd_type(node->nd_args->nd_head)) {
+	  case NODE_ZARRAY:
+	    argc = INT2FIX(0);
+	    break;
+	  case NODE_BLOCK_PASS:
+	    boff = 1;
+	  default:
 	    INIT_ANCHOR(args);
 	    argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
 	    ADD_SEQ(ret, args);
 	}
-	else {
-	    argc = INT2FIX(0);
-	}
-	ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1));
+	ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1 + boff));
 	ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
 
 	if (id == 0 || id == 1) {
@@ -3808,15 +3812,27 @@
 
 	    COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
 	    if (!poped) {
-		ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
+		ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2+boff));
 	    }
 	    if (flag & VM_CALL_ARGS_SPLAT_BIT) {
 		ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
+		if (boff > 0) {
+		    ADD_INSN1(ret, nd_line(node), dupn, INT2FIX(3));
+		    ADD_INSN(ret, nd_line(node), swap);
+		    ADD_INSN(ret, nd_line(node), pop);
+		}
 		ADD_INSN(ret, nd_line(node), concatarray);
+		if (boff > 0) {
+		    ADD_INSN1(ret, nd_line(node), setn, INT2FIX(3));
+		    ADD_INSN(ret, nd_line(node), pop);
+		    ADD_INSN(ret, nd_line(node), pop);
+		}
 		ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
 			   argc, Qfalse, LONG2FIX(flag));
 	    }
 	    else {
+		if (boff > 0)
+		    ADD_INSN(ret, nd_line(node), swap);
 		ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
 			   FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
 	    }
@@ -3824,24 +3840,36 @@
 	    ADD_INSNL(ret, nd_line(node), jump, lfin);
 	    ADD_LABEL(ret, label);
 	    if (!poped) {
-		ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
+		ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2+boff));
 	    }
-	    ADD_INSN1(ret, nd_line(node), adjuststack, FIXNUM_INC(argc, 2));
+	    ADD_INSN1(ret, nd_line(node), adjuststack, FIXNUM_INC(argc, 2+boff));
 	    ADD_LABEL(ret, lfin);
 	}
 	else {
 	    COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
 	    ADD_SEND(ret, nd_line(node), ID2SYM(id), INT2FIX(1));
 	    if (!poped) {
-		ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
+		ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2+boff));
 	    }
 	    if (flag & VM_CALL_ARGS_SPLAT_BIT) {
 		ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
+		if (boff > 0) {
+		    ADD_INSN1(ret, nd_line(node), dupn, INT2FIX(3));
+		    ADD_INSN(ret, nd_line(node), swap);
+		    ADD_INSN(ret, nd_line(node), pop);
+		}
 		ADD_INSN(ret, nd_line(node), concatarray);
+		if (boff > 0) {
+		    ADD_INSN1(ret, nd_line(node), setn, INT2FIX(3));
+		    ADD_INSN(ret, nd_line(node), pop);
+		    ADD_INSN(ret, nd_line(node), pop);
+		}
 		ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
 			   argc, Qfalse, LONG2FIX(flag));
 	    }
 	    else {
+		if (boff > 0)
+		    ADD_INSN(ret, nd_line(node), swap);
 		ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
 			   FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
 	    }
Index: ruby_1_9_2/parse.y
===================================================================
--- ruby_1_9_2/parse.y	(revision 28269)
+++ ruby_1_9_2/parse.y	(revision 28270)
@@ -1953,7 +1953,12 @@
 
 			value_expr($6);
 			if (!$3) $3 = NEW_ZARRAY();
-			args = arg_concat($3, $6);
+			if (nd_type($3) == NODE_BLOCK_PASS) {
+			    args = NEW_ARGSCAT($3, $6);
+			}
+		        else {
+			    args = arg_concat($3, $6);
+		        }
 			if ($5 == tOROP) {
 			    $5 = 0;
 			}
@@ -8313,7 +8318,10 @@
     if (!node2) return node1;
     switch (nd_type(node1)) {
       case NODE_BLOCK_PASS:
-	node1->nd_iter = arg_concat(node1->nd_iter, node2);
+	if (node1->nd_head)
+	    node1->nd_head = arg_concat(node1->nd_head, node2);
+	else
+	    node1->nd_head = NEW_LIST(node2);
 	return node1;
       case NODE_ARGSPUSH:
 	if (nd_type(node2) != NODE_ARRAY) break;

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

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