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

ruby-changes:26257

From: usa <ko1@a...>
Date: Tue, 11 Dec 2012 17:51:38 +0900 (JST)
Subject: [ruby-changes:26257] usa:r38314 (ruby_1_9_3): [Backport #5634]

usa	2012-12-11 17:51:25 +0900 (Tue, 11 Dec 2012)

  New Revision: 38314

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

  Log:
    [Backport #5634]
    
    * vm.c (rb_vm_make_env_object): make Proc object if Env is possible
      to point block. [ruby-core:41038] [ruby-trunk - Bug #5634]
    
    * vm.c (rb_vm_make_proc): No need to make Proc object here.
    
    * bootstraptest/test_proc.rb: add tests.

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/bootstraptest/test_proc.rb
    branches/ruby_1_9_3/version.h
    branches/ruby_1_9_3/vm.c

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 38313)
+++ ruby_1_9_3/ChangeLog	(revision 38314)
@@ -1,3 +1,12 @@
+Tue Dec 11 17:49:45 2012  Koichi Sasada  <ko1@a...>
+
+	* vm.c (rb_vm_make_env_object): make Proc object if Env is possible
+	  to point block. [ruby-core:41038] [ruby-trunk - Bug #5634]
+
+	* vm.c (rb_vm_make_proc): No need to make Proc object here.
+
+	* bootstraptest/test_proc.rb: add tests.
+
 Tue Dec 11 17:47:01 2012  Narihiro Nakamura  <authornari@g...>
 
 	* lib/irb/magic-file.rb: set a encoding, which is detected from
Index: ruby_1_9_3/bootstraptest/test_proc.rb
===================================================================
--- ruby_1_9_3/bootstraptest/test_proc.rb	(revision 38313)
+++ ruby_1_9_3/bootstraptest/test_proc.rb	(revision 38314)
@@ -456,3 +456,27 @@
   end
 }
 
+assert_equal 'ok', %q{
+  def x
+    binding
+  end
+  b = x{|a| a }
+  b.eval('yield("ok")')
+}, '[Bug #5634]'
+
+assert_equal 'ok', %q{
+  def x
+    binding
+  end
+  eval("x { 'ok' }").eval "yield"
+}, '[Bug #5634]'
+
+assert_equal 'ok', %q{
+  def x
+    binding
+  end
+  def m
+    x{ 'ok' }
+  end
+  eval('yield', m)
+}, '[Bug #5634]'
Index: ruby_1_9_3/vm.c
===================================================================
--- ruby_1_9_3/vm.c	(revision 38313)
+++ ruby_1_9_3/vm.c	(revision 38314)
@@ -467,16 +467,30 @@
     }
 }
 
+static VALUE vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block);
+
 VALUE
 rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp)
 {
     VALUE envval;
+    VALUE *lfp;
+    rb_block_t *blockptr;
 
     if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_FINISH) {
 	/* for method_missing */
 	cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
     }
 
+    lfp = cfp->lfp;
+    blockptr = GC_GUARDED_PTR_REF(lfp[0]);
+
+    if (blockptr && !(lfp[0] & 0x02)) {
+	VALUE blockprocval = vm_make_proc_from_block(th, blockptr);
+	rb_proc_t *p;
+	GetProcPtr(blockprocval, p);
+	lfp[0] = GC_GUARDED_PTR(&p->block);
+    }
+
     envval = vm_make_env_each(th, cfp, cfp->dfp, cfp->lfp);
     rb_vm_rewrite_dfp_in_errinfo(th);
 
@@ -545,16 +559,6 @@
 	rb_bug("rb_vm_make_proc: Proc value is already created.");
     }
 
-    if (GC_GUARDED_PTR_REF(cfp->lfp[0])) {
-	rb_proc_t *p;
-
-	blockprocval = vm_make_proc_from_block(
-	    th, (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp));
-
-	GetProcPtr(blockprocval, p);
-	*cfp->lfp = GC_GUARDED_PTR(&p->block);
-    }
-
     envval = rb_vm_make_env_object(th, cfp);
 
     if (PROCDEBUG) {
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 38313)
+++ ruby_1_9_3/version.h	(revision 38314)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 333
+#define RUBY_PATCHLEVEL 334
 
 #define RUBY_RELEASE_DATE "2012-12-11"
 #define RUBY_RELEASE_YEAR 2012

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

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