Sha256: 61025c821b4dc0236443651c0562a671be39c7de8df592a012423f7a2955d52c

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

#include "RubySourceSupport.h"

#include "vm_exec.h"

//	Taken from eval.c in Ruby source
//	No header, so easiest way to integrate was to copy the code and make my own header.
//	Previously declared static; otherwise unchanged

ID frame_func_id( rb_control_frame_t *cfp )
{
    rb_iseq_t *iseq = cfp->iseq;
    if (!iseq) {
		return cfp->method_id;
    }
    while (iseq) {
		if (RUBY_VM_IFUNC_P(iseq)) {
			return rb_intern("<ifunc>");
		}
		if (iseq->defined_method_id) {
			return iseq->defined_method_id;
		}
		if (iseq->local_iseq == iseq) {
			break;
		}
		iseq = iseq->parent_iseq;
    }
    return 0;
}

ID rb_frame_caller(void)
{
    rb_thread_t *th = GET_THREAD();
    rb_control_frame_t *prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp);
    /* check if prev_cfp can be accessible */
    if ((void *)(th->stack + th->stack_size) == (void *)(prev_cfp)) {
        return 0;
    }
    return frame_func_id(prev_cfp);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sender-1.0.1 ext/sender/RubySourceSupport.c