summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-26 22:11:54 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-26 22:11:54 +0000
commitb65c619058864442dd7e283e1eec3093a8a7e86e (patch)
treeda7077c8f5ceb52b44eb1ad78e8d0d909a21f84c /compile.c
parent18a7dade10a06a66ba9415ee8e2cc1f0dc98d20a (diff)
compile.c (iseq_calc_param_size): hoist out of iseq_set_arguments
This will be reused for iseq loading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/compile.c b/compile.c
index 5f68113..6b3f49a 100644
--- a/compile.c
+++ b/compile.c
@@ -1120,6 +1120,43 @@ get_dyna_var_idx(rb_iseq_t *iseq, ID id, int *level, int *ls)
return idx;
}
+static void
+iseq_calc_param_size(rb_iseq_t *iseq)
+{
+ if (iseq->param.flags.has_opt ||
+ iseq->param.flags.has_post ||
+ iseq->param.flags.has_rest ||
+ iseq->param.flags.has_block ||
+ iseq->param.flags.has_kw ||
+ iseq->param.flags.has_kwrest) {
+
+ if (iseq->param.flags.has_block) {
+ iseq->param.size = iseq->param.block_start + 1;
+ }
+ else if (iseq->param.flags.has_kwrest) {
+ iseq->param.size = iseq->param.keyword->rest_start + 1;
+ }
+ else if (iseq->param.flags.has_kw) {
+ iseq->param.size = iseq->param.keyword->bits_start + 1;
+ }
+ else if (iseq->param.flags.has_post) {
+ iseq->param.size = iseq->param.post_start + iseq->param.post_num;
+ }
+ else if (iseq->param.flags.has_rest) {
+ iseq->param.size = iseq->param.rest_start + 1;
+ }
+ else if (iseq->param.flags.has_opt) {
+ iseq->param.size = iseq->param.lead_num + iseq->param.opt_num;
+ }
+ else {
+ rb_bug("unreachable");
+ }
+ }
+ else {
+ iseq->param.size = iseq->param.lead_num;
+ }
+}
+
static int
iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
{
@@ -1267,38 +1304,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
iseq->param.flags.has_block = TRUE;
}
- if (iseq->param.flags.has_opt ||
- iseq->param.flags.has_post ||
- iseq->param.flags.has_rest ||
- iseq->param.flags.has_block ||
- iseq->param.flags.has_kw ||
- iseq->param.flags.has_kwrest) {
-
- if (iseq->param.flags.has_block) {
- iseq->param.size = iseq->param.block_start + 1;
- }
- else if (iseq->param.flags.has_kwrest) {
- iseq->param.size = iseq->param.keyword->rest_start + 1;
- }
- else if (iseq->param.flags.has_kw) {
- iseq->param.size = iseq->param.keyword->bits_start + 1;
- }
- else if (iseq->param.flags.has_post) {
- iseq->param.size = iseq->param.post_start + iseq->param.post_num;
- }
- else if (iseq->param.flags.has_rest) {
- iseq->param.size = iseq->param.rest_start + 1;
- }
- else if (iseq->param.flags.has_opt) {
- iseq->param.size = iseq->param.lead_num + iseq->param.opt_num;
- }
- else {
- rb_bug("unreachable");
- }
- }
- else {
- iseq->param.size = iseq->param.lead_num;
- }
+ iseq_calc_param_size(iseq);
if (iseq->type == ISEQ_TYPE_BLOCK) {
if (iseq->param.flags.has_opt == FALSE &&