summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog10
-rw-r--r--eval.c29
-rw-r--r--variable.c2
3 files changed, 33 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 419864a262..d0c5398215 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sat May 25 11:24:24 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
+
Sat May 25 08:58:23 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_quote_unprintable): check if argument is a string.
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);
diff --git a/variable.c b/variable.c
index 679dfac693..5f06a9d5ae 100644
--- a/variable.c
+++ b/variable.c
@@ -2231,7 +2231,7 @@ set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag)
if (argc == 0) {
rb_warning("%"PRIsVALUE" with no argument is just ignored",
- QUOTE_ID(rb_frame_this_func()));
+ QUOTE_ID(rb_frame_callee()));
}
for (i = 0; i < argc; i++) {