diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | compile.c | 29 | ||||
-rw-r--r-- | parse.y | 22 |
3 files changed, 40 insertions, 16 deletions
@@ -1,3 +1,8 @@ +Thu May 17 13:23:38 2007 Koichi Sasada <ko1@atdot.net> + + * parse.y, compile.c (set_arguments): fix to support in-paren + parameter (ex: def foo((a, b))). + Thu May 17 13:01:52 2007 Koichi Sasada <ko1@atdot.net> * iseq.c (ruby_iseq_disasm): fix to show post arg info. @@ -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; } @@ -2689,16 +2689,11 @@ primary : literal /*%%%*/ ID id = internal_id(); ID *tbl = ALLOC_N(ID, 2); - NODE *args = NEW_ARGS(1 /* m */, 0 /* o */); - NODE *init; + NODE *args =new_args(NEW_NODE(NODE_ARGS_AUX, 0, 1 /* nd_plen */, + node_assign($2, NEW_DVAR(id))), + 0, 0, 0, 0); NODE *scope = NEW_NODE(NODE_SCOPE, tbl, $8, args); tbl[0] = 1; tbl[1] = id; - - init = node_assign($2, NEW_DVAR(id)); - args->nd_next = NEW_ARGS_AUX(0, 0); - args->nd_next->nd_next = NEW_ARGS_AUX(0, 0); - args->nd_next->nd_next->nd_next = init; - $$ = NEW_FOR(0, $5, scope); fixpos($$, $2); /*% @@ -4114,7 +4109,12 @@ f_arg_item : f_norm_arg /*%%%*/ ID tid = internal_id(); arg_var(tid); - $2->nd_value = NEW_DVAR(tid); + if (dyna_in_block()) { + $2->nd_value = NEW_DVAR(tid); + } + else { + $2->nd_value = NEW_LVAR(tid); + } $$ = NEW_ARGS_AUX(tid, 1); $$->nd_next = $2; /*% @@ -4128,11 +4128,12 @@ f_arg : f_arg_item /*%c { $$ = rb_ary_new3(1, $1); - } +n } c%*/ | f_arg ',' f_arg_item { /*%%%*/ + $$ = $1; $$->nd_plen++; $$->nd_next = block_append($$->nd_next, $3->nd_next); rb_gc_force_recycle((VALUE)$3); @@ -7928,6 +7929,7 @@ new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, ID b node = NEW_ARGS(m ? m->nd_plen : 0, o); i1 = m ? m->nd_next : 0; node->nd_next = NEW_ARGS_AUX(r, b); + if (p) { i2 = p->nd_next; node->nd_next->nd_next = NEW_ARGS_AUX(p->nd_pid, p->nd_plen); |