ruby-changes:49306
From: k0kubun <ko1@a...>
Date: Sat, 23 Dec 2017 18:10:41 +0900 (JST)
Subject: [ruby-changes:49306] k0kubun:r61423 (trunk): iseq.c: show first_lineno on iseq inspect
k0kubun 2017-12-23 18:10:34 +0900 (Sat, 23 Dec 2017) New Revision: 61423 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61423 Log: iseq.c: show first_lineno on iseq inspect My motivation was to improve the output of `ruby --dump=insns xxx.rb`. When one file has many iseqs, it's hard to find the one I want to read. So I wanted `iseq_disasm` to show first_lineno. I unified the behavior of `iseqw_disasm` for consistency. Modified files: trunk/iseq.c Index: iseq.c =================================================================== --- iseq.c (revision 61422) +++ iseq.c (revision 61423) @@ -1035,9 +1035,10 @@ iseqw_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1035 return rb_sprintf("#<%"PRIsVALUE": uninitialized>", klass); } else { - return rb_sprintf("<%"PRIsVALUE":%"PRIsVALUE"@%"PRIsVALUE">", + return rb_sprintf("<%"PRIsVALUE":%"PRIsVALUE"@%"PRIsVALUE":%d>", klass, - iseq->body->location.label, rb_iseq_path(iseq)); + iseq->body->location.label, rb_iseq_path(iseq), + FIX2INT(rb_iseq_first_lineno(iseq))); } } @@ -1661,7 +1662,9 @@ iseq_inspect(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1662 return rb_sprintf("#<ISeq: uninitialized>"); } else { - return rb_sprintf("#<ISeq:%s@%s>", RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(rb_iseq_path(iseq))); + return rb_sprintf("#<ISeq:%s@%s:%d>", + RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(rb_iseq_path(iseq)), + FIX2INT(rb_iseq_first_lineno(iseq))); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/