aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-26 12:23:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-26 12:23:05 +0000
commit06ca50338b15d2931c0fa04faa718d00e71092f7 (patch)
tree97d0dbf23437c1210431c17aeb082dfddcbe67d3
parent69fbb21c12336810b0864f213c6a401c75967c3f (diff)
downloadruby-06ca50338b15d2931c0fa04faa718d00e71092f7.tar.gz
{Fixnum,Bignum}#<< is unified into Integer.
* numeric.c (rb_int_lshift): {Fixnum,Bignum}#<< is unified into Integer. * bignum.c (rb_big_lshift): Don't define Bignum#<<. * internal.h (rb_big_lshift): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--bignum.c1
-rw-r--r--numeric.c28
3 files changed, 29 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index de176fc9fe..8039dad72b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Apr 26 21:11:02 2016 Tanaka Akira <akr@fsij.org>
+
+ * numeric.c (rb_int_lshift): {Fixnum,Bignum}#<< is unified into
+ Integer.
+
+ * bignum.c (rb_big_lshift): Don't define Bignum#<<.
+
+ * internal.h (rb_big_lshift): Declared.
+
Tue Apr 26 20:59:40 2016 Tanaka Akira <akr@fsij.org>
* numeric.c (rb_int_rshift): {Fixnum,Bignum}#>> is unified into
diff --git a/bignum.c b/bignum.c
index 9d908a741b..db63e0160c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -7013,7 +7013,6 @@ Init_Bignum(void)
rb_define_method(rb_cBignum, "|", rb_big_or, 1);
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_aref, 1);
rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
diff --git a/numeric.c b/numeric.c
index f80991ae40..36432b27b4 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3936,13 +3936,6 @@ fix_xor(VALUE x, VALUE y)
return rb_funcall(x, '^', 1, y);
}
-/*
- * call-seq:
- * fix << count -> integer
- *
- * Shifts +fix+ left +count+ positions, or right if +count+ is negative.
- */
-
static VALUE
rb_fix_lshift(VALUE x, VALUE y)
{
@@ -3968,6 +3961,25 @@ fix_lshift(long val, unsigned long width)
return LONG2NUM(val);
}
+/*
+ * call-seq:
+ * fix << count -> integer
+ *
+ * Shifts +fix+ left +count+ positions, or right if +count+ is negative.
+ */
+
+static VALUE
+rb_int_lshift(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return rb_fix_lshift(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_lshift(x, y);
+ }
+ return Qnil;
+}
+
static VALUE
rb_fix_rshift(VALUE x, VALUE y)
{
@@ -4693,7 +4705,7 @@ Init_Numeric(void)
rb_define_method(rb_cFixnum, "^", fix_xor, 1);
rb_define_method(rb_cFixnum, "[]", fix_aref, 1);
- rb_define_method(rb_cFixnum, "<<", rb_fix_lshift, 1);
+ rb_define_method(rb_cInteger, "<<", rb_int_lshift, 1);
rb_define_method(rb_cInteger, ">>", rb_int_rshift, 1);
rb_define_method(rb_cInteger, "size", int_size, 0);