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

156 Коммитов

Автор SHA1 Сообщение Дата
mrkn 5385ae9af4 * rational.c (numeric_quo): move num_quo in numeric.c to numeric_quo
in rational.c to refer canonicalization state for mathn support.
  [ruby-core:41575] [Bug #5736]

* numeric.c (num_quo): ditto.

* test/test_mathn.rb: add a test for the change at r41109.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:50:32 +00:00
nobu 4f66fb1442 rational.c: use existing functions
* rational.c (f_inspect, f_to_s): use existing functions, rb_inspect
  and rb_obj_as_string respectively.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-29 23:57:25 +00:00
ko1 4f401816ff * gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
  check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
  you want to access raw pointers. If you modify the contents which
  pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
  and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
  barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
  generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
  FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
  move flag bits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
ko1 89e6910f04 * include/ruby/ruby.h: constify RRational::(num,den) and
RComplex::(real,imag).
  Add macro to set these values:
* RRATIONAL_SET_NUM()
* RRATIONAL_SET_DEN()
* RCOMPLEX_SET_REAL()
* RCOMPLEX_SET_IMAG()
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
  TODO: API design. RRATIONAL_SET(rat,num,den) is enough?
  TODO: Setting constify variable with cast has same issue of r40691.
* complex.c, rational.c: use above macros.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 15:55:09 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
akr 712c7168bf * internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.
(MUL_OVERFLOW_FIXNUM_P): Ditto.
  (MUL_OVERFLOW_LONG_P): Ditto.

* array.c (rb_ary_product): Don't overflow on signed integer
  multiplication.

* numeric.c (fix_mul): Ditto.
  (int_pow): Ditto.

* rational.c (f_imul): Ditto.

* insns.def (opt_mult): Ditto.

* thread.c (sleep_timeval): Don't overflow on signed integer addition.

* bignum.c (rb_int2big): Don't overflow on signed integer negation.
  (rb_big2ulong): Ditto.
  (rb_big2long): Ditto.
  (rb_big2ull): Ditto.
  (rb_big2ll): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09 11:39:53 +00:00
takano32 5e04bb6697 * rational.c: fix dangling if, else-if and else.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-12 08:00:16 +00:00
tadf 9a4f037502 * complex.c: edited rdoc.
* rational.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 08:01:32 +00:00
tadf ec9eabc6c2 * complex.c: described syntax of string form.
* rational.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-10 00:18:52 +00:00
zzak c2204ca328 * array.c: Document #<=> return values and formatting
* bignum.c: ditto
* file.c: ditto
* object.c: ditto
* numeric.c: ditto
* rational.c: ditto
* string.c: ditto
* time.c: ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23 03:35:38 +00:00
marcandre 8797ebd662 * rational.c (nurat_expt): Deal with special cases for rationals 0, ±1
[bug #5713] [bug #5715]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05 05:39:33 +00:00
nobu 3d0786a3a8 marshal.c: marshal_dump instance varialbes
* marshal.c (w_object): dump instance varialbes of the result of
  marshal_dump not the original object.  [ruby-core:51163] [Bug #7627]
* complex.c (nucomp_marshal_dump): need to copy instance variables.
* rational.c (nurat_marshal_dump): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-26 13:39:15 +00:00
tadf cbe5f8820b * rational.c (f_round_common): should check overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 09:25:13 +00:00
tadf 81af1bd9e8 * ratioanl.c (float_rationalize): reduced.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 09:01:22 +00:00
nobu 4d73f95068 random.c, rational.c: make marshal methods private
* random.c (Init_Random), rational.c (Init_Rational): make marshal
  methods private.  [Feature #6539]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03 10:10:14 +00:00
tadf d6ec400148 * complex.c (string_to_c_strict, string_to_c): check NUL.
* rational.c (string_to_r_strict, string_to_r): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 11:32:52 +00:00
tadf 1ac4e6d274 * rational.c (read_digits): due to a bit tighter rb_cstr_to_inum().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 09:48:51 +00:00
tadf 21453dc738 * complex.c: some improvements.
* rational.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 12:10:08 +00:00
tadf 42d38decda * complex.c (read_comp): mathn compliant.
* rational.c (read_num): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-18 00:35:06 +00:00
tadf 7a1985a969 trivial changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-18 00:26:15 +00:00
tadf 47fe9b79a3 * complex.c (string_to_c_strict, string_to_c): rewrote without regexp.
* rational.c (string_to_r_strict, string_to_r): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-17 15:19:55 +00:00
tadf e864787c84 * complex.c: modified doc.
* ratioanl.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-10 10:29:13 +00:00
tadf d4199057bc * complex.c: modified doc.
* rational.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 14:39:50 +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
nobu 003c45f9cd complex.c, rational.c: compatible marshal loader
* complex.c, rational.c: compatible marshal loader for compatibilities
  with 1.8.  [ruby-core:45775] [Bug #6625]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-25 08:41:07 +00:00
tadf eb6579e647 * marshal.c: experimental test aborted.
* complex.c: ditto.
	* rational.c: ditto.
	* include/ruby/intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 19:26:58 +00:00
tadf f5b06413ca * marshal.c: calls directly rb_{Complex,Rational}_marshal_load().
But now disabled. [experimental]
	* complex.c: followed the above.
	* rational.c: ditto.
	* include/rub/intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 12:21:18 +00:00
nobu 694035eb35 use rb_marshal_{dump,load}
* marshal.c: revert r35879 "now marshal_{load|dump} are external."
* complex.c (nucomp_marshal__{dump,load}): should use rb_marshal_{dump,load}.
* rational.c (nurat_marshal__{dump,load}): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 07:34:03 +00:00
tadf bdc55aa0c6 * complex.c: wrote Complex#_dump and Complex::load. But now
disabled (due to compatibility) [experimental].

	* rational.c: wrote Rational#_dump and Rational::load. ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 05:05:29 +00:00
tadf 89ae71d721 * complex.c (nucomp_marshal_load): [ruby-core:45394]
* rational.c (nurat_marshal_load): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 01:26:41 +00:00
naruse eeff98c430 * complex.c (nucomp_marshal_load): raise error on invalid data.
reported by John Firebaugh [ruby-core:42860] [Bug #6076]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-25 07:20:00 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
mrkn b30d203fed * rational.c (nurat_coerce): Rational#coerce should converts itself
into Complex if the argument is a Complex with non-zero imaginary
  part.  [Bug #5020] [ruby-dev:44088]
* test/ruby/test_rational.rb (test_coerce): test for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-17 01:24:22 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
tadf 14c504b3cc * complex.c (string_to_c_internal): uses rb_reg_nth_match;
* rational.c (string_to_r_internal): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-09 15:36:13 +00:00
tadf aca87391e9 * rational.c (string_to_r): Rational#** may return flonum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-09 15:25:12 +00:00
naruse 1d5431374d * insns.def (opt_mult): as r31805, volatile it.
Without this, clang -O fails calculation.

* numeric.c (fix_mul): ditto.

* rational.c (f_imul): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-30 06:53:21 +00:00
tadf 14491f13d7 * complex.c, rational.c: omitted some method calls.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-24 13:24:02 +00:00
akr dd5ad24735 * rational.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-26 00:36:08 +00:00
tadf 4ffe7a1734 modified some descriptions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-23 14:28:55 +00:00
tadf 1d8ca7a237 * complex.c, rational.c ({nucomp,nurat}_expt): added a check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-22 22:31:55 +00:00
nobu dccf9e0c45 * configure.in, include/ruby/defines.h (RUBY_FUNC_EXPORTED): macro
to declare exported function.

* array.c (rb_ary_memsize), string.c (rb_str_memsize),
  variable.c (rb_objspace_data_type_memsize): used in
  objspace.  [ruby-dev:42022]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-14 06:33:06 +00:00
nobu cba4d05785 * rational.c (nurat_div): divided by infinity should be zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-06 11:13:48 +00:00
nobu edd4332a38 * rational.c (nurat_div): divided by float zero should be
infinity.  [ruby-core:31626]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-06 11:12:35 +00:00
nobu 5274f89201 * complex.c (nucomp_marshal_load): should check the argument.
[ruby-core:31622]

* rational.c (nurat_marshal_load): ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-05 09:36:16 +00:00
nobu 292c39098d * bignum.c (rb_big_eq): never equal to infinity.
[ruby-core:31603]

* rational.c (nurat_div): hack for integral float divisor.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-03 11:30:19 +00:00
nobu 062b4d6752 * include/ruby/{intern,io}.h: add missing prototypes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-22 03:02:40 +00:00
tadf a90469602c * complex.c, rational.c, lib/cmath.rb, lib/date.rb lib/date/delta*:
reverted r27484-27486.  now official spec.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-26 11:14:40 +00:00
tadf 3502114507 * complex.c, ratioanl.c: reverted experimental r24565.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-25 06:52:24 +00:00
marcandre 215b8092a7 * complex.c (nucomp_real_check): raise TypeError instead of ArgumentError
when argument is not a real as expected [ruby-core:28395]

* rational.c (nurat_int_check): ditto (for integers)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-03 14:18:26 +00:00