Пример #1
0
rb_method_entry_t *
rb_method_entry_with_refinements(VALUE klass, ID id,
				 VALUE *defined_class_ptr)
{
    VALUE defined_class;
    rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);

    if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
	NODE *cref = rb_vm_cref();
	VALUE refinements = cref ? cref->nd_refinements : Qnil;

	me = rb_resolve_refined_method(refinements, me, &defined_class);
    }
    if (defined_class_ptr)
	*defined_class_ptr = defined_class;
    return me;
}
Пример #2
0
    if (!is_singleton && noex == NOEX_MODFUNC) {
	rb_add_method(rb_singleton_class(klass), id, VM_METHOD_TYPE_ISEQ, miseq, NOEX_PUBLIC);
    }
    INC_VM_STATE_VERSION();
}

#define REWIND_CFP(expr) do { \
    rb_thread_t *th__ = GET_THREAD(); \
    th__->cfp++; expr; th__->cfp--; \
} while (0)

static VALUE
m_core_define_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
{
    REWIND_CFP({
	vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 0, rb_vm_cref());
    });
    return Qnil;
}

static VALUE
m_core_define_singleton_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
{
    REWIND_CFP({
	vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 1, rb_vm_cref());
    });
    return Qnil;
}

static VALUE
m_core_set_method_alias(VALUE self, VALUE cbase, VALUE sym1, VALUE sym2)