ruby-changes:36267
From: nobu <ko1@a...>
Date: Sun, 9 Nov 2014 23:26:10 +0900 (JST)
Subject: [ruby-changes:36267] nobu:r48348 (trunk): vm.c: super in bmethod
nobu 2014-11-09 23:25:52 +0900 (Sun, 09 Nov 2014) New Revision: 48348 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48348 Log: vm.c: super in bmethod * vm_eval.c (vm_call_super): allow bound proc method to call super method. * vm_insnhelper.c (vm_yield_with_cfunc): push defined class and bound proc method entry to the control frame. Added directories: trunk/ext/-test-/proc/ Added files: trunk/ext/-test-/proc/call_super.c trunk/ext/-test-/proc/extconf.rb trunk/ext/-test-/proc/init.c Modified files: trunk/ChangeLog trunk/vm.c trunk/vm_eval.c trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 48347) +++ ChangeLog (revision 48348) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 9 23:25:49 2014 Nobuyoshi Nakada <nobu@r...> + + * vm_eval.c (vm_call_super): allow bound proc method to call super + method. + + * vm_insnhelper.c (vm_yield_with_cfunc): push defined class and + bound proc method entry to the control frame. + + Sun Nov 9 22:46:13 2014 Tanaka Akira <akr@f...> * test/open-uri: Test server log in server thread. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 48347) +++ vm_eval.c (revision 48348) @@ -265,7 +265,7 @@ vm_call_super(rb_thread_t *th, int argc, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L265 rb_method_entry_t *me; rb_control_frame_t *cfp = th->cfp; - if (cfp->iseq || NIL_P(cfp->klass)) { + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) || NIL_P(cfp->klass)) { rb_bug("vm_call_super: should not be reached"); } Index: ext/-test-/proc/init.c =================================================================== --- ext/-test-/proc/init.c (revision 0) +++ ext/-test-/proc/init.c (revision 48348) @@ -0,0 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/proc/init.c#L1 +#include "ruby.h" + +#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);} + +void +Init_proc(void) +{ + VALUE mBug = rb_define_module("Bug"); + VALUE klass = rb_define_module_under(mBug, "Proc"); + TEST_INIT_FUNCS(init); +} Property changes on: ext/-test-/proc/init.c ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/-test-/proc/extconf.rb =================================================================== --- ext/-test-/proc/extconf.rb (revision 0) +++ ext/-test-/proc/extconf.rb (revision 48348) @@ -0,0 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/proc/extconf.rb#L1 +$INCFLAGS << " -I$(topdir) -I$(top_srcdir)" +$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] +inits = $srcs.map {|s| File.basename(s, ".*")} +inits.delete("init") +inits.map! {|s|"X(#{s})"} +$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\"" +create_makefile("-test-/proc") Property changes on: ext/-test-/proc/extconf.rb ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/-test-/proc/call_super.c =================================================================== --- ext/-test-/proc/call_super.c (revision 0) +++ ext/-test-/proc/call_super.c (revision 48348) @@ -0,0 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/proc/call_super.c#L1 +#include "ruby.h" + +static VALUE +bug_proc_call_super(VALUE yieldarg, VALUE procarg) +{ + VALUE args[2]; + args[0] = yieldarg; + args[1] = procarg; + return rb_call_super(2, args); +} + +static VALUE +bug_proc_make_caller(VALUE self, VALUE procarg) +{ + return rb_proc_new(bug_proc_call_super, procarg); +} + +void +Init_call_super(VALUE klass) +{ + rb_define_method(klass, "call_super", bug_proc_call_super, 1); + rb_define_singleton_method(klass, "make_caller", bug_proc_make_caller, 1); +} Property changes on: ext/-test-/proc/call_super.c ___________________________________________________________________ Added: svn:eol-style + LF Index: vm.c =================================================================== --- vm.c (revision 48347) +++ vm.c (revision 48348) @@ -825,7 +825,8 @@ invoke_block_from_c(rb_thread_t *th, con https://github.com/ruby/ruby/blob/trunk/vm.c#L825 return ret; } else { - return vm_yield_with_cfunc(th, block, self, argc, argv, blockptr); + return vm_yield_with_cfunc(th, block, self, defined_class, + argc, argv, blockptr); } } Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 48347) +++ vm_insnhelper.c (revision 48348) @@ -1969,7 +1969,8 @@ block_proc_is_lambda(const VALUE procval https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1969 static inline VALUE vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block, - VALUE self, int argc, const VALUE *argv, + VALUE self, VALUE defined_class, + int argc, const VALUE *argv, const rb_block_t *blockargptr) { NODE *ifunc = (NODE *) block->iseq; @@ -1998,9 +1999,10 @@ vm_yield_with_cfunc(rb_thread_t *th, con https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1999 blockarg = Qnil; } - vm_push_frame(th, (rb_iseq_t *)ifunc, VM_FRAME_MAGIC_IFUNC, self, - 0, VM_ENVVAL_PREV_EP_PTR(block->ep), 0, - th->cfp->sp, 1, 0, 0); + vm_push_frame(th, (rb_iseq_t *)ifunc, VM_FRAME_MAGIC_IFUNC, + self, defined_class, + VM_ENVVAL_PREV_EP_PTR(block->ep), 0, + th->cfp->sp, 1, th->passed_bmethod_me, 0); val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg); @@ -2065,7 +2067,8 @@ vm_invoke_block(rb_thread_t *th, rb_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2067 else { VALUE val; CALLER_SETUP_ARG(th->cfp, ci); - val = vm_yield_with_cfunc(th, block, block->self, ci->argc, STACK_ADDR_FROM_TOP(ci->argc), 0); + val = vm_yield_with_cfunc(th, block, block->self, block->klass, + ci->argc, STACK_ADDR_FROM_TOP(ci->argc), 0); POPN(ci->argc); /* TODO: should put before C/yield? */ return val; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/