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

229 Коммитов

Автор SHA1 Сообщение Дата
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
charliesome b512e61ca0 * class.c (include_modules_at): invalidate method cache if included
module contains constants

* test/ruby/test_module.rb: add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 10:48:33 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
nobu 609c7420d7 class.c: rb_singleton_class_get
* class.c (rb_singleton_class_get): get the singleton class if exists,
  or nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:50:38 +00:00
nobu 111c791c37 class.c: adjust indent
* class.c (singleton_class_of): adjust indent.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 05:49:47 +00:00
nobu e8bdef657a class.c: include modules only
* class.c (rb_mod_included_modules): should not include non-modules.
  [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 16:05:50 +00:00
nobu 3fd0000c0c class.c: exclude original module
* class.c (rb_mod_included_modules): should not include the original
  module itself.  [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 13:47:11 +00:00
nobu 97982e823f id.def: predefined IDs
* defs/id.def: add more predefined IDs used in core.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-02 07:54:17 +00:00
nobu 6500760bd3 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 04:51:05 +00:00
zzak 0b4214ad9b * class.c: Example of Object#methods by @windwiny [Fixes GH-293]
* ruby.c: Document return values of Kernel #sub, #gsub, and #chop


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 04:47:31 +00:00
nobu c5fe7eb6f6 class.c: suppress wrong warning
* class.c (HAVE_METACLASS_P): should check FL_SINGLTON flag before get
  instance variable to get rid of wrong warning about __attached__.
  [ruby-core:53839] [Bug #8188]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:27:27 +00:00
nobu 99126a4c88 class.c: from the origin class
* class.c (rb_obj_singleton_methods): collect methods from the origin
  class.  [ruby-core:53207] [Bug #8044]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-13 06:13:08 +00:00
marcandre dfde34cb3c * class.c (rb_mod_ancestors): Include singleton_class in ancestors list
[Feature #8035]

* test/ruby/test_module.rb (class): test for above

* test/ruby/marshaltestlib.rb (module): adapt test

* NEWS: list change

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-07 17:54:49 +00:00
nobu f113ab552c class.c: check redefinition
* class.c (rb_prepend_module): check redefinition of built-in opimized
  methods.  [ruby-dev:47124] [Bug #7983]
* vm.c (rb_vm_check_redefinition_by_prepend): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05 12:36:45 +00:00
nobu 632ab19c4d class.c: cyclic prepend
* class.c (include_modules_at): detect cyclic prepend with original
  method table.  [ruby-core:52205] [Bug #7841]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-14 02:08:31 +00:00
nobu ad6f06aed8 object.c: singleton class clone
* object.c (rb_obj_clone): attach clone to its singleton class during
  cloning singleton class so that singleton_method_added will be called
  on it.  based on the patch by shiba (satoshi shiba)[Bug #5283] in
  [ruby-dev:44477].  [Bug #5283]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 02:37:47 +00:00
charliesome a70bb8889b * class.c (rewrite_cref_stack, clone_method): rewrite a method's cref
stack when cloning into a new class to allow lexical const lookup to
  work as expected [ruby-core:47834] [Bug #7107]
* test/ruby/test_class.rb (class TestClass): related test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17 09:49:00 +00:00
nobu 3738ebe15a * object.c (Init_Object): no needs to override with same method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 14:32:40 +00:00
charliesome c01f06089f * object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copy
* class.c (rb_class_init_copy): rename to class_init_copy_check, performs type
	  checks on arguments to prevent reinitialization of initialized class
	  [ruby-core:50869] [Bug #7557]
	* class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS
	* test/ruby/test_class.rb (class TestClass): related test


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 14:11:01 +00:00
shugo 75bed271f0 * class.c (rb_prepend_module): move refined methods from the origin
of a class to the class, because refinements should have priority
  over prepended modules.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12 09:35:50 +00:00
shugo 7ef16d224a * fix the behavior when a module is included into a refinement.
This change is a little tricky, so it might be better to prohibit
  module inclusion to refinements.

* include/ruby/ruby.h (RMODULE_INCLUDED_INTO_REFINEMENT): new flag
  to represent that a module (iclass) is included into a refinement.

* class.c (include_modules_at): set RMODULE_INCLUDED_INTO_REFINEMENT
  if klass is a refinement.

* eval.c (rb_mod_refine): set the superclass of a refinement to the
  refined class for super.

* eval.c (rb_using_refinement): skip the above superclass (the
  refined class) when creating iclasses for refinements.  Otherwise,
  `using Refinement1; using Refinement2' creates iclasses:
  <Refinement2> -> <RefinedClass> -> <Refinement1> -> RefinedClass,
  where <Module> is an iclass for Module, so RefinedClass is
  searched before Refinement1.  The correct iclasses should be
  <Refinement2> -> <Refinement1> -> RefinedClass.

* vm_insnhelper.c (vm_search_normal_superclass): if klass is an
  iclass for a refinement, use the refinement's superclass instead
  of the iclass's superclass.  Otherwise, multiple refinements are
  searched by super.  For example, if a refinement Refinement2
  includes a module M (i.e., Refinement2 -> <M> -> RefinedClass,
  and if refinements iclasses are <Refinement2> -> <M>' ->
  <Refinement1> -> RefinedClass, then super in <Refinement2> should
  use Refinement2's superclass <M> instead of <Refinement2>'s
  superclass <M>'.

* vm_insnhelper.c (vm_search_super_method): do not raise a
  NotImplementError if current_defind_class is a module included
  into a refinement.  Because of the change of
  vm_search_normal_superclass(), the receiver might not be an
  instance of the module('s iclass).

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-10 16:05:45 +00:00
shugo 60d6038dda * revised r37993 to avoid SEGV/ILL in tests. In r37993, a method
entry with VM_METHOD_TYPE_REFINED holds only the original method
  definition, so ci->me is set to a method entry allocated in the
  stack, and it causes SEGV/ILL.  In this commit, a method entry
  with VM_METHOD_TYPE_REFINED holds the whole original method entry.
  Furthermore, rb_thread_mark() is changed to mark cfp->klass to
  avoid GC for iclasses created by copy_refinement_iclass().

* vm_method.c (rb_method_entry_make): add a method entry with
  VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_me) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* vm.c (rb_thread_mark): mark cfp->klass for iclasses created by
  copy_refinement_iclass().

* vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 13:08:41 +00:00
shugo 9e44974874 * revert r37993 to avoid SEGV in tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 02:11:59 +00:00
shugo 421314cf4e * vm_method.c (rb_method_entry_make): add a method entry with
VM_METHOD_TYPE_REFINED to the class refined by the refinement if
  the target module is a refinement.  When a method entry with
  VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with
  the same name is searched in refinements.  If such a method is
  found, the method is invoked.  Otherwise, the original method in
  the refined class (rb_method_definition_t::body.orig_def) is
  invoked.  This change is made to simplify the normal method lookup
  and to improve the performance of normal method calls.

* vm_method.c (EXPR1, search_method, rb_method_entry),
  vm_eval.c (rb_call0, rb_search_method_entry): do not use
  refinements for method lookup.

* vm_insnhelper.c (vm_call_method): search methods in refinements if
  ci->me is VM_METHOD_TYPE_REFINED.  If the method is called by
  super (i.e., ci->call == vm_call_super_method), skip the same
  method entry as the current method to avoid infinite call of the
  same method.

* class.c (include_modules_at): add a refined method entry for each
  method defined in a module included in a refinement.

* class.c (rb_prepend_module): set an empty table to
  RCLASS_M_TBL(klass) to add refined method entries, because
  refinements should have priority over prepended modules.

* proc.c (mnew): use rb_method_entry_with_refinements() to get
  a refined method.

* test/ruby/test_refinement.rb (test_inline_method_cache): do not skip
  the test because it should pass successfully.

* test/ruby/test_refinement.rb (test_redefine_refined_method): new
  test for the case a refined method is redefined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 12:50:10 +00:00
ko1 f3e5f2cd75 * bignum.c (bignew_1): Bignum instances are frozen.
Feature #3222
* include/ruby/ruby.h: Fixnum instances are also frozen.
* class.c (singleton_class_of): check Bignum before
  singleton cheking.
* test/ruby/test_bignum.rb: add a test.
* test/ruby/test_fixnum.rb: ditto.
* test/ruby/marshaltestlib.rb, test/ruby/test_eval.rb,
  test/ruby/test_object.rb: catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 00:03:20 +00:00
ko1 180c744b3b * numeric.c (rb_float_new_in_heap), include/ruby/ruby.h:
make all Float objects frozen.
  [ruby-dev:46081] [ruby-trunk - Feature #6936]
  Most part of patch by NARUSE, Yui  <naruse@ruby-lang.org>.
* class.c (singleton_class_of): raise TypeError when
  trying to define a singleton method on Float objects.
* vm.c (vm_define_method): ditto.
* test/ruby/marshaltestlib.rb: catch up above changes.
* test/ruby/test_class.rb: ditto.
* test/test_pp.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 02:10:53 +00:00
ko1 9dc3a7d7a5 * include/ruby/ruby.h, class.c: remove (revert)
`rb_add_method_cfunc_frameless()' API.
  This API is not mature to become an offical API.
  For example, we can not use this API with
  `rb_define_private_method()'.
* method.h, vm_method.c (rb_add_method_cfunc_frameless): removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-25 06:03:53 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
ko1 588b73bca2 * class.c (rb_define_frameless_method): rename from
rb_define_method_fast(). Defined method with this C API
  does not make a method frame. It is bit lightweight than
  ordinal C functions. Now only 0 or 1 argc are permitted.
* method.h (VM_METHOD_TYPE_CFUNC_FRAMELESS): rename macro name
  from VM_METHOD_TYPE_CFUNC_FAST.
* vm_insnhelper.c, vm_method.c: rename related functions.
* proc.c (rb_method_entry_arity): catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 05:22:13 +00:00
ko1 90a6dce041 * method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.
This method is similar to VM_METHOD_TYPE_CFUNC methods, but
  called cfunc without building new frame (does not push new control
  frame). If error is occured in cfunc, the backtrace only shows
  caller frame and upper.
  This kind of methods can be added by rb_define_method_fast().
  This feature is similar to specialized instructions (opt_plus, etc),
  but more flexible (but a bit slower).
* class.c (rb_define_method_fast): added.
  Maybe it will be renamed soon.
* vm_insnhelper.c (vm_call_method): support method type
  VM_METHOD_TYPE_CFUNC_FAST.
* proc.c (rb_method_entry_arity): catch up new method type.
* vm_method.c (rb_add_method_cfunc_fast): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15 21:24:08 +00:00
nobu 5fbfc21b67 internal.h: allocator function in rb_classext_t
* internal.h (struct rb_classext_struct): move allocator function into
  rb_classext_t from ordinary method table.  [ruby-dev:46121]
  [Feature #6993]
* object.c (rb_obj_alloc): call allocator function directly.
* vm_method.c (rb_define_alloc_func, rb_undef_alloc_func)
  (rb_get_alloc_func): use allocator function in rb_classext_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-08 09:52:26 +00:00
usa 6a80947a4b * class.c (singleton_class_of): flonum can't have singleton class.
* vm.c (vm_define_method): flonum can't have singleton method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 11:36:42 +00:00
nobu 28827e61d1 method in instance_eval
* class.c (rb_special_singleton_class_of): utility function.
* vm_eval.c (eval_under): special deal for class variable scope with
  instance_eval.
* vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow method
  definition in instance_eval of special constants.  [ruby-core:28324]
  [Bug #2788]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06 15:31:13 +00:00
shugo 9537e8ffe5 * internal.h, class.c, eval.c, insns.def: find the appropriate
receiver for super called in instance_eval.  If such a receiver is
  not found, raise NoMethodError. [ruby-dev:39772] [Bug #2402]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06 07:00:19 +00:00
shugo 19ddfc2483 * eval.c (rb_mod_using): new method Module#using. [experimental]
* eval.c (rb_mod_refine): new method Module#refine. [experimental]

* eval.c (f_using): new method Kernel#using. [experimental]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:34:19 +00:00
shugo 319088e9c7 * class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: add klass to
  rb_control_frame_t to implement super correctly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 11:08:44 +00:00
nobu b283d01987 class.c: fix duplication of prepended module
* class.c (include_class_new): fix duplication of prepended module.
  since m_tbl of prepended module is always zero, copy from its
  copy iclass of original.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-31 15:33:23 +00:00
nobu edb1fc4eb2 prepend: fix mixing with include
* class.c (rb_include_module): include modules after the origin.
* class.c (include_modules_at): skip prepended modules.
* class.c (rb_prepend_module): now basic.klass in ICLASS refers the
  old original class/module.  [ruby-dev:45868][Bug #6662]
* class.c (rb_mod_ancestors): ditto.
* vm_method.c (search_method): search method entry from the origin
  iclass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-02 08:06:37 +00:00
nagachika 912df4b615 * class.c (class_instance_method_list): consider prepended Class/Module
when recur != 0. [ruby-dev:45863] [Bug #6660]

* test/ruby/test_module.rb (test_prepend_instance_methods_false): add
  a test for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-28 00:39:52 +00:00
nobu 3f3225905b prepend: fix ancestors order
* class.c (rb_mod_ancestors): fix ancestors order.
  [ruby-core:45919][Bug #6658] [ruby-dev:45861][Bug #6659]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 21:12:46 +00:00
nobu d4269d7b7c fix null m_tbl
* class.c (rb_obj_singleton_methods): m_tbl in prepended class/module
  is NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 13:40:34 +00:00
nobu cf3a8f09b8 ancestor modules
* class.c (rb_prepend_module): ancestors of prepending module also
  should be included.  [ruby-core:45914][Bug #6654]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 12:31:17 +00:00
nobu 48c04ad0d8 fix null m_tbl
* class.c (class_instance_method_list): m_tbl in prepended
  class/module is NULL.  [ruby-core:45915][Bug #6655]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 12:01:39 +00:00
nobu 8ddbbb3324 Module#prepend
* class.c (rb_prepend_module): prepend module into another module.
* eval.c (rb_mod_prepend): new method Module#prepend.  [Feature #1102]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 07:48:50 +00:00
nobu ffa20cf154 use rb_check_hash_type
* class.c (rb_scan_args): use rb_check_hash_type.
* process.c (rb_exec_getargs): ditto.
* sprintf.c (get_hash): ditto.
* string.c (rb_str_sub_bang, str_gsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 07:46:24 +00:00
nobu 82a408fb9d Revert r31873 Module#mix
* class.c (rb_mix_module): revert Module#mix.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-25 08:49:32 +00:00
drbrain 1d4e7d9232 * class.c (rb_mod_init_copy): Clear the cached inspect string of a
dup'd anonymous module or class.  [ruby-trunk - Bug #6454]
* test/ruby/test_module.rb (class TestModule):  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-22 20:15:28 +00:00
nobu 57fb219905 * reduce UNREACHABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15 00:06:13 +00:00
drbrain da39d32f60 * encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "control
reaches end of non-void function" warnings.  [ruby-trunk - Bug #6066]
* re.c (name_to_backref_number):  ditto.
* object.c (rb_Float):  ditto.
* io.c (io_readpartial):  ditto.
* io.c (io_read_nonblock):  ditto.
* pack.c (rb_uv_to_utf8):  ditto.
* proc.c (rb_method_entry_arity):  ditto.
* vm_method.c (rb_f_notimplement):  ditto.
* struct.c (rb_struct_aset_id):  ditto.
* class.c (rb_scan_args):  ditto.
* process.c (rlimit_resource_type):  ditto.
* process.c (rlimit_resource_value):  ditto.
* process.c (p_uid_switch):  ditto.
* process.c (p_gid_switch):  ditto.
* ext/digest/digest.c (rb_digest_instance_update):  ditto.
* ext/digest/digest.c (rb_digest_instance_finish):  ditto.
* ext/digest/digest.c (rb_digest_instance_reset):  ditto.
* ext/digest/digest.c (rb_digest_instance_block_length):  ditto.
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp):  ditto.
* ext/dl/handle.c (rb_dlhandle_close):  ditto.
* ext/tk/tcltklib.c (pending_exception_check0):  ditto.
* ext/tk/tcltklib.c (pending_exception_check1):  ditto.
* ext/tk/tcltklib.c (ip_cancel_eval_core):  ditto.
* ext/tk/tcltklib.c (lib_get_reltype_name):  ditto.
* ext/tk/tcltklib.c (create_dummy_encoding_for_tk_core):  ditto.
* ext/tk/tkutil/tkutil.c (tk_hash_kv):  ditto.
* ext/openssl/ossl_ssl.c (ossl_ssl_session_reused):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_dsa_verify_asn1):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_at_infinit):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_on_curve):  ditto.
* ext/fiddle/conversions.c (generic_to_value):  ditto.
* ext/socket/raddrinfo.c (rsock_io_socket_addrinfo):  ditto.
* ext/socket/socket.c (sock_s_getnameinfo):  ditto.
* ext/ripper/eventids2.c (ripper_token2eventid):  ditto.
* cont.c (return_fiber):  ditto.
* dmydln.c (dln_load):  ditto.
* vm_insnhelper.c (vm_search_normal_superclass):  ditto.
* bignum.c (big_fdiv):  ditto.
* marshal.c (r_symlink):  ditto.
* marshal.c (r_symbol):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 23:45:37 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00