aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-26 12:09:40 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-26 12:09:40 +0000
commit69fbb21c12336810b0864f213c6a401c75967c3f (patch)
tree022940cb1a0221c32c731848104b4f2f9642500a
parent8f045eddb2dcd171b98a4dd6b018441acf4b1048 (diff)
downloadruby-69fbb21c12336810b0864f213c6a401c75967c3f.tar.gz
{Fixnum,Bignum}#>> is unified into Integer.
* numeric.c (rb_int_rshift): {Fixnum,Bignum}#>> is unified into Integer. * bignum.c (rb_big_rshift): Don't define Bignum#>>. * internal.h (rb_big_rshift): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--bignum.c9
-rw-r--r--numeric.c28
3 files changed, 29 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 2133a36c48..de176fc9fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Apr 26 20:59:40 2016 Tanaka Akira <akr@fsij.org>
+
+ * numeric.c (rb_int_rshift): {Fixnum,Bignum}#>> is unified into
+ Integer.
+
+ * bignum.c (rb_big_rshift): Don't define Bignum#>>.
+
+ * internal.h (rb_big_rshift): Declared.
+
Tue Apr 26 20:46:16 2016 Tanaka Akira <akr@fsij.org>
* numeric.c (int_size): {Fixnum,Bignum}#size is unified into Integer.
diff --git a/bignum.c b/bignum.c
index 335304204e..9d908a741b 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6748,14 +6748,6 @@ rb_big_lshift(VALUE x, VALUE y)
}
}
-
-/*
- * call-seq:
- * big >> numeric -> integer
- *
- * Shifts big right _numeric_ positions (left if _numeric_ is negative).
- */
-
VALUE
rb_big_rshift(VALUE x, VALUE y)
{
@@ -7022,7 +7014,6 @@ Init_Bignum(void)
rb_define_method(rb_cBignum, "^", rb_big_xor, 1);
rb_define_method(rb_cBignum, "~", rb_big_neg, 0);
rb_define_method(rb_cBignum, "<<", rb_big_lshift, 1);
- rb_define_method(rb_cBignum, ">>", rb_big_rshift, 1);
rb_define_method(rb_cBignum, "[]", rb_big_aref, 1);
rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
diff --git a/numeric.c b/numeric.c
index 4ec8f3e0c3..f80991ae40 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3968,13 +3968,6 @@ fix_lshift(long val, unsigned long width)
return LONG2NUM(val);
}
-/*
- * call-seq:
- * fix >> count -> integer
- *
- * Shifts +fix+ right +count+ positions, or left if +count+ is negative.
- */
-
static VALUE
rb_fix_rshift(VALUE x, VALUE y)
{
@@ -4002,6 +3995,25 @@ fix_rshift(long val, unsigned long i)
}
/*
+ * call-seq:
+ * int >> count -> integer
+ *
+ * Shifts +int+ right +count+ positions, or left if +count+ is negative.
+ */
+
+static VALUE
+rb_int_rshift(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return rb_fix_rshift(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_rshift(x, y);
+ }
+ return Qnil;
+}
+
+/*
* call-seq:
* fix[n] -> 0, 1
*
@@ -4682,7 +4694,7 @@ Init_Numeric(void)
rb_define_method(rb_cFixnum, "[]", fix_aref, 1);
rb_define_method(rb_cFixnum, "<<", rb_fix_lshift, 1);
- rb_define_method(rb_cFixnum, ">>", rb_fix_rshift, 1);
+ rb_define_method(rb_cInteger, ">>", rb_int_rshift, 1);
rb_define_method(rb_cInteger, "size", int_size, 0);
rb_define_method(rb_cInteger, "bit_length", rb_int_bit_length, 0);