summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-17 06:53:48 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-17 06:53:48 (GMT)
commitf9727c12cc8fbc5f752f5983be1f14bb976e5a13 (patch)
treebdf433b181c6d6e00bd33581136ab2970bc9509d /numeric.c
parent565241f11f5d217631ed1e8bbafec7a088bed654 (diff)
[Feature #12005] Unify Fixnum and Bignum into Integer
* [Feature #12005] Unify Fixnum and Bignum into Integer * include/ruby/ruby.h (rb_class_of): Return rb_cInteger for fixnums. * insns.def (INTEGER_REDEFINED_OP_FLAG): Unified from FIXNUM_REDEFINED_OP_FLAG and BIGNUM_REDEFINED_OP_FLAG. * vm_core.h: Ditto. * vm_insnhelper.c (opt_eq_func): Use INTEGER_REDEFINED_OP_FLAG instead of FIXNUM_REDEFINED_OP_FLAG. * vm.c (vm_redefinition_check_flag): Use rb_cInteger instead of rb_cFixnum and rb_cBignum. (C): Use Integer instead of Fixnum and Bignum. * numeric.c (fix_succ): Removed. (Init_Numeric): Define Fixnum as Integer. * bignum.c (bignew): Use rb_cInteger instead of Rb_cBignum. (rb_int_coerce): replaced from rb_big_coerce and return fixnums as-is. (Init_Bignum): Define Bignum as Integer. Don't define ===. * error.c (builtin_class_name): Return "Integer" for fixnums. * sprintf.c (ruby__sfvextra): Use rb_cInteger instead of rb_cFixnum. * ext/-test-/testutil: New directory to test. Currently it provides utilities for fixnum and bignum. * ext/json/generator/generator.c: Define mInteger_to_json. * lib/mathn.rb (Fixnum#/): Redefinition removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/numeric.c b/numeric.c
index e2a14b2..eee539e 100644
--- a/numeric.c
+++ b/numeric.c
@@ -2948,13 +2948,6 @@ int_even_p(VALUE num)
* (-1).succ #=> 0
*/
-static VALUE
-fix_succ(VALUE num)
-{
- long i = FIX2LONG(num) + 1;
- return LONG2NUM(i);
-}
-
VALUE
rb_int_succ(VALUE num)
{
@@ -4954,6 +4947,7 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "abs", int_abs, 0);
rb_define_method(rb_cInteger, "magnitude", int_abs, 0);
+ rb_define_method(rb_cInteger, "===", int_equal, 1);
rb_define_method(rb_cInteger, "==", int_equal, 1);
rb_define_method(rb_cInteger, ">", int_gt, 1);
rb_define_method(rb_cInteger, ">=", int_ge, 1);
@@ -4972,22 +4966,8 @@ Init_Numeric(void)
rb_define_method(rb_cInteger, "size", int_size, 0);
rb_define_method(rb_cInteger, "bit_length", rb_int_bit_length, 0);
- rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);
-
- rb_define_method(rb_cFixnum, "+", fix_plus, 1);
- rb_define_method(rb_cFixnum, "-", fix_minus, 1);
- rb_define_method(rb_cFixnum, "*", fix_mul, 1);
- rb_define_method(rb_cFixnum, "/", fix_div, 1);
- rb_define_method(rb_cFixnum, "%", fix_mod, 1);
-
- rb_define_method(rb_cFixnum, "==", fix_equal, 1);
- rb_define_method(rb_cFixnum, "===", fix_equal, 1);
- rb_define_method(rb_cFixnum, ">", fix_gt, 1);
- rb_define_method(rb_cFixnum, ">=", fix_ge, 1);
- rb_define_method(rb_cFixnum, "<", fix_lt, 1);
- rb_define_method(rb_cFixnum, "<=", fix_le, 1);
-
- rb_define_method(rb_cFixnum, "succ", fix_succ, 0);
+ rb_cFixnum = rb_cInteger;
+ rb_define_const(rb_cObject, "Fixnum", rb_cInteger);
rb_cFloat = rb_define_class("Float", rb_cNumeric);