diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-13 18:01:59 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-13 18:01:59 +0000 |
commit | b73e900f50e74504c48f05811dbfb2aabdf40cdc (patch) | |
tree | eb307802dff370bdef006b8faf49b64be2820d80 | |
parent | 25f5dd6799bbacc9f61d60b87b70ea6e6d815c20 (diff) | |
download | ruby-b73e900f50e74504c48f05811dbfb2aabdf40cdc.tar.gz |
* vm.c (vm_define_method): refactoring.
* get CREF in this function.
* cbase is no longer needed (CREF_CLASS(cref) is enough).
* compile.c: RubyVM::FrozenCore.define_method only accept 2 args.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | compile.c | 3 | ||||
-rw-r--r-- | vm.c | 14 |
3 files changed, 16 insertions, 9 deletions
@@ -1,3 +1,11 @@ +Sat Nov 14 02:58:03 2015 Koichi Sasada <ko1@atdot.net> + + * vm.c (vm_define_method): refactoring. + * get CREF in this function. + * cbase is no longer needed (CREF_CLASS(cref) is enough). + + * compile.c: RubyVM::FrozenCore.define_method only accept 2 args. + Sat Nov 14 02:34:43 2015 Koichi Sasada <ko1@atdot.net> * vm.c (vm_define_method): do not use current CREF immediately, @@ -5258,10 +5258,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) debugp_param("defn/iseq", (VALUE)method_iseq); ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE)); - ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE)); ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid)); ADD_INSN1(ret, line, putiseq, method_iseq); - ADD_SEND (ret, line, id_core_define_method, INT2FIX(3)); + ADD_SEND (ret, line, id_core_define_method, INT2FIX(2)); if (poped) { ADD_INSN(ret, line, pop); @@ -2337,14 +2337,14 @@ rb_thread_alloc(VALUE klass) } static void -vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, - rb_num_t is_singleton, rb_cref_t *cref) +vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, int is_singleton) { VALUE klass; rb_method_visibility_t visi; + rb_cref_t *cref = rb_vm_cref(); if (!is_singleton) { - klass = obj; + klass = CREF_CLASS(cref); visi = rb_scope_visibility_get(); } else { /* singleton */ @@ -2374,10 +2374,10 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, } while (0) static VALUE -m_core_define_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval) +m_core_define_method(VALUE self, VALUE sym, VALUE iseqval) { REWIND_CFP({ - vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 0, rb_vm_cref()); + vm_define_method(GET_THREAD(), Qnil, SYM2ID(sym), iseqval, FALSE); }); return sym; } @@ -2386,7 +2386,7 @@ 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()); + vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, TRUE); }); return sym; } @@ -2586,7 +2586,7 @@ Init_VM(void) rb_define_method_id(klass, id_core_set_method_alias, m_core_set_method_alias, 3); rb_define_method_id(klass, id_core_set_variable_alias, m_core_set_variable_alias, 2); rb_define_method_id(klass, id_core_undef_method, m_core_undef_method, 2); - rb_define_method_id(klass, id_core_define_method, m_core_define_method, 3); + rb_define_method_id(klass, id_core_define_method, m_core_define_method, 2); rb_define_method_id(klass, id_core_define_singleton_method, m_core_define_singleton_method, 3); rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 0); rb_define_method_id(klass, id_core_hash_from_ary, m_core_hash_from_ary, 1); |