From 12f368d6a48d7eb35a9c802d1ae4824b876f7c74 Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 7 Oct 2013 05:12:08 +0000 Subject: [PATCH] * iseq.c, internal.h: change to public (but internal) functions * VALUE rb_iseq_path(VALUE iseqval); * VALUE rb_iseq_absolute_path(VALUE iseqval); * VALUE rb_iseq_label(VALUE iseqval); * VALUE rb_iseq_base_label(VALUE iseqval); * VALUE rb_iseq_first_lineno(VALUE iseqval); And new (temporary) function: * VALUE rb_iseq_klass(VALUE iseqval); * iseq.c. vm_core.h (int rb_iseq_first_lineno): remove function `int rb_iseq_first_lineno(const rb_iseq_t *iseq)'. Use `VALUE rb_iseq_first_lineno(VALUE iseqval)' instead. * proc.c. vm_insnhelper.c, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 +++++++++++++++++ internal.h | 6 ++++++ iseq.c | 44 +++++++++++++++++++++++--------------------- proc.c | 6 +++--- vm_core.h | 1 - vm_insnhelper.c | 2 +- vm_method.c | 2 +- 7 files changed, 51 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 625b1c5065..2c283c0225 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Mon Oct 7 14:07:45 2013 Koichi Sasada + + * iseq.c, internal.h: change to public (but internal) functions + * VALUE rb_iseq_path(VALUE iseqval); + * VALUE rb_iseq_absolute_path(VALUE iseqval); + * VALUE rb_iseq_label(VALUE iseqval); + * VALUE rb_iseq_base_label(VALUE iseqval); + * VALUE rb_iseq_first_lineno(VALUE iseqval); + And new (temporary) function: + * VALUE rb_iseq_klass(VALUE iseqval); + + * iseq.c. vm_core.h (int rb_iseq_first_lineno): remove + function `int rb_iseq_first_lineno(const rb_iseq_t *iseq)'. + Use `VALUE rb_iseq_first_lineno(VALUE iseqval)' instead. + + * proc.c. vm_insnhelper.c, vm_method.c: catch up this change. + Sun Oct 6 08:37:39 2013 Zachary Scott * lib/webrick.rb: [DOC] fix grammar in WEBrick overview [Fixes GH-413] diff --git a/internal.h b/internal.h index 7c5a42a521..f26a63dbf6 100644 --- a/internal.h +++ b/internal.h @@ -449,6 +449,12 @@ VALUE rb_io_flush_raw(VALUE, int); /* iseq.c */ VALUE rb_iseq_clone(VALUE iseqval, VALUE newcbase); +VALUE rb_iseq_path(VALUE iseqval); +VALUE rb_iseq_absolute_path(VALUE iseqval); +VALUE rb_iseq_label(VALUE iseqval); +VALUE rb_iseq_base_label(VALUE iseqval); +VALUE rb_iseq_first_lineno(VALUE iseqval); +VALUE rb_iseq_klass(VALUE iseqval); /* completely temporary fucntion */ /* load.c */ VALUE rb_get_load_path(void); diff --git a/iseq.c b/iseq.c index e600a4de6e..6336489861 100644 --- a/iseq.c +++ b/iseq.c @@ -842,8 +842,8 @@ iseq_inspect(VALUE self) * > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') * > iseq.path #=> /tmp/method.rb */ -static VALUE -iseq_path(VALUE self) +VALUE +rb_iseq_path(VALUE self) { rb_iseq_t *iseq; GetISeqPtr(self, iseq); @@ -866,8 +866,8 @@ iseq_path(VALUE self) * > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') * > iseq.absolute_path #=> /tmp/method.rb */ -static VALUE -iseq_absolute_path(VALUE self) +VALUE +rb_iseq_absolute_path(VALUE self) { rb_iseq_t *iseq; GetISeqPtr(self, iseq); @@ -897,8 +897,8 @@ iseq_absolute_path(VALUE self) * > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') * > iseq.label #=>
*/ -static VALUE -iseq_label(VALUE self) +VALUE +rb_iseq_label(VALUE self) { rb_iseq_t *iseq; GetISeqPtr(self, iseq); @@ -925,8 +925,8 @@ iseq_label(VALUE self) * > iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb') * > iseq.base_label #=>
*/ -static VALUE -iseq_base_label(VALUE self) +VALUE +rb_iseq_base_label(VALUE self) { rb_iseq_t *iseq; GetISeqPtr(self, iseq); @@ -943,14 +943,22 @@ iseq_base_label(VALUE self) * iseq.first_lineno * #=> 1 */ -static VALUE -iseq_first_lineno(VALUE self) +VALUE +rb_iseq_first_lineno(VALUE self) { rb_iseq_t *iseq; GetISeqPtr(self, iseq); return iseq->location.first_lineno; } +VALUE +rb_iseq_klass(VALUE self) +{ + rb_iseq_t *iseq; + GetISeqPtr(self, iseq); + return iseq->klass; +} + static VALUE iseq_data_to_ary(rb_iseq_t *iseq); @@ -1047,12 +1055,6 @@ iseq_to_a(VALUE self) return iseq_data_to_ary(iseq); } -int -rb_iseq_first_lineno(const rb_iseq_t *iseq) -{ - return FIX2INT(iseq->location.first_lineno); -} - /* TODO: search algorithm is brute force. this should be binary search or so. */ @@ -2259,11 +2261,11 @@ Init_ISeq(void) rb_define_method(rb_cISeq, "eval", iseq_eval, 0); /* location APIs */ - rb_define_method(rb_cISeq, "path", iseq_path, 0); - rb_define_method(rb_cISeq, "absolute_path", iseq_absolute_path, 0); - rb_define_method(rb_cISeq, "label", iseq_label, 0); - rb_define_method(rb_cISeq, "base_label", iseq_base_label, 0); - rb_define_method(rb_cISeq, "first_lineno", iseq_first_lineno, 0); + rb_define_method(rb_cISeq, "path", rb_iseq_path, 0); + rb_define_method(rb_cISeq, "absolute_path", rb_iseq_absolute_path, 0); + rb_define_method(rb_cISeq, "label", rb_iseq_label, 0); + rb_define_method(rb_cISeq, "base_label", rb_iseq_base_label, 0); + rb_define_method(rb_cISeq, "first_lineno", rb_iseq_first_lineno, 0); #if 0 /* Now, it is experimental. No discussions, no tests. */ diff --git a/proc.c b/proc.c index 9038098529..e376ea5db2 100644 --- a/proc.c +++ b/proc.c @@ -924,7 +924,7 @@ iseq_location(rb_iseq_t *iseq) if (!iseq) return Qnil; loc[0] = iseq->location.path; if (iseq->line_info_table) { - loc[1] = INT2FIX(rb_iseq_first_lineno(iseq)); + loc[1] = INT2FIX(rb_iseq_first_lineno(iseq->self)); } else { loc[1] = Qnil; @@ -1038,7 +1038,7 @@ proc_to_s(VALUE self) int first_lineno = 0; if (iseq->line_info_table) { - first_lineno = rb_iseq_first_lineno(iseq); + first_lineno = rb_iseq_first_lineno(iseq->self); } str = rb_sprintf("#<%s:%p@%"PRIsVALUE":%d%s>", cname, (void *)self, iseq->location.path, first_lineno, is_lambda); @@ -2382,7 +2382,7 @@ proc_binding(VALUE self) bind->env = proc->envval; if (RUBY_VM_NORMAL_ISEQ_P(proc->block.iseq)) { bind->path = proc->block.iseq->location.path; - bind->first_lineno = rb_iseq_first_lineno(proc->block.iseq); + bind->first_lineno = rb_iseq_first_lineno(proc->block.iseq->self); } else { bind->path = Qnil; diff --git a/vm_core.h b/vm_core.h index 39843093f3..4c6e3c250c 100644 --- a/vm_core.h +++ b/vm_core.h @@ -666,7 +666,6 @@ VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VA VALUE rb_iseq_disasm(VALUE self); int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child); const char *ruby_node_name(int node); -int rb_iseq_first_lineno(const rb_iseq_t *iseq); RUBY_EXTERN VALUE rb_cISeq; RUBY_EXTERN VALUE rb_cRubyVM; diff --git a/vm_insnhelper.c b/vm_insnhelper.c index d82cec1858..b352767922 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -131,7 +131,7 @@ argument_error(const rb_iseq_t *iseq, int miss_argc, int min_argc, int max_argc) VALUE err_line = 0; if (iseq) { - int line_no = rb_iseq_first_lineno(iseq); + int line_no = rb_iseq_first_lineno(iseq->self); err_line = rb_sprintf("%s:%d:in `%s'", RSTRING_PTR(iseq->location.path), diff --git a/vm_method.c b/vm_method.c index 8bd2b2ce56..54c024bd06 100644 --- a/vm_method.c +++ b/vm_method.c @@ -290,7 +290,7 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type, break; } if (iseq && !NIL_P(iseq->location.path)) { - int line = iseq->line_info_table ? rb_iseq_first_lineno(iseq) : 0; + int line = iseq->line_info_table ? rb_iseq_first_lineno(iseq->self) : 0; rb_compile_warning(RSTRING_PTR(iseq->location.path), line, "previous definition of %s was here", rb_id2name(old_def->original_id));