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

ruby-changes:39907

From: nobu <ko1@a...>
Date: Wed, 30 Sep 2015 15:36:38 +0900 (JST)
Subject: [ruby-changes:39907] nobu:r51988 (trunk): proc.c: include symbol name

nobu	2015-09-30 15:36:11 +0900 (Wed, 30 Sep 2015)

  New Revision: 51988

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

  Log:
    proc.c: include symbol name
    
    * proc.c (proc_to_s): include the original symbol name in string
      form.

  Modified files:
    trunk/internal.h
    trunk/proc.c
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 51987)
+++ string.c	(revision 51988)
@@ -8915,8 +8915,8 @@ sym_to_sym(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L8915
     return sym;
 }
 
-static VALUE
-sym_call(VALUE args, VALUE sym, int argc, VALUE *argv, VALUE passed_proc)
+VALUE
+rb_sym_proc_call(VALUE args, VALUE sym, int argc, VALUE *argv, VALUE passed_proc)
 {
     VALUE obj;
 
@@ -8959,7 +8959,7 @@ sym_to_proc(VALUE sym) https://github.com/ruby/ruby/blob/trunk/string.c#L8959
 	return aryp[index + 1];
     }
     else {
-	proc = rb_proc_new(sym_call, (VALUE)id);
+	proc = rb_proc_new(rb_sym_proc_call, (VALUE)id);
 	rb_block_clear_env_self(proc);
 	aryp[index] = sym;
 	aryp[index + 1] = proc;
Index: proc.c
===================================================================
--- proc.c	(revision 51987)
+++ proc.c	(revision 51988)
@@ -1059,6 +1059,7 @@ proc_to_s(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L1059
     const char *cname = rb_obj_classname(self);
     const rb_iseq_t *iseq;
     const char *is_lambda;
+    const struct vm_ifunc *ifunc;
 
     GetProcPtr(self, proc);
     iseq = proc->block.iseq;
@@ -1073,6 +1074,10 @@ proc_to_s(VALUE self) https://github.com/ruby/ruby/blob/trunk/proc.c#L1074
 	str = rb_sprintf("#<%s:%p@%"PRIsVALUE":%d%s>", cname, (void *)self,
 			 iseq->body->location.path, first_lineno, is_lambda);
     }
+    else if ((ifunc = (struct vm_ifunc *)iseq)->func == rb_sym_proc_call) {
+	str = rb_sprintf("#<%s:%p(&%+"PRIsVALUE")%s>", cname, (void *)self,
+			 ID2SYM((ID)ifunc->data), is_lambda);
+    }
     else {
 	str = rb_sprintf("#<%s:%p%s>", cname, (void *)proc->block.iseq,
 			 is_lambda);
Index: internal.h
===================================================================
--- internal.h	(revision 51987)
+++ internal.h	(revision 51988)
@@ -1109,6 +1109,7 @@ VALUE rb_external_str_with_enc(VALUE str https://github.com/ruby/ruby/blob/trunk/internal.h#L1109
 #define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
 #define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
 size_t rb_str_memsize(VALUE);
+VALUE rb_sym_proc_call(VALUE args, VALUE sym, int argc, VALUE *argv, VALUE passed_proc);
 
 /* struct.c */
 VALUE rb_struct_init_copy(VALUE copy, VALUE s);

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

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