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

ruby-changes:10305

From: yugui <ko1@a...>
Date: Wed, 28 Jan 2009 20:10:18 +0900 (JST)
Subject: [ruby-changes:10305] Ruby:r21850 (ruby_1_9_1): merges r21660 from trunk into ruby_1_9_1.

yugui	2009-01-28 20:09:51 +0900 (Wed, 28 Jan 2009)

  New Revision: 21850

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

  Log:
    merges r21660 from trunk into ruby_1_9_1.
    * vm_eval.c, eval.c (rb_f_block_given_p): move definition of
      "iterator?" and "block_given?" to make static.
    * vm.c (vm_get_ruby_level_caller_cfp): make it static.
    * eval_intern.h, vm_insnhelper.c: move decl. of
      vm_get_ruby_level_caller_cfp()
      from eval_intern.h to vm_insnhelper.c.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/eval.c
    branches/ruby_1_9_1/eval_intern.h
    branches/ruby_1_9_1/vm.c
    branches/ruby_1_9_1/vm_eval.c
    branches/ruby_1_9_1/vm_insnhelper.c

Index: ruby_1_9_1/eval_intern.h
===================================================================
--- ruby_1_9_1/eval_intern.h	(revision 21849)
+++ ruby_1_9_1/eval_intern.h	(revision 21850)
@@ -198,7 +198,6 @@
 
 VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
 NODE *rb_vm_cref(void);
-rb_control_frame_t *vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
 VALUE rb_obj_is_proc(VALUE);
 VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
 void rb_thread_terminate_all(void);
Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 21849)
+++ ruby_1_9_1/ChangeLog	(revision 21850)
@@ -1,3 +1,14 @@
+Mon Jan 19 11:46:39 2009  Koichi Sasada  <ko1@a...>
+
+	* vm_eval.c, eval.c (rb_f_block_given_p): move definition of
+	  "iterator?" and "block_given?" to make static.
+
+	* vm.c (vm_get_ruby_level_caller_cfp): make it static.
+
+	* eval_intern.h, vm_insnhelper.c: move decl. of
+	  vm_get_ruby_level_caller_cfp()
+	  from eval_intern.h to vm_insnhelper.c.
+
 Mon Jan 19 11:27:39 2009  Koichi Sasada  <ko1@a...>
 
 	* vm.c: add a prefix "rb_" to exposed functions
Index: ruby_1_9_1/vm_eval.c
===================================================================
--- ruby_1_9_1/vm_eval.c	(revision 21849)
+++ ruby_1_9_1/vm_eval.c	(revision 21850)
@@ -1376,11 +1376,52 @@
     return ary;
 }
 
+/*
+ *  call-seq:
+ *     block_given?   => true or false
+ *     iterator?      => true or false
+ *
+ *  Returns <code>true</code> if <code>yield</code> would execute a
+ *  block in the current context. The <code>iterator?</code> form
+ *  is mildly deprecated.
+ *
+ *     def try
+ *       if block_given?
+ *         yield
+ *       else
+ *         "no block"
+ *       end
+ *     end
+ *     try                  #=> "no block"
+ *     try { "hello" }      #=> "hello"
+ *     try do "hello" end   #=> "hello"
+ */
+
+
+VALUE
+rb_f_block_given_p(void)
+{
+    rb_thread_t *th = GET_THREAD();
+    rb_control_frame_t *cfp = th->cfp;
+    cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
+
+    if (cfp != 0 &&
+	(cfp->lfp[0] & 0x02) == 0 &&
+	GC_GUARDED_PTR_REF(cfp->lfp[0])) {
+	return Qtrue;
+    }
+    else {
+	return Qfalse;
+    }
+}
+
 void
 Init_vm_eval(void)
 {
     rb_define_global_function("eval", rb_f_eval, -1);
     rb_define_global_function("local_variables", rb_f_local_variables, 0);
+    rb_define_global_function("iterator?", rb_f_block_given_p, 0);
+    rb_define_global_function("block_given?", rb_f_block_given_p, 0);
 
     rb_define_global_function("catch", rb_f_catch, -1);
     rb_define_global_function("throw", rb_f_throw, -1);
Index: ruby_1_9_1/eval.c
===================================================================
--- ruby_1_9_1/eval.c	(revision 21849)
+++ ruby_1_9_1/eval.c	(revision 21850)
@@ -548,45 +548,6 @@
     return rb_block_given_p();
 }
 
-/*
- *  call-seq:
- *     block_given?   => true or false
- *     iterator?      => true or false
- *
- *  Returns <code>true</code> if <code>yield</code> would execute a
- *  block in the current context. The <code>iterator?</code> form
- *  is mildly deprecated.
- *
- *     def try
- *       if block_given?
- *         yield
- *       else
- *         "no block"
- *       end
- *     end
- *     try                  #=> "no block"
- *     try { "hello" }      #=> "hello"
- *     try do "hello" end   #=> "hello"
- */
-
-
-VALUE
-rb_f_block_given_p(void)
-{
-    rb_thread_t *th = GET_THREAD();
-    rb_control_frame_t *cfp = th->cfp;
-    cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
-
-    if (cfp != 0 &&
-	(cfp->lfp[0] & 0x02) == 0 &&
-	GC_GUARDED_PTR_REF(cfp->lfp[0])) {
-	return Qtrue;
-    }
-    else {
-	return Qfalse;
-    }
-}
-
 VALUE rb_eThreadError;
 
 void
@@ -1070,9 +1031,6 @@
     rb_define_virtual_variable("$@", errat_getter, errat_setter);
     rb_define_virtual_variable("$!", errinfo_getter, 0);
 
-    rb_define_global_function("iterator?", rb_f_block_given_p, 0);
-    rb_define_global_function("block_given?", rb_f_block_given_p, 0);
-
     rb_define_global_function("raise", rb_f_raise, -1);
     rb_define_global_function("fail", rb_f_raise, -1);
 
Index: ruby_1_9_1/vm.c
===================================================================
--- ruby_1_9_1/vm.c	(revision 21849)
+++ ruby_1_9_1/vm.c	(revision 21850)
@@ -146,7 +146,7 @@
     return 0;
 }
 
-rb_control_frame_t *
+static rb_control_frame_t *
 vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
 {
     if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) {
Index: ruby_1_9_1/vm_insnhelper.c
===================================================================
--- ruby_1_9_1/vm_insnhelper.c	(revision 21849)
+++ ruby_1_9_1/vm_insnhelper.c	(revision 21850)
@@ -18,6 +18,8 @@
 #define INLINE inline
 #endif
 
+static rb_control_frame_t *vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
+
 static inline rb_control_frame_t *
 vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq,
 	      VALUE type, VALUE self, VALUE specval,

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

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