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

ruby-changes:36472

From: normal <ko1@a...>
Date: Tue, 25 Nov 2014 10:46:26 +0900 (JST)
Subject: [ruby-changes:36472] normal:r48554 (trunk): compile.c (iseq_build_callinfo_from_hash): hoist out

normal	2014-11-25 10:46:11 +0900 (Tue, 25 Nov 2014)

  New Revision: 48554

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

  Log:
    compile.c (iseq_build_callinfo_from_hash): hoist out
    
    iseq_build_from_ary_body indentation was too deep for my little
    terminal, so extract it so it is easier to add keyword support.
    
    * compile.c (iseq_build_callinfo_from_hash): hoist out
      (iseq_build_from_ary_body): shorten callinfo case

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48553)
+++ ChangeLog	(revision 48554)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 25 10:32:23 2014  Eric Wong  <e@8...>
+
+	* compile.c (iseq_build_callinfo_from_hash): hoist out
+	  (iseq_build_from_ary_body): shorten callinfo case
+
 Mon Nov 24 23:03:21 2014  Kouhei Sutou  <kou@c...>
 
 	* gems/bundled_gems: Update to 3.0.7.
Index: compile.c
===================================================================
--- compile.c	(revision 48553)
+++ compile.c	(revision 48554)
@@ -5766,6 +5766,31 @@ iseq_build_load_iseq(rb_iseq_t *iseq, VA https://github.com/ruby/ruby/blob/trunk/compile.c#L5766
     return iseqval;
 }
 
+static VALUE
+iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op)
+{
+    ID mid = 0;
+    int orig_argc = 0;
+    VALUE block = 0;
+    unsigned int flag = 0;
+    rb_call_info_kw_arg_t *kw_arg = 0;
+
+    if (!NIL_P(op)) {
+	VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern("mid")));
+	VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern("flag")));
+	VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern("orig_argc")));
+	VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("blockptr")));
+
+	if (!NIL_P(vmid)) mid = SYM2ID(vmid);
+	if (!NIL_P(vflag)) flag = NUM2UINT(vflag);
+	if (!NIL_P(vorig_argc)) orig_argc = FIX2INT(vorig_argc);
+	if (!NIL_P(vblock)) block = iseq_build_load_iseq(iseq, vblock);
+    }
+
+    /* TODO: support keywords */
+
+    return (VALUE)new_callinfo(iseq, mid, orig_argc, block, flag, kw_arg);
+}
 static int
 iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
 		VALUE body, struct st_table *labels_table)
@@ -5854,25 +5879,7 @@ iseq_build_from_ary_body(rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/compile.c#L5879
 			}
 			break;
 		      case TS_CALLINFO:
-			{
-			    ID mid = 0;
-			    int orig_argc = 0;
-			    VALUE block = 0;
-			    unsigned int flag = 0;
-
-			    if (!NIL_P(op)) {
-				VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern("mid")));
-				VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern("flag")));
-				VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern("orig_argc")));
-				VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("blockptr")));
-
-				if (!NIL_P(vmid)) mid = SYM2ID(vmid);
-				if (!NIL_P(vflag)) flag = NUM2UINT(vflag);
-				if (!NIL_P(vorig_argc)) orig_argc = FIX2INT(vorig_argc);
-				if (!NIL_P(vblock)) block = iseq_build_load_iseq(iseq, vblock);
-			    }
-			    argv[j] = (VALUE)new_callinfo(iseq, mid, orig_argc, block, flag, NULL /* TODO: support keywords */);
-			}
+			argv[j] = iseq_build_callinfo_from_hash(iseq, op);
 			break;
 		      case TS_ID:
 			argv[j] = rb_convert_type(op, T_SYMBOL,

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

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