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

ruby-changes:31083

From: ko1 <ko1@a...>
Date: Mon, 7 Oct 2013 14:12:14 +0900 (JST)
Subject: [ruby-changes:31083] ko1:r43162 (trunk): * iseq.c, internal.h: change to public (but internal) functions

ko1	2013-10-07 14:12:08 +0900 (Mon, 07 Oct 2013)

  New Revision: 43162

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

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/internal.h
    trunk/iseq.c
    trunk/proc.c
    trunk/vm_core.h
    trunk/vm_insnhelper.c
    trunk/vm_method.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43161)
+++ ChangeLog	(revision 43162)
@@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Oct  7 14:07:45 2013  Koichi Sasada  <ko1@a...>
+
+	* 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  <e@z...>
 
 	* lib/webrick.rb: [DOC] fix grammar in WEBrick overview [Fixes GH-413]
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 43161)
+++ vm_core.h	(revision 43162)
@@ -666,7 +666,6 @@ VALUE rb_iseq_compile_with_option(VALUE https://github.com/ruby/ruby/blob/trunk/vm_core.h#L666
 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;
Index: iseq.c
===================================================================
--- iseq.c	(revision 43161)
+++ iseq.c	(revision 43162)
@@ -842,8 +842,8 @@ iseq_inspect(VALUE self) https://github.com/ruby/ruby/blob/trunk/iseq.c#L842
  *	> 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L866
  *	> 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L897
  *	> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
  *	> iseq.label #=> <main>
  */
-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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L925
  *	> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
  *	> iseq.base_label #=> <main>
  */
-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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L943
  *	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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1055
     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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2261
     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. */
Index: proc.c
===================================================================
--- proc.c	(revision 43161)
+++ proc.c	(revision 43162)
@@ -924,7 +924,7 @@ iseq_location(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/proc.c#L924
     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) https://github.com/ruby/ruby/blob/trunk/proc.c#L1038
 	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) https://github.com/ruby/ruby/blob/trunk/proc.c#L2382
     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;
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 43161)
+++ vm_method.c	(revision 43162)
@@ -290,7 +290,7 @@ rb_method_entry_make(VALUE klass, ID mid https://github.com/ruby/ruby/blob/trunk/vm_method.c#L290
 		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));
Index: internal.h
===================================================================
--- internal.h	(revision 43161)
+++ internal.h	(revision 43162)
@@ -449,6 +449,12 @@ VALUE rb_io_flush_raw(VALUE, int); https://github.com/ruby/ruby/blob/trunk/internal.h#L449
 
 /* 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);
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 43161)
+++ vm_insnhelper.c	(revision 43162)
@@ -131,7 +131,7 @@ argument_error(const rb_iseq_t *iseq, in https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L131
     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),

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

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