Граф коммитов

256 Коммитов

Автор SHA1 Сообщение Дата
ko1 5e8a147480 * method.h: introduce rb_callable_method_entry_t to remove
rb_control_frame_t::klass.
  [Bug #11278], [Bug #11279]
  rb_method_entry_t data belong to modules/classes.
  rb_method_entry_t::owner points defined module or class.
    module M
      def foo; end
    end
  In this case, owner is M.
  rb_callable_method_entry_t data belong to only classes.
  For modules, MRI creates corresponding T_ICLASS internally.
  rb_callable_method_entry_t can also belong to T_ICLASS.
  rb_callable_method_entry_t::defined_class points T_CLASS or
  T_ICLASS.
  rb_method_entry_t data for classes (not for modules) are also
  rb_callable_method_entry_t data because it is completely same data.
  In this case, rb_method_entry_t::owner == rb_method_entry_t::defined_class.
  For example, there are classes C and D, and incldues M,
    class C; include M; end
    class D; include M; end
  then, two T_ICLASS objects for C's super class and D's super class
  will be created.
  When C.new.foo is called, then M#foo is searcheed and
  rb_callable_method_t data is used by VM to invoke M#foo.
  rb_method_entry_t data is only one for M#foo.
  However, rb_callable_method_entry_t data are two (and can be more).
  It is proportional to the number of including (and prepending)
  classes (the number of T_ICLASS which point to the module).
  Now, created rb_callable_method_entry_t are collected when
  the original module M was modified. We can think it is a cache.
  We need to select what kind of method entry data is needed.
  To operate definition, then you need to use rb_method_entry_t.
  You can access them by the following functions.
  * rb_method_entry(VALUE klass, ID id);
  * rb_method_entry_with_refinements(VALUE klass, ID id);
  * rb_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
  To invoke methods, then you need to use rb_callable_method_entry_t
  which you can get by the following APIs corresponding to the
  above listed functions.
  * rb_callable_method_entry(VALUE klass, ID id);
  * rb_callable_method_entry_with_refinements(VALUE klass, ID id);
  * rb_callable_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
  VM pushes rb_callable_method_entry_t, so that rb_vm_frame_method_entry()
  returns rb_callable_method_entry_t.
  You can check a super class of current method by
  rb_callable_method_entry_t::defined_class.
* method.h: renamed from rb_method_entry_t::klass to
  rb_method_entry_t::owner.
* internal.h: add rb_classext_struct::callable_m_tbl to cache
  rb_callable_method_entry_t data.
  We need to consider abotu this field again because it is only
  active for T_ICLASS.
* class.c (method_entry_i): ditto.
* class.c (rb_define_attr): rb_method_entry() does not takes
  defiend_class_ptr.
* gc.c (mark_method_entry): mark RCLASS_CALLABLE_M_TBL() for T_ICLASS.
* cont.c (fiber_init): rb_control_frame_t::klass is removed.
* proc.c: fix `struct METHOD' data structure because
  rb_callable_method_t has all information.
* vm_core.h: remove several fields.
  * rb_control_frame_t::klass.
  * rb_block_t::klass.
  And catch up changes.
* eval.c: catch up changes.
* gc.c: ditto.
* insns.def: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_backtrace.c: ditto.
* vm_dump.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03 11:24:50 +00:00
nobu 051a749919 vm_method.c: remove unused code
* vm_method.c (rb_method_entry_make): remove unused code to
  prohibit method re-definition, introduced at r34983.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 09:55:57 +00:00
nobu e13f05f9e6 vm_method.c: no NOEX macros
* vm_method.c (rb_method_entry_make): NOEX macros are no longer
  defined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 08:18:18 +00:00
nobu f35b09c108 vm_method.c: orignial visibilities
* vm_method.c (Init_eval_method): copy the orignial visibilities,
  instead of setting explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 08:17:58 +00:00
normal b49075cdf1 move RB_GC_GUARD responsibility to rb_add_method_iseq
This simplifies all the callers and makes code easier to use
and review.  I was confused about the need for RB_GC_GUARD
in define_{aset,aref}_method of struct.c without reading
rb_add_method_iseq.

Likewise, do the same for rb_iseq_clone, where the GC guard
only seems neccesary iff RGenGC is disabled.

* vm_method.c (rb_add_method_iseq): add RB_GC_GUARD
* class.c (clone_method): remove RB_GC_GUARD
* struct.c (define_aref_method): ditto
  (define_aset_method): ditto
* vm.c (vm_define_method):
* iseq.c (rb_iseq_clone): add RB_GC_GUARD

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 21:07:18 +00:00
ko1 7bba6adc56 * vm_method.c (rb_method_entry_create): need to call
method_definition_reset() if def is given.
  Actually, `me' is a new object, so we don't need to call it.
  It is just to make sure.
* vm_method.c (method_definition_reset): remove duplicated insertion.
* vm_method.c (rb_method_entry_clone): assgine dst->def here,
  not in method_definition_reset().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 08:37:27 +00:00
ko1 f4d71ad509 * vm_method.c: make a rb_method_definition_t data (def) *after* making
a rb_method_entry_t data (me).
  Normally, `me' points `def'. Some Ruby objects pointed from `def'
  and objects are marked by `me' (mark_method_entry() in gc.c).
  However, `def' is built before making a `me', then nobody can mark
  objects pointed from `def' before making (and pointing from) `me'.
  I hope this patch solve #11244.
* vm_method.c: remove `rb_' prefix from some static functions.
* method.h (rb_method_entry_create): constify
* gc.c (mark_method_entry): add checking `def' and
  `def->body.iseq.iseqptr' availability because they can be NULL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 07:59:23 +00:00
ko1 988267d462 * vm_method.c (rb_method_definition_reset): need a WB for
VM_METHOD_TYPE_ATTRSET.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 21:44:58 +00:00
nobu 220f9d5053 vm_method.c: use the current visibility
* vm_method.c (rb_attr): simply use the current visibility,
  instead of tests for each visibilities.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 08:31:43 +00:00
nobu d92b0dc58a vm_method.c: remove redundant check
* vm_method.c (rb_attr): remove redundant check.  attribute names
  given in ruby level should be checked before calling this
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 08:29:03 +00:00
ko1 a5fa5f34b0 * method.h: embed rb_method_entry_t::attr::flags (5 bits) into
rb_method_entry_t::flags to make one word spare space.
  Add some macros to access these flags.
* vm_method.c: use these macros.
* internal.h: define IMEMO_FL_USHIFT and IMEMO_FL_USER[0-4]
  for T_IMEMO local flags.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-10 23:55:33 +00:00
ko1 c7edd997e8 * vm.c: use VM_ASSERT instead of assert().
* vm_args.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-10 23:42:01 +00:00
ko1 c19d373750 * method.h: back to share rb_method_definition_t by
rb_method_entry_t.
  r50728 changed sharing `def's to isolating `def's
  on alias and so on. However, this change conflicts
  future improvement plan. So I change back to sharing approach.
* method.h: move rb_method_definition_t::flags to
  rb_method_entry_t::attr::flags.
  rb_method_entry_t::attr is union with VALUE because this field
  should have same size of VALUE. rb_method_entry_t is T_IMEMO).
  And also add the following access macros to it's fileds.
  * METHOD_ENTRY_VISI(me)
  * METHOD_ENTRY_BASIC(me)
  * METHOD_ENTRY_SAFE(me)
* vm_method.c (rb_method_definition_addref): added instead of
  rb_method_definition_clone().
  Do not create new definition, but increment alias_count.
* class.c (clone_method): catch up this fix.
* class.c (method_entry_i): ditto.
* proc.c (mnew_internal): ditto.
* proc.c (mnew_missing): ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 10:19:48 +00:00
ko1 b6b76e3a85 * internal.h: move definition of rb_cref_t to method.h.
* eval_intern.h: move definition of rb_scope_visibility_t
  to method.h.
* method.h: change rb_cref_t::scope_visi from VALUE to
  rb_scope_visibility_t.
  [Bug #11219]
* vm.c (vm_cref_new): accept rb_method_visibility_t directly.
* vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0,
  but METHOD_VISI_UNDEF.
* vm_method.c (rb_scope_visibility_set): don't need to use cast.
* vm_method.c (rb_scope_module_func_set): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 11:42:34 +00:00
ko1 0f419d39b4 * vm_method.c (rb_add_method_iseq): use intermediate struct to
avoid initializing struct with variables.
  [Bug #11217]
* method.h: add a comment about it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:08:40 +00:00
ko1 3619a8b52d * method.h: constify rb_method_refined_t::orig_me.
Also constify the following functions.
  * rb_resolve_refined_method()
  * rb_method_entry_with_refinements()
  * rb_method_entry_without_refinements()
  * rb_method_entry_copy()'s parameter.
* class.c: catch up this fix.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:02:01 +00:00
ko1 9e73d45e0f * method.h: introduce rb_method_refined_t for refined method entry.
* class.c (move_refined_method): catch up this fix.
* gc.c (mark_method_entry): ditto.
* vm_eval.c (vm_call0_body): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 22:27:51 +00:00
ko1 4ab762de21 * vm_method.c: rename `rb_frame_...' to `rb_scope_...'.
* eval_intern.h: move decl. of rb_scope_visibility_set() to method.h.
* load.c: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 14:07:24 +00:00
ko1 18bbd05709 * method.h: split rb_method_definition_t::flag to several flags.
`flag' contains several categories of attributes and it makes us
  confusion (at least, I had confused).
  * rb_method_visibility_t (flags::visi)
    * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
    * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
    * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
    * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
  * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
  * NOEX_BASIC       -> basic (flags::basic, 1 bit)
  * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
  * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
  * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
  * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
  Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
  Background:
    I did not know what "NOEX" stands for.
    I asked Matz (who made this name) and his answer was "Nothing".
    "At first, it meant NO EXport (private), but the original
    meaning was gone."
    This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
  method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
  scope visibility.
  It has 3 method visibilities (public/private/protected)
  and `module_function`.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 01:39:16 +00:00
mame ea0bc53ec3 * vm_method.c (rb_method_definition_set): remove a double assignment.
Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 16:28:50 +00:00
ko1 721e096ffd * vm_method.c (rb_alias): rename parameter names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 15:06:29 +00:00
ko1 ac88162198 * method.h: remove rb_method_iseq_t::iseqval.
While making a r50728, iseqval is needed (to mark correctly),
  but now just iseqptr is enough.
* class.c: catch up this fix.
* gc.c: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 14:32:33 +00:00
ko1 57b817f4c5 * method.h: make rb_method_entry_t a VALUE.
Motivation and new data structure are described in [Bug #11203].
  This patch also solve the following issues.
  * [Bug #11200] Memory leak of method entries
  * [Bug #11046] __callee__ returns incorrect method name in orphan
                 proc
* test/ruby/test_method.rb: add a test for [Bug #11046].
* vm_core.h: remvoe rb_control_frame_t::me. me is located at value
  stack.
* vm_core.h, gc.c, vm_method.c: remove unlinked_method... codes
  because method entries are simple VALUEs.
* method.h:  Now, all method entries has own independent method
  definititons. Strictly speaking, this change is not essential,
  but for future changes.
  * rb_method_entry_t::flag is move to rb_method_definition_t::flag.
  * rb_method_definition_t::alias_count is now
    rb_method_definition_t::alias_count_ptr, a pointer to the counter.
* vm_core.h, vm_insnhelper.c (rb_vm_frame_method_entry) added to
  search the current method entry from value stack.
* vm_insnhelper.c (VM_CHECK_MODE): introduced to enable/disable
  assertions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 04:20:30 +00:00
ko1 7221252ab1 * vm_method.c (rb_method_entry_make): do not show warning message
when method_entry is an alias.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 10:26:05 +00:00
ko1 cd909b553f * class.c: remove needless include pragmra for method.h.
* struct.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 06:44:16 +00:00
nobu 473427a391 vm_method.c: suppress warning
* vm_method.c (rb_frame_visibility_check): suppress comparison
  warning by gcc 4.8 and 4.9.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-31 23:06:25 +00:00
ko1 1611735b29 * eval_intern.h, vm_method.c: move macros to functions.
* SCOPE_TEST(f)  -> rb_frame_visibility_test(flag).
  * SCOPE_CHECK(f) -> rb_frame_visibility_check(flag).
  * SCOPE_SET(f)   -> rb_frame_visibility_set(flag).
* load.c (load_ext): use it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-31 20:44:56 +00:00
ko1 9794af357e fix indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 19:58:08 +00:00
ko1 f1d4e8b3b3 * method.h: add VM_METHOD_TYPE_ALIAS rb_method_definition_t::type
to fix [Bug #11173].
  Now, inter class/method alias creates new method entry
  VM_METHOD_TYPE_ALIAS, which has an original method entry.
* vm_insnhelper.c (find_defiend_class_by_owner): added.
  Search corresponding defined_class from owner class/module.
* vm_method.c (rb_method_entry_get_without_cache): return me->klass
  directly for defined_class.
  Now, no need to check me->klass any more.
* vm_method.c (method_entry_set0): separated from method_entry_set().
* vm_method.c (rb_alias): make method entry has VM_METHOD_TYPE_ALIAS.
* vm_method.c (release_method_definition): support VM_METHOD_TYPE_ALIAS.
* vm_method.c (rb_hash_method_definition): ditto.
* vm_method.c (rb_method_definition_eq): ditto.
* vm_method.c (release_method_definition): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
* vm_insnhelper.c (vm_method_cfunc_entry): ditto.
* vm_eval.c (vm_call0_body): ditto.
* gc.c (mark_method_entry): ditto.
* proc.c (method_def_iseq): ditto.
* proc.c (method_cref): ditto.
* proc.c (rb_method_entry_min_max_arity): ditto.
* test/ruby/test_alias.rb: add tests.
* test/ruby/test_module.rb: fix a test to catch up current behavior.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:45:28 +00:00
ko1 255c16b598 * vm_method.c (rb_unlink_method_entry): make it static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:35:21 +00:00
ko1 9cf6751f83 * method.h, vm_method.c (rb_free_method_entry): constify a parameter.
* vm_method.c (rb_unlink_method_entry): constify a parameter.
* vm_core.h: remove useless declaration about rb_unlink_method_entry().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:30:42 +00:00
shugo 834d2bbe4d * vm_method.c (rb_alias): should resolve refined methods.
[ruby-core:69360] [Bug #11182]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-26 13:16:18 +00:00
ko1 7239111ef5 * iseq.c: constify.
* iseq.h: ditto.
* method.h: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 09:01:44 +00:00
zzak 32a5a098e3 * vm_method.c: Remove private attribute warning [Bug #10967]
Patch by @spastorino [Fixes GH-849]
  https://github.com/ruby/ruby/pull/849

* test/ruby/test_module.rb: Update test for changes


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 06:40:27 +00:00
ko1 8dced4d2c0 * internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE.
  It is easy to understand what is CREF and what is pure NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 21:22:43 +00:00
ko1 ae166317a4 * internal.h: define CREF accessor macros.
* CREF_CLASS(cref)
  * CREF_NEXT(cref)
  * CREF_VISI(cref)
  * CREF_VISI_SET(cref, v)
  * CREF_REFINEMENTS(cref)
  * CREF_PUSHED_BY_EVAL(cref)
  * CREF_PUSHED_BY_EVAL_SET(cref)
  * CREF_OMOD_SHARED(cref)
  * CREF_OMOD_SHARED_SET(cref)
  * CREF_OMOD_SHARED_UNSET(cref)
  This is process to change CREF data type from NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 19:50:37 +00:00
ko1 d84f9b1694 * fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored
  to rb_method_definition_t::body.iseq_body.cref.
* vm_insnhelper.c: modify SVAR usage.
  When calling ISEQ type method, push CREF information onto method
  frame, SVAR located place. Before this fix, SVAR is simply nil.
  After this patch, CREF (or NULL == Qfalse for not iseq methods)
  is stored at the method invocation.
  When SVAR is requierd, then put NODE_IF onto SVAR location,
  and NDOE_IF::nd_reserved points CREF itself.
* vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added.
* vm_insnhelper.c (vm_push_frame): accept CREF.
* method.h, vm_method.c (rb_add_method_iseq): added. This function
  accepts iseq and CREF.
* class.c (clone_method): use rb_add_method_iseq().
* gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref.
* iseq.c: remove CREF related codes.
* insns.def (getinlinecache/setinlinecache): CREF should be cache key
  because a different CREF has a different namespace.
* node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR.
* proc.c: catch up changes.
* struct.c: ditto.
* insns.def: ditto.
* vm_args.c (raise_argument_error): ditto.
* vm_eval.c: ditto.
* test/ruby/test_class.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06 12:24:58 +00:00
nobu 4194ca02fb revert r45487
* variable.c (rb_alias_variable): IDs are always immportal now, no
  pin down is needed.

* vm_method.c (rb_method_entry_make): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-06 02:33:47 +00:00
shugo 525f515f9a * vm_method.c (remove_method): When remove refined
method, raise a NameError if the method is not
  defined in refined class.

  But if the method is defined in refined class,
  it should keep refined method and remove original
  method.

  Patch by Seiei Higa. [ruby-core:67722] [Bug #10765]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-03 06:26:48 +00:00
nobu 0fb2cd458b class.c: add callback argument
* class.c (rb_class_foreach_subclass): add argument for callback
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 14:09:20 +00:00
nobu dd1baaabcd vm_method.c: method defined should not use refinements.
* vm_method.c (check_definition): Module#public_method_defined?,
  Module#private_method_defined?, Module#protected_method_defined?
  should not use refinements. [ruby-core:67656] [Bug #10753]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-18 06:57:34 +00:00
nobu a11e25432b method.h: UNDEFINED_REFINED_METHOD_P
* method.h (UNDEFINED_REFINED_METHOD_P): macro to tell if refined
  original method is defined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 08:18:10 +00:00
nobu 1abd51ad91 vm_method.c: NameError at refined method alias
* vm_method.c (rb_alias): raise a NameError when creating alias to
  a refined method if the original method of the refined method is
  not defined.  [ruby-core:67523] [Bug #10731]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 07:45:49 +00:00
nobu 3f8ceab90e vm_method.c: no super klass, no original method entry
* vm_method.c (rb_method_entry): if no super class, no original
  method entry.  [ruby-core:67389] [Bug #10707]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08 08:05:03 +00:00
nobu 459894160e vm_method.c: fix change refined new method visibility
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08 07:31:45 +00:00
nobu 91e2cd34d4 vm_method.c: preserve encodings
* vm_method.c (rb_mod_remove_method): preserve encodings of method
  name and class name in error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 18:58:05 +00:00
nobu f2fc80cebe vm_method.c: preserve encodings
* vm_method.c (rb_method_entry_make): preserve encodings of
  constant names in warning messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 18:44:12 +00:00
nobu 4b8cb23a36 intern.h: deprecate disable and enable super
* include/ruby/intern.h (rb_disable_super, rb_enable_super): warn
  as deprecated at build time, instead of ignoring silently or
  warning at runtime only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-05 08:20:31 +00:00
nobu 2c8db2c24c vm_method.c: get rid of cache
* vm_method.c (rb_method_entry_make): get rid of storing method
  cache, so that the added method will be called later.
  [ruby-dev:48691] [Bug #10421]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-23 16:02:46 +00:00
nobu 8dc89b34c1 vm_method.c: no redefinition warnings for undefined methods
* vm_method.c (rb_method_entry_make): warn redefinition only for
  already defined methods, but not for undefined methods.
  [ruby-dev:48691] [Bug #10421]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-23 10:13:29 +00:00