From ebaec402a7b3ee6c88aaaaa7fa3dfb103f614a40 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 17 May 2007 04:25:18 +0000 Subject: * parse.y, compile.c (set_arguments): fix to support in-paren parameter (ex: def foo((a, b))). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index a44dbafd30..568c792b44 100644 --- a/compile.c +++ b/compile.c @@ -789,9 +789,21 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) int d = iseq->local_size - iseq->local_table_size; if (nd_type(node_args) != NODE_ARGS) { - rb_bug("set_arguments: NODE_ARGS is expected, but %s", ruby_node_name(nd_type(node_args))); + rb_bug("set_arguments: NODE_ARGS is expected, but %s", + ruby_node_name(nd_type(node_args))); } + /* + * new argument infromation: + * NODE_ARGS [m: int, o: NODE_OPT_ARG, ->] + * NODE_ARGS_AUX [r: ID, b: ID, ->] + * NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*] + * optarg information: + * NODE_OPT_ARGS [idx, expr, ->] + * init arg: + * NODE_AND(m_init, p_init) + */ + iseq->argc = node_args->nd_frml; debugs(" - argc: %d\n", iseq->argc); @@ -807,10 +819,6 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) } } - if (node_init) { - COMPILE_POPED(optargs, "init arguments", node_init); - } - if (node_opt) { NODE *node = node_opt; LABEL *label; @@ -843,6 +851,15 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) iseq->arg_opts = 0; } + if (node_init) { + if (node_init->nd_1st) { /* m_init */ + COMPILE_POPED(optargs, "init arguments (m)", node_init->nd_1st); + } + if (node_init->nd_2nd) { /* p_init */ + COMPILE_POPED(optargs, "init arguments (p)", node_init->nd_2nd); + } + } + if (rest_id) { iseq->arg_rest = get_dyna_var_idx_at_raw(iseq, rest_id) + d; @@ -920,7 +937,7 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args) ADD_SEND (optargs, nd_line(node_args), ID2SYM(rb_intern("pop")), INT2FIX(0)); SET_LOCAL(iseq->arg_rest + i + 1); - } + } iseq->arg_post_len = post_len; } -- cgit v1.2.3