From de870875f773f5a680b12e5306bc316d35465fe5 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 16 Nov 2014 10:38:15 +0000 Subject: vm_eval.c: rb_current_receiver * vm_eval.c (rb_current_receiver): new function to return the receiver in the current control frame. [Feature #10195] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_eval.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vm_eval.c') diff --git a/vm_eval.c b/vm_eval.c index 0d47aacf30..0f2b19053d 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -290,6 +290,16 @@ rb_call_super(int argc, const VALUE *argv) return vm_call_super(GET_THREAD(), argc, argv); } +VALUE +rb_current_receiver(void) +{ + rb_thread_t *th = GET_THREAD(); + rb_control_frame_t *cfp; + if (!th || !(cfp = th->cfp)) + rb_raise(rb_eRuntimeError, "no self, no life"); + return cfp->self; +} + static inline void stack_check(void) { -- cgit v1.2.3