[前][次][番号順一覧][スレッド一覧]

ruby-changes:36511

From: normal <ko1@a...>
Date: Thu, 27 Nov 2014 07:12:07 +0900 (JST)
Subject: [ruby-changes:36511] normal:r48593 (trunk): compile.c (iseq_calc_param_size): hoist out of iseq_set_arguments

normal	2014-11-27 07:11:54 +0900 (Thu, 27 Nov 2014)

  New Revision: 48593

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48593

  Log:
    compile.c (iseq_calc_param_size): hoist out of iseq_set_arguments
    
    This will be reused for iseq loading.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48592)
+++ ChangeLog	(revision 48593)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Nov 27 07:11:00 2014  Eric Wong  <e@8...>
+
+	* compile.c (iseq_calc_param_size): hoist out of iseq_set_arguments
+
 Wed Nov 26 22:28:12 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* include/ruby/ruby.h (rb_get_kwargs, rb_extract_keywords): export
Index: compile.c
===================================================================
--- compile.c	(revision 48592)
+++ compile.c	(revision 48593)
@@ -1120,6 +1120,43 @@ get_dyna_var_idx(rb_iseq_t *iseq, ID id, https://github.com/ruby/ruby/blob/trunk/compile.c#L1120
     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 https://github.com/ruby/ruby/blob/trunk/compile.c#L1304
 	    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 &&

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]