summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-19 03:03:09 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-19 03:03:09 +0000
commit9b520ddcec94c4654ca36bbb404bf4e9569b70cc (patch)
tree5c92e6c53ea8850593e9d12a2746d923ff67e902
parentcf23d0f0f0b6f3c118a0c243e16cc9b66a81d541 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--eval.c42
-rw-r--r--eval_intern.h1
-rw-r--r--vm.c2
-rw-r--r--vm_eval.c41
-rw-r--r--vm_insnhelper.c2
6 files changed, 55 insertions, 44 deletions
diff --git a/ChangeLog b/ChangeLog
index 15922d896ff..2716683d763 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Jan 19 11:46:39 2009 Koichi Sasada <ko1@atdot.net>
+
+ * 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@atdot.net>
* vm.c: add a prefix "rb_" to exposed functions
diff --git a/eval.c b/eval.c
index 3947ed34949..b1b04985ac7 100644
--- a/eval.c
+++ b/eval.c
@@ -547,45 +547,6 @@ rb_iterator_p()
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
@@ -1069,9 +1030,6 @@ Init_eval(void)
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);
diff --git a/eval_intern.h b/eval_intern.h
index 780be527914..40f64eca060 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -198,7 +198,6 @@ NORETURN(void rb_vm_jump_tag_but_local_jump(int, VALUE));
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);
diff --git a/vm.c b/vm.c
index 75f96147dd1..a549f0280d0 100644
--- a/vm.c
+++ b/vm.c
@@ -146,7 +146,7 @@ rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp)
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)) {
diff --git a/vm_eval.c b/vm_eval.c
index 8e6bd76e9ec..e9774d2785a 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1377,11 +1377,52 @@ rb_f_local_variables(void)
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);
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 83b9e7f535b..7b4fd37979a 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -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,