ruby-changes:40053
From: nobu <ko1@a...>
Date: Thu, 15 Oct 2015 23:56:26 +0900 (JST)
Subject: [ruby-changes:40053] nobu:r52134 (trunk): proc.c: void env
nobu 2015-10-15 23:56:05 +0900 (Thu, 15 Oct 2015) New Revision: 52134 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52134 Log: proc.c: void env * proc.c (rb_sym_to_proc): make void env. Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_symbol.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52133) +++ ChangeLog (revision 52134) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Oct 15 23:56:03 2015 Nobuyoshi Nakada <nobu@r...> + + * proc.c (rb_sym_to_proc): make void env. + Thu Oct 15 13:37:23 2015 Nobuyoshi Nakada <nobu@r...> * proc.c (rb_sym_to_proc): move from string.c and create a Proc Index: proc.c =================================================================== --- proc.c (revision 52133) +++ proc.c (revision 52134) @@ -57,9 +57,17 @@ proc_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/proc.c#L57 RUBY_MARK_LEAVE("proc"); } +typedef struct { + rb_proc_t basic; + VALUE env[2]; /* specval, envval */ +} sym_proc_t; + static size_t proc_memsize(const void *ptr) { + const rb_proc_t *proc = ptr; + if (proc->block.ep == ((const sym_proc_t *)ptr)->env) + return sizeof(sym_proc_t); return sizeof(rb_proc_t); } @@ -1060,9 +1068,12 @@ rb_sym_to_proc(VALUE sym) https://github.com/ruby/ruby/blob/trunk/proc.c#L1068 } else { rb_proc_t *ptr; + sym_proc_t *symproc; VALUE ifunc = (VALUE)IFUNC_NEW(rb_sym_proc_call, (VALUE)id, 0); - proc = rb_proc_alloc(rb_cProc); - ptr = RTYPEDDATA_DATA(proc); + proc = TypedData_Make_Struct(rb_cProc, sym_proc_t, &proc_data_type, symproc); + symproc->env[0] = VM_ENVVAL_BLOCK_PTR(0); + ptr = &symproc->basic; + ptr->block.ep = symproc->env; ptr->block.iseq = (rb_iseq_t *)ifunc; ptr->block.proc = ifunc; aryp[index] = sym; Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 52133) +++ test/ruby/test_symbol.rb (revision 52134) @@ -137,6 +137,7 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L137 assert_separately([], <<-"end;", timeout: 5.0) bug11566 = '[ruby-core:70980] [Bug #11566]' assert_raise(NoMethodError, bug11566) {Proc.new(&:foo).(1)} + assert_raise(NoMethodError, bug11566) {:foo.to_proc.(1)} end; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/