From 66296d37745c42cf12e056a0c78a7831c4989c78 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 30 Sep 2015 06:36:11 +0000 Subject: [PATCH] proc.c: include symbol name * proc.c (proc_to_s): include the original symbol name in string form. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- internal.h | 1 + proc.c | 5 +++++ string.c | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal.h b/internal.h index 9dafcb0f264819..bd77ba864cc270 100644 --- a/internal.h +++ b/internal.h @@ -1109,6 +1109,7 @@ VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc); #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); diff --git a/proc.c b/proc.c index f01d40455ae1c9..98029d024b8a1b 100644 --- a/proc.c +++ b/proc.c @@ -1059,6 +1059,7 @@ proc_to_s(VALUE self) 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) 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); diff --git a/string.c b/string.c index 728676c1597aff..5352a6aab160be 100644 --- a/string.c +++ b/string.c @@ -8915,8 +8915,8 @@ sym_to_sym(VALUE sym) 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) 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;