summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-17 04:25:18 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-17 04:25:18 +0000
commitebaec402a7b3ee6c88aaaaa7fa3dfb103f614a40 (patch)
tree54efcf78b8bd69a52e579853f11ea54d7dc2040c /compile.c
parent82068396594c85a3686cb73a52a57cb60745b394 (diff)
* 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
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c29
1 files changed, 23 insertions, 6 deletions
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;
}