1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
ko1 2015-11-13 18:01:59 +00:00
parent 25f5dd6799
commit b73e900f50
3 changed files with 16 additions and 9 deletions

View file

@ -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> Sat Nov 14 02:34:43 2015 Koichi Sasada <ko1@atdot.net>
* vm.c (vm_define_method): do not use current CREF immediately, * vm.c (vm_define_method): do not use current CREF immediately,

View file

@ -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); 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_VMCORE));
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid)); ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid));
ADD_INSN1(ret, line, putiseq, method_iseq); 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) { if (poped) {
ADD_INSN(ret, line, pop); ADD_INSN(ret, line, pop);

14
vm.c
View file

@ -2337,14 +2337,14 @@ rb_thread_alloc(VALUE klass)
} }
static void static void
vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, int is_singleton)
rb_num_t is_singleton, rb_cref_t *cref)
{ {
VALUE klass; VALUE klass;
rb_method_visibility_t visi; rb_method_visibility_t visi;
rb_cref_t *cref = rb_vm_cref();
if (!is_singleton) { if (!is_singleton) {
klass = obj; klass = CREF_CLASS(cref);
visi = rb_scope_visibility_get(); visi = rb_scope_visibility_get();
} }
else { /* singleton */ else { /* singleton */
@ -2374,10 +2374,10 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
} while (0) } while (0)
static VALUE 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({ 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; return sym;
} }
@ -2386,7 +2386,7 @@ static VALUE
m_core_define_singleton_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval) m_core_define_singleton_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
{ {
REWIND_CFP({ 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; 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_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_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_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_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_set_postexe, m_core_set_postexe, 0);
rb_define_method_id(klass, id_core_hash_from_ary, m_core_hash_from_ary, 1); rb_define_method_id(klass, id_core_hash_from_ary, m_core_hash_from_ary, 1);