aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/eval.c b/eval.c
index 8501f64f5c..de9f6f5785 100644
--- a/eval.c
+++ b/eval.c
@@ -753,12 +753,27 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*e_proc)(ANYARGS), VALUE
return result;
}
+static const rb_method_entry_t *
+method_entry_of_iseq(rb_control_frame_t *cfp, rb_iseq_t *iseq)
+{
+ rb_thread_t *th = GET_THREAD();
+ rb_control_frame_t *cfp_limit;
+
+ cfp_limit = (rb_control_frame_t *)(th->stack + th->stack_size);
+ while (cfp_limit > cfp) {
+ if (cfp->iseq == iseq)
+ return cfp->me;
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ }
+ return 0;
+}
+
static ID
frame_func_id(rb_control_frame_t *cfp)
{
+ const rb_method_entry_t *me_local;
rb_iseq_t *iseq = cfp->iseq;
- if (!iseq) {
- if (!cfp->me) return 0;
+ if (cfp->me) {
return cfp->me->def->original_id;
}
while (iseq) {
@@ -767,6 +782,10 @@ frame_func_id(rb_control_frame_t *cfp)
if (ifunc->nd_aid) return ifunc->nd_aid;
return rb_intern("<ifunc>");
}
+ me_local = method_entry_of_iseq(cfp, iseq);
+ if (me_local) {
+ return me_local->def->original_id;
+ }
if (iseq->defined_method_id) {
return iseq->defined_method_id;
}