summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-25 02:24:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-25 02:24:33 +0000
commit8a4fb4acba170bae08b2d3c29f380b7a7983efd8 (patch)
tree18cbd90ec8ad338b847a659e65fc745b4b45f3ee /eval.c
parent165db57cdc91ba422448b1be228a9f70bff08f15 (diff)
eval.c: rb_frame_callee returns current name
* eval.c (rb_frame_callee): returns the called name of the current frame, not the previous frame. * eval.c (prev_frame_callee, prev_frame_func): rename and make static, as these are used by rb_f_method_name() and rb_f_callee_name() only. * variable.c (set_const_visibility): use the called name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/eval.c b/eval.c
index 6906a83bef..220ac1f8f0 100644
--- a/eval.c
+++ b/eval.c
@@ -914,6 +914,12 @@ rb_frame_this_func(void)
return frame_func_id(GET_THREAD()->cfp);
}
+ID
+rb_frame_callee(void)
+{
+ return frame_called_id(GET_THREAD()->cfp);
+}
+
static rb_control_frame_t *
previous_frame(rb_thread_t *th)
{
@@ -925,8 +931,8 @@ previous_frame(rb_thread_t *th)
return prev_cfp;
}
-ID
-rb_frame_callee(void)
+static ID
+prev_frame_callee(void)
{
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
if (!prev_cfp) return 0;
@@ -934,7 +940,7 @@ rb_frame_callee(void)
}
static ID
-rb_frame_caller(void)
+prev_frame_func(void)
{
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
if (!prev_cfp) return 0;
@@ -1471,9 +1477,9 @@ errat_setter(VALUE val, ID id, VALUE *var)
/*
* call-seq:
* __method__ -> symbol
- * __callee__ -> symbol
*
- * Returns the name of the current method as a Symbol.
+ * Returns the name at the definition of the current method as a
+ * Symbol.
* If called outside of a method, it returns <code>nil</code>.
*
*/
@@ -1481,7 +1487,7 @@ errat_setter(VALUE val, ID id, VALUE *var)
static VALUE
rb_f_method_name(void)
{
- ID fname = rb_frame_caller(); /* need *caller* ID */
+ ID fname = prev_frame_func(); /* need *method* ID */
if (fname) {
return ID2SYM(fname);
@@ -1491,10 +1497,19 @@ rb_f_method_name(void)
}
}
+/*
+ * call-seq:
+ * __callee__ -> symbol
+ *
+ * Returns the called name of the current method as a Symbol.
+ * If called outside of a method, it returns <code>nil</code>.
+ *
+ */
+
static VALUE
rb_f_callee_name(void)
{
- ID fname = rb_frame_callee(); /* need *callee* ID */
+ ID fname = prev_frame_callee(); /* need *callee* ID */
if (fname) {
return ID2SYM(fname);