зеркало из https://github.com/github/ruby.git
* vm.c, vm_insnhelper.c (vm_define_method): move
function place. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
456dc8bcee
Коммит
596eecd76d
|
@ -1,3 +1,8 @@
|
|||
Tue Aug 12 18:58:48 2008 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* vm.c, vm_insnhelper.c (vm_define_method): move
|
||||
function place.
|
||||
|
||||
Tue Aug 12 18:56:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,
|
||||
|
|
40
vm.c
40
vm.c
|
@ -1655,6 +1655,46 @@ m_core_undef_method(VALUE self, VALUE cbase, VALUE sym)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static void
|
||||
vm_define_method(rb_thread_t *th, VALUE obj, ID id, rb_iseq_t *miseq,
|
||||
rb_num_t is_singleton, NODE *cref)
|
||||
{
|
||||
NODE *newbody;
|
||||
VALUE klass = cref->nd_clss;
|
||||
int noex = cref->nd_visi;
|
||||
|
||||
if (NIL_P(klass)) {
|
||||
rb_raise(rb_eTypeError, "no class/module to add method");
|
||||
}
|
||||
|
||||
if (is_singleton) {
|
||||
if (FIXNUM_P(obj) || SYMBOL_P(obj)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"can't define singleton method \"%s\" for %s",
|
||||
rb_id2name(id), rb_obj_classname(obj));
|
||||
}
|
||||
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
rb_error_frozen("object");
|
||||
}
|
||||
|
||||
klass = rb_singleton_class(obj);
|
||||
noex = NOEX_PUBLIC;
|
||||
}
|
||||
|
||||
/* dup */
|
||||
COPY_CREF(miseq->cref_stack, cref);
|
||||
miseq->klass = klass;
|
||||
miseq->defined_method_id = id;
|
||||
newbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0, miseq->self, 0);
|
||||
rb_add_method(klass, id, newbody, noex);
|
||||
|
||||
if (!is_singleton && noex == NOEX_MODFUNC) {
|
||||
rb_add_method(rb_singleton_class(klass), id, newbody, NOEX_PUBLIC);
|
||||
}
|
||||
INC_VM_STATE_VERSION();
|
||||
}
|
||||
|
||||
static VALUE
|
||||
m_core_define_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
|
||||
{
|
||||
|
|
|
@ -1061,46 +1061,6 @@ vm_get_cvar_base(NODE *cref)
|
|||
return klass;
|
||||
}
|
||||
|
||||
static inline void
|
||||
vm_define_method(rb_thread_t *th, VALUE obj, ID id, rb_iseq_t *miseq,
|
||||
rb_num_t is_singleton, NODE *cref)
|
||||
{
|
||||
NODE *newbody;
|
||||
VALUE klass = cref->nd_clss;
|
||||
int noex = cref->nd_visi;
|
||||
|
||||
if (NIL_P(klass)) {
|
||||
rb_raise(rb_eTypeError, "no class/module to add method");
|
||||
}
|
||||
|
||||
if (is_singleton) {
|
||||
if (FIXNUM_P(obj) || SYMBOL_P(obj)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"can't define singleton method \"%s\" for %s",
|
||||
rb_id2name(id), rb_obj_classname(obj));
|
||||
}
|
||||
|
||||
if (OBJ_FROZEN(obj)) {
|
||||
rb_error_frozen("object");
|
||||
}
|
||||
|
||||
klass = rb_singleton_class(obj);
|
||||
noex = NOEX_PUBLIC;
|
||||
}
|
||||
|
||||
/* dup */
|
||||
COPY_CREF(miseq->cref_stack, cref);
|
||||
miseq->klass = klass;
|
||||
miseq->defined_method_id = id;
|
||||
newbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0, miseq->self, 0);
|
||||
rb_add_method(klass, id, newbody, noex);
|
||||
|
||||
if (!is_singleton && noex == NOEX_MODFUNC) {
|
||||
rb_add_method(rb_singleton_class(klass), id, newbody, NOEX_PUBLIC);
|
||||
}
|
||||
INC_VM_STATE_VERSION();
|
||||
}
|
||||
|
||||
static inline NODE *
|
||||
vm_method_search(VALUE id, VALUE klass, IC ic)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче