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

ruby-changes:27862

From: nagachika <ko1@a...>
Date: Mon, 25 Mar 2013 01:10:50 +0900 (JST)
Subject: [ruby-changes:27862] nagachika:r39914 (ruby_2_0_0): merge revision(s) 39627: [Backport #8008]

nagachika	2013-03-25 01:10:40 +0900 (Mon, 25 Mar 2013)

  New Revision: 39914

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

  Log:
    merge revision(s) 39627: [Backport #8008]
    
    * compile.c (iseq_compile_each): pass keyword arguments to zsuper,
      with current values.  [ruby-core:53114] [Bug #8008]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/compile.c
    branches/ruby_2_0_0/test/ruby/test_super.rb
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 39913)
+++ ruby_2_0_0/ChangeLog	(revision 39914)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Mar 25 01:09:48 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (iseq_compile_each): pass keyword arguments to zsuper,
+	  with current values.  [ruby-core:53114] [Bug #8008]
+
 Mon Mar 25 01:05:15 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/objspace/objspace.c (count_nodes): count also newly added nodes,
Index: ruby_2_0_0/compile.c
===================================================================
--- ruby_2_0_0/compile.c	(revision 39913)
+++ ruby_2_0_0/compile.c	(revision 39914)
@@ -4466,6 +4466,22 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/compile.c#L4466
 			argc = INT2FIX(post_len + post_start);
 		    }
 		}
+
+		if (liseq->arg_keyword > 0) {
+		    int local_size = liseq->local_size;
+		    int idx = local_size - liseq->arg_keyword;
+		    argc++;
+		    ADD_INSN1(args, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
+		    ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
+		    ADD_SEND (args, line, ID2SYM(rb_intern("dup")), INT2FIX(0));
+		    for (i = 0; i < liseq->arg_keywords; ++i) {
+			ID id = liseq->arg_keyword_table[i];
+			idx = local_size - get_local_var_idx(liseq, id);
+			ADD_INSN1(args, line, putobject, ID2SYM(id));
+			ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
+		    }
+		    ADD_SEND(args, line, ID2SYM(id_core_hash_merge_ptr), INT2FIX(i * 2 + 1));
+		}
 	    }
 	}
 
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 39913)
+++ ruby_2_0_0/version.h	(revision 39914)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-03-25"
-#define RUBY_PATCHLEVEL 91
+#define RUBY_PATCHLEVEL 92
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_0_0/test/ruby/test_super.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_super.rb	(revision 39913)
+++ ruby_2_0_0/test/ruby/test_super.rb	(revision 39914)
@@ -7,6 +7,7 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_super.rb#L7
     def double(a, b) [a,b] end
     def array(*a) a end
     def optional(a = 0) a end
+    def keyword(**a) a end
   end
   class Single1 < Base
     def single(*) super end
@@ -50,6 +51,18 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_super.rb#L51
   class Optional5 < Base
     def array(a = 1, b = 2, *) super end
   end
+  class Keyword1 < Base
+    def keyword(foo: "keyword1") super end
+  end
+  class Keyword2 < Base
+    def keyword(foo: "keyword2")
+      foo = "changed1"
+      x = super
+      foo = "changed2"
+      y = super
+      [x, y]
+    end
+  end
 
   def test_single1
     assert_equal(1, Single1.new.single(1))
@@ -112,6 +125,14 @@ class TestSuper < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_super.rb#L125
     assert_equal([9, 8], Optional5.new.array(9, 8))
     assert_equal([9, 8, 7], Optional5.new.array(9, 8, 7))
   end
+  def test_keyword1
+    assert_equal({foo: "keyword1"}, Keyword1.new.keyword)
+    bug8008 = '[ruby-core:53114] [Bug #8008]'
+    assert_equal({foo: bug8008}, Keyword1.new.keyword(foo: bug8008))
+  end
+  def test_keyword2
+    assert_equal([{foo: "changed1"}, {foo: "changed2"}], Keyword2.new.keyword)
+  end
 
   class A
     def tt(aa)

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r39627


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

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