aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-25 16:05:17 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-25 16:05:17 +0000
commited4e57690c9cc782ab8675c4bf48153ce0a36896 (patch)
tree5cdf90849da2ef0e17458f17b2d8358929c7a7d2 /compile.c
parent588e79f7688c9b7f085cb8d46b9289e4769f4135 (diff)
downloadruby-ed4e57690c9cc782ab8675c4bf48153ce0a36896.tar.gz
* insnhelper.ci, vm.c: complete block parameter support.
post arguments, optional arguments, block argument. * compile.c, parse.y: fix {|a|} parameter. * insnshelper.ci, insns.def: revert caller_setup_args() option (need_block_check) parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index e84cc827ad..5d4ed1b785 100644
--- a/compile.c
+++ b/compile.c
@@ -774,6 +774,7 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
NODE *node_aux = node_args->nd_next;
NODE *node_opt = node_args->nd_opt;
ID rest_id = 0;
+ int last_comma = 0;
ID block_id = 0;
NODE *node_init = 0;
@@ -784,13 +785,14 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *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*]
+ * 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, ->]
+ * NODE_OPT_ARGS [idx, expr, next ->]
* init arg:
* NODE_AND(m_init, p_init)
+ * if "r" is 1, it's means "{|x,|}" type block parameter.
*/
iseq->argc = node_args->nd_frml;
@@ -798,6 +800,10 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
if (node_aux) {
rest_id = node_aux->nd_rest;
+ if (rest_id == 1) {
+ last_comma = 1;
+ rest_id = 0;
+ }
block_id = (ID)node_aux->nd_body;
node_aux = node_aux->nd_next;
@@ -891,7 +897,18 @@ set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
iseq->arg_simple = 1;
iseq->arg_size = iseq->argc;
}
+
+ if (iseq->type == ISEQ_TYPE_BLOCK) {
+ if (iseq->argc == 1 && iseq->arg_simple == 1 && last_comma == 0) {
+ /* {|a|} */
+ iseq->arg_simple = 2;
+ }
+ }
}
+ else {
+ iseq->arg_simple = 1;
+ }
+
return COMPILE_OK;
}