Hi,

At Mon, 18 Feb 2002 11:43:09 +0900,
David Alan Black <dblack / candle.superlink.net> wrote:
> > Almost agree.  But I'm not sure whether it's "correct" that
> > super() with (arglist) doesn't propagate the original arguments
> > but does the block.
> 
> Yeah, I was sort of wondering about that too.  We have:
> 
>   + args + block
>   - args + block
> 
> but no
> 
>   + args - block
>   - args - block
> 
> But I don't think super() should be "- args - block", because then we
> would still need "- args + block", and you'd have to capture the block
> and send it.  That seems sort of awkward to me.

Maybe.  But it may be a problem there's no way to call super
without a block.


Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.260 diff -u -2 -p -r1.260 eval.c --- eval.c 2002/02/15 06:14:25 1.260 +++ eval.c 2002/02/18 04:55:24 @@ -2127,4 +2127,38 @@ mvalue_to_svalue(v) } +static VALUE +call_node_super(self, node, iter) + VALUE self; + NODE *node; + int iter; +{ + VALUE result; + int argc; VALUE *argv; /* used in SETUP_ARGS */ + TMP_PROTECT; + + if (ruby_frame->last_class == 0) { + rb_name_error(ruby_frame->last_func, + "superclass method `%s' disabled", + rb_id2name(ruby_frame->last_func)); + } + if (nd_type(node) == NODE_ZSUPER) { + argc = ruby_frame->argc; + argv = ruby_frame->argv; + } + else { + BEGIN_CALLARGS; + SETUP_ARGS(node->nd_args); + END_CALLARGS; + } + + PUSH_ITER(iter?ITER_PRE:ITER_NOT); + result = rb_call(RCLASS(ruby_frame->last_class)->super, + ruby_frame->self, ruby_frame->last_func, + argc, argv, 3); + POP_ITER(); + + return result; +} + static void return_check _((void)); #define return_value(v) prot_tag->retval = (v) @@ -2683,29 +2717,5 @@ rb_eval(self, n) case NODE_SUPER: case NODE_ZSUPER: - { - int argc; VALUE *argv; /* used in SETUP_ARGS */ - TMP_PROTECT; - - if (ruby_frame->last_class == 0) { - rb_name_error(ruby_frame->last_func, - "superclass method `%s' disabled", - rb_id2name(ruby_frame->last_func)); - } - if (nd_type(node) == NODE_ZSUPER) { - argc = ruby_frame->argc; - argv = ruby_frame->argv; - } - else { - BEGIN_CALLARGS; - SETUP_ARGS(node->nd_args); - END_CALLARGS; - } - - PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT); - result = rb_call(RCLASS(ruby_frame->last_class)->super, - ruby_frame->self, ruby_frame->last_func, - argc, argv, 3); - POP_ITER(); - } + result = call_node_super(self, node, ruby_iter->iter); break; @@ -6599,5 +6609,12 @@ block_pass(self, node) if (NIL_P(block)) { - return rb_eval(self, node->nd_iter); + if (!(node = node->nd_iter)) return Qnil; + switch (nd_type(node)) { + case NODE_SUPER: + case NODE_ZSUPER: + return call_node_super(self, node, Qfalse); + default: + return rb_eval(self, node); + } } if (rb_obj_is_kind_of(block, rb_cMethod)) {
-- Nobu Nakada