Project

General

Profile

unify-fixnum-and-bignum.patch

akr (Akira Tanaka), 05/03/2016 10:18 AM

Download (30.5 KB)

View differences:

bignum.c (working copy)
110 110
#define BIGNUM_SET_NEGATIVE_SIGN(b) BIGNUM_SET_SIGN(b, 0)
111 111
#define BIGNUM_SET_POSITIVE_SIGN(b) BIGNUM_SET_SIGN(b, 1)
112 112

  
113
#define bignew(len,sign) bignew_1(rb_cBignum,(len),(sign))
113
#define bignew(len,sign) bignew_1(rb_cInteger,(len),(sign))
114 114

  
115 115
#define BDIGITS_ZERO(ptr, n) do { \
116 116
  BDIGIT *bdigitz_zero_ptr = (ptr); \
......
6669 6669
 */
6670 6670

  
6671 6671
static VALUE
6672
rb_big_coerce(VALUE x, VALUE y)
6672
rb_int_coerce(VALUE x, VALUE y)
6673 6673
{
6674
    if (FIXNUM_P(y)) {
6675
	y = rb_int2big(FIX2LONG(y));
6674
    if (FIXNUM_P(y) || RB_BIGNUM_TYPE_P(y)) {
6675
        return rb_assoc_new(y, x);
6676 6676
    }
6677
    else if (!RB_BIGNUM_TYPE_P(y)) {
6678
	rb_raise(rb_eTypeError, "can't coerce %"PRIsVALUE" to Bignum",
6679
		 rb_obj_class(y));
6677
    else {
6678
        x = rb_Float(x);
6679
        y = rb_Float(y);
6680
        return rb_assoc_new(y, x);
6680 6681
    }
6681
    return rb_assoc_new(y, x);
6682 6682
}
6683 6683

  
6684 6684
VALUE
......
6783 6783
void
6784 6784
Init_Bignum(void)
6785 6785
{
6786
    rb_cBignum = rb_define_class("Bignum", rb_cInteger);
6787

  
6788
    rb_define_method(rb_cBignum, "coerce", rb_big_coerce, 1);
6786
    rb_cBignum = rb_cInteger;
6787
    rb_define_const(rb_cObject, "Bignum", rb_cInteger);
6789 6788

  
6790
    rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
6789
    rb_define_method(rb_cInteger, "coerce", rb_int_coerce, 1);
6791 6790

  
6792 6791
#ifdef USE_GMP
6793 6792
    /* The version of loaded GMP. */
6794
    rb_define_const(rb_cBignum, "GMP_VERSION", rb_sprintf("GMP %s", gmp_version));
6795 6793
    rb_define_const(rb_cInteger, "GMP_VERSION", rb_sprintf("GMP %s", gmp_version));
6796 6794
#endif
6797 6795

  
bootstraptest/test_literal.rb (working copy)
15 15
assert_equal ':sym',            ':sym.inspect'
16 16
assert_equal 'Symbol',          ':sym.class'
17 17
assert_equal '1234',            '1234'
18
assert_equal 'Fixnum',          '1234.class'
18
assert_equal 'Integer',          '1234.class'
19 19
assert_equal '1234',            '1_2_3_4'
20
assert_equal 'Fixnum',          '1_2_3_4.class'
20
assert_equal 'Integer',          '1_2_3_4.class'
21 21
assert_equal '18',              '0x12'
22
assert_equal 'Fixnum',          '0x12.class'
22
assert_equal 'Integer',          '0x12.class'
23 23
assert_equal '15',              '0o17'
24
assert_equal 'Fixnum',          '0o17.class'
24
assert_equal 'Integer',          '0o17.class'
25 25
assert_equal '5',               '0b101'
26
assert_equal 'Fixnum',          '0b101.class'
26
assert_equal 'Integer',          '0b101.class'
27 27
assert_equal '123456789012345678901234567890', '123456789012345678901234567890'
28
assert_equal 'Bignum',          '123456789012345678901234567890.class'
28
assert_equal 'Integer',         '123456789012345678901234567890.class'
29 29
assert_equal '2.0',             '2.0'
30 30
assert_equal 'Float',           '1.3.class'
31 31

  
......
169 169
assert_equal 'c',               'r = ("a".."c"); r.end'
170 170

  
171 171
assert_equal 'String',          '__FILE__.class'
172
assert_equal 'Fixnum',          '__LINE__.class'
172
assert_equal 'Integer',          '__LINE__.class'
173 173

  
174 174
###
175 175

  
error.c (working copy)
525 525
	etype = "nil";
526 526
    }
527 527
    else if (FIXNUM_P(x)) {
528
	etype = "Fixnum";
528
	etype = "Integer";
529 529
    }
530 530
    else if (SYMBOL_P(x)) {
531 531
	etype = "Symbol";
ext/-test-/testutil/extconf.rb (working copy)
1
# frozen_string_literal: false
2
$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
3
$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
4
inits = $srcs.map {|s| File.basename(s, ".*")}
5
inits.delete("init")
6
inits.map! {|s|"X(#{s})"}
7
$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
8
create_makefile("-test-/testutil")
ext/-test-/testutil/init.c (working copy)
1
#include "ruby.h"
2

  
3
#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
4

  
5
void
6
Init_testutil(void)
7
{
8
    VALUE mBug = rb_define_module("Bug");
9
    VALUE klass = rb_define_class_under(mBug, "TestUtil", rb_cObject);
10
    TEST_INIT_FUNCS(init);
11
}
ext/-test-/testutil/integer.c (working copy)
1
#include "internal.h"
2

  
3
static VALUE
4
int_bignum_p(VALUE self)
5
{
6
    return RB_TYPE_P(self, T_BIGNUM) ? Qtrue : Qfalse;
7
}
8

  
9
static VALUE
10
int_fixnum_p(VALUE self)
11
{
12
    return FIXNUM_P(self) ? Qtrue : Qfalse;
13
}
14

  
15
static VALUE
16
rb_int_to_bignum(VALUE x)
17
{
18
    if (FIXNUM_P(x))
19
        x = rb_int2big(FIX2LONG(x));
20
    return x;
21
}
22

  
23
void
24
Init_integer(VALUE klass)
25
{
26
    rb_define_method(rb_cInteger, "bignum?", int_bignum_p, 0);
27
    rb_define_method(rb_cInteger, "fixnum?", int_fixnum_p, 0);
28
    rb_define_method(rb_cInteger, "to_bignum", rb_int_to_bignum, 0);
29
}
ext/json/generator/generator.c (working copy)
7 7
#endif
8 8

  
9 9
static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
10
             mHash, mArray, mFixnum, mBignum, mFloat, mString, mString_Extend,
10
             mHash, mArray, mInteger, mFixnum, mBignum, mFloat, mString, mString_Extend,
11 11
             mTrueClass, mFalseClass, mNilClass, eGeneratorError,
12 12
             eNestingError, CRegexp_MULTILINE, CJSON_SAFE_STATE_PROTOTYPE,
13 13
             i_SAFE_STATE_PROTOTYPE;
......
347 347
 *
348 348
 * Returns a JSON string representation for this Integer number.
349 349
 */
350
static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self)
351
{
352
    GENERATE_JSON(integer);
353
}
354

  
355
/*
356
 * call-seq: to_json(*)
357
 *
358
 * Returns a JSON string representation for this Integer number.
359
 */
350 360
static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self)
351 361
{
352 362
    GENERATE_JSON(fixnum);
......
825 835
    fbuffer_append_str(buffer, tmp);
826 836
}
827 837

  
838
static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
839
{
840
    if (FIXNUM_P(obj))
841
        generate_json_fixnum(buffer, Vstate, state, obj);
842
    else
843
        generate_json_bignum(buffer, Vstate, state, obj);
844
}
845

  
828 846
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
829 847
{
830 848
    double value = RFLOAT_VALUE(obj);
......
858 876
        generate_json_false(buffer, Vstate, state, obj);
859 877
    } else if (obj == Qtrue) {
860 878
        generate_json_true(buffer, Vstate, state, obj);
861
    } else if (klass == rb_cFixnum) {
879
    } else if (FIXNUM_P(obj)) {
862 880
        generate_json_fixnum(buffer, Vstate, state, obj);
863
    } else if (klass == rb_cBignum) {
881
    } else if (RB_TYPE_P(obj, T_BIGNUM)) {
864 882
        generate_json_bignum(buffer, Vstate, state, obj);
865 883
    } else if (klass == rb_cFloat) {
866 884
        generate_json_float(buffer, Vstate, state, obj);
......
1402 1420
    rb_define_method(mHash, "to_json", mHash_to_json, -1);
1403 1421
    mArray = rb_define_module_under(mGeneratorMethods, "Array");
1404 1422
    rb_define_method(mArray, "to_json", mArray_to_json, -1);
1405
    mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum");
1406
    rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1);
1407
    mBignum = rb_define_module_under(mGeneratorMethods, "Bignum");
1408
    rb_define_method(mBignum, "to_json", mBignum_to_json, -1);
1423
    if (rb_cInteger == rb_cFixnum) {
1424
        mInteger = rb_define_module_under(mGeneratorMethods, "Integer");
1425
        rb_define_method(mInteger, "to_json", mInteger_to_json, -1);
1426
    }
1427
    else {
1428
        mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum");
1429
        rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1);
1430
        mBignum = rb_define_module_under(mGeneratorMethods, "Bignum");
1431
        rb_define_method(mBignum, "to_json", mBignum_to_json, -1);
1432
    }
1409 1433
    mFloat = rb_define_module_under(mGeneratorMethods, "Float");
1410 1434
    rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
1411 1435
    mString = rb_define_module_under(mGeneratorMethods, "String");
ext/json/generator/generator.h (working copy)
122 122
static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
123 123
static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
124 124
static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
125
static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
125 126
static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
126 127
static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
127 128
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
include/ruby/ruby.h (working copy)
1968 1968
rb_class_of(VALUE obj)
1969 1969
{
1970 1970
    if (RB_IMMEDIATE_P(obj)) {
1971
	if (RB_FIXNUM_P(obj)) return rb_cFixnum;
1971
	if (RB_FIXNUM_P(obj)) return rb_cInteger;
1972 1972
	if (RB_FLONUM_P(obj)) return rb_cFloat;
1973 1973
	if (obj == RUBY_Qtrue)  return rb_cTrueClass;
1974 1974
	if (RB_STATIC_SYM_P(obj)) return rb_cSymbol;
insns.def (working copy)
1345 1345
      case T_STRING:
1346 1346
	if (BASIC_OP_UNREDEFINED_P(BOP_EQQ,
1347 1347
				   SYMBOL_REDEFINED_OP_FLAG |
1348
				   FIXNUM_REDEFINED_OP_FLAG |
1348
				   INTEGER_REDEFINED_OP_FLAG |
1349 1349
				   FLOAT_REDEFINED_OP_FLAG |
1350
				   BIGNUM_REDEFINED_OP_FLAG |
1351 1350
				   NIL_REDEFINED_OP_FLAG    |
1352 1351
				   TRUE_REDEFINED_OP_FLAG   |
1353 1352
				   FALSE_REDEFINED_OP_FLAG  |
......
1380 1379
(VALUE val)
1381 1380
{
1382 1381
    if (FIXNUM_2_P(recv, obj) &&
1383
	BASIC_OP_UNREDEFINED_P(BOP_PLUS,FIXNUM_REDEFINED_OP_FLAG)) {
1382
	BASIC_OP_UNREDEFINED_P(BOP_PLUS,INTEGER_REDEFINED_OP_FLAG)) {
1384 1383
	/* fixnum + fixnum */
1385 1384
#ifndef LONG_LONG_VALUE
1386 1385
	val = (recv + (obj & (~1)));
......
1438 1437
(VALUE val)
1439 1438
{
1440 1439
    if (FIXNUM_2_P(recv, obj) &&
1441
	BASIC_OP_UNREDEFINED_P(BOP_MINUS, FIXNUM_REDEFINED_OP_FLAG)) {
1440
	BASIC_OP_UNREDEFINED_P(BOP_MINUS, INTEGER_REDEFINED_OP_FLAG)) {
1442 1441
	long a, b, c;
1443 1442

  
1444 1443
	a = FIX2LONG(recv);
......
1480 1479
(VALUE val)
1481 1480
{
1482 1481
    if (FIXNUM_2_P(recv, obj) &&
1483
	BASIC_OP_UNREDEFINED_P(BOP_MULT, FIXNUM_REDEFINED_OP_FLAG)) {
1482
	BASIC_OP_UNREDEFINED_P(BOP_MULT, INTEGER_REDEFINED_OP_FLAG)) {
1484 1483
	val = rb_fix_mul_fix(recv, obj);
1485 1484
    }
1486 1485
    else if (FLONUM_2_P(recv, obj) &&
......
1516 1515
(VALUE val)
1517 1516
{
1518 1517
    if (FIXNUM_2_P(recv, obj) &&
1519
	BASIC_OP_UNREDEFINED_P(BOP_DIV, FIXNUM_REDEFINED_OP_FLAG)) {
1518
	BASIC_OP_UNREDEFINED_P(BOP_DIV, INTEGER_REDEFINED_OP_FLAG)) {
1520 1519
	if (FIX2LONG(obj) == 0) goto INSN_LABEL(normal_dispatch);
1521 1520
	val = rb_fix_div_fix(recv, obj);
1522 1521
    }
......
1553 1552
(VALUE val)
1554 1553
{
1555 1554
    if (FIXNUM_2_P(recv, obj) &&
1556
	BASIC_OP_UNREDEFINED_P(BOP_MOD, FIXNUM_REDEFINED_OP_FLAG )) {
1555
	BASIC_OP_UNREDEFINED_P(BOP_MOD, INTEGER_REDEFINED_OP_FLAG )) {
1557 1556
	if (FIX2LONG(obj) == 0) goto INSN_LABEL(normal_dispatch);
1558 1557
	val = rb_fix_mod_fix(recv, obj);
1559 1558
    }
......
1643 1642
(VALUE val)
1644 1643
{
1645 1644
    if (FIXNUM_2_P(recv, obj) &&
1646
	BASIC_OP_UNREDEFINED_P(BOP_LT, FIXNUM_REDEFINED_OP_FLAG)) {
1645
	BASIC_OP_UNREDEFINED_P(BOP_LT, INTEGER_REDEFINED_OP_FLAG)) {
1647 1646
	SIGNED_VALUE a = recv, b = obj;
1648 1647

  
1649 1648
	if (a < b) {
......
1687 1686
(VALUE val)
1688 1687
{
1689 1688
    if (FIXNUM_2_P(recv, obj) &&
1690
	BASIC_OP_UNREDEFINED_P(BOP_LE, FIXNUM_REDEFINED_OP_FLAG)) {
1689
	BASIC_OP_UNREDEFINED_P(BOP_LE, INTEGER_REDEFINED_OP_FLAG)) {
1691 1690
	SIGNED_VALUE a = recv, b = obj;
1692 1691

  
1693 1692
	if (a <= b) {
......
1722 1721
(VALUE val)
1723 1722
{
1724 1723
    if (FIXNUM_2_P(recv, obj) &&
1725
	BASIC_OP_UNREDEFINED_P(BOP_GT, FIXNUM_REDEFINED_OP_FLAG)) {
1724
	BASIC_OP_UNREDEFINED_P(BOP_GT, INTEGER_REDEFINED_OP_FLAG)) {
1726 1725
	SIGNED_VALUE a = recv, b = obj;
1727 1726

  
1728 1727
	if (a > b) {
......
1766 1765
(VALUE val)
1767 1766
{
1768 1767
    if (FIXNUM_2_P(recv, obj) &&
1769
	BASIC_OP_UNREDEFINED_P(BOP_GE, FIXNUM_REDEFINED_OP_FLAG)) {
1768
	BASIC_OP_UNREDEFINED_P(BOP_GE, INTEGER_REDEFINED_OP_FLAG)) {
1770 1769
	SIGNED_VALUE a = recv, b = obj;
1771 1770

  
1772 1771
	if (a >= b) {
......
2047 2046
{
2048 2047
    if (SPECIAL_CONST_P(recv)) {
2049 2048
	if (FIXNUM_P(recv) &&
2050
	    BASIC_OP_UNREDEFINED_P(BOP_SUCC, FIXNUM_REDEFINED_OP_FLAG)) {
2049
	    BASIC_OP_UNREDEFINED_P(BOP_SUCC, INTEGER_REDEFINED_OP_FLAG)) {
2051 2050
	    const VALUE obj = INT2FIX(1);
2052 2051
	    /* fixnum + INT2FIX(1) */
2053 2052
	    val = (recv + (obj & (~1)));
lib/mathn.rb (working copy)
55 55
end
56 56

  
57 57
##
58
# When mathn is required, Fixnum's division is enhanced to
58
# When mathn is required, Integer's division is enhanced to
59 59
# return more precise values from mathematical expressions.
60 60
#
61 61
#   2/3*3  # => 0
62 62
#   require 'mathn'
63 63
#   2/3*3  # => 2
64

  
65
class Fixnum
66
  remove_method :/
67

  
68
  ##
69
  # +/+ defines the Rational division for Fixnum.
70
  #
71
  #   1/3  # => (1/3)
72

  
73
  alias / quo
74
end
75

  
76
##
77
# When mathn is required Bignum's division is enhanced to
78
# return more precise values from mathematical expressions.
79 64
#
80 65
#   (2**72) / ((2**70) * 3)  # => 4/3
81 66

  
numeric.c (working copy)
2951 2951
 *     (-1).succ   #=> 0
2952 2952
 */
2953 2953

  
2954
static VALUE
2955
fix_succ(VALUE num)
2956
{
2957
    long i = FIX2LONG(num) + 1;
2958
    return LONG2NUM(i);
2959
}
2960

  
2961 2954
VALUE
2962 2955
rb_int_succ(VALUE num)
2963 2956
{
......
4962 4955
    rb_define_method(rb_cInteger, "abs", int_abs, 0);
4963 4956
    rb_define_method(rb_cInteger, "magnitude", int_abs, 0);
4964 4957

  
4958
    rb_define_method(rb_cInteger, "===", int_equal, 1);
4965 4959
    rb_define_method(rb_cInteger, "==", int_equal, 1);
4966 4960
    rb_define_method(rb_cInteger, ">", int_gt, 1);
4967 4961
    rb_define_method(rb_cInteger, ">=", int_ge, 1);
......
4980 4974
    rb_define_method(rb_cInteger, "size", int_size, 0);
4981 4975
    rb_define_method(rb_cInteger, "bit_length", rb_int_bit_length, 0);
4982 4976

  
4983
    rb_cFixnum = rb_define_class("Fixnum", rb_cInteger);
4984

  
4985
    rb_define_method(rb_cFixnum, "+", fix_plus, 1);
4986
    rb_define_method(rb_cFixnum, "-", fix_minus, 1);
4987
    rb_define_method(rb_cFixnum, "*", fix_mul, 1);
4988
    rb_define_method(rb_cFixnum, "/", fix_div, 1);
4989
    rb_define_method(rb_cFixnum, "%", fix_mod, 1);
4990

  
4991
    rb_define_method(rb_cFixnum, "==", fix_equal, 1);
4992
    rb_define_method(rb_cFixnum, "===", fix_equal, 1);
4993
    rb_define_method(rb_cFixnum, ">",  fix_gt, 1);
4994
    rb_define_method(rb_cFixnum, ">=", fix_ge, 1);
4995
    rb_define_method(rb_cFixnum, "<",  fix_lt, 1);
4996
    rb_define_method(rb_cFixnum, "<=", fix_le, 1);
4997

  
4998
    rb_define_method(rb_cFixnum, "succ", fix_succ, 0);
4977
    rb_cFixnum = rb_cInteger;
4978
    rb_define_const(rb_cObject, "Fixnum", rb_cInteger);
4999 4979

  
5000 4980
    rb_cFloat  = rb_define_class("Float", rb_cNumeric);
5001 4981

  
sprintf.c (working copy)
1349 1349
	    if (value == rb_cNilClass) {
1350 1350
		return LITERAL("nil");
1351 1351
	    }
1352
	    else if (value == rb_cFixnum) {
1353
		return LITERAL("Fixnum");
1352
	    else if (value == rb_cInteger) {
1353
		return LITERAL("Integer");
1354 1354
	    }
1355 1355
	    else if (value == rb_cSymbol) {
1356 1356
		return LITERAL("Symbol");
test/-ext-/num2int/test_num2int.rb (working copy)
104 104
  end
105 105

  
106 106
  def assert_fix2i_success(type, num, result=num)
107
    return if !num.kind_of?(Fixnum)
107
    return if !num.fixnum?
108 108
    func = "FIX2#{type}".upcase
109 109
    assert_fix2i_success_internal(result.to_s, func, num)
110 110
  end
......
116 116
  end
117 117

  
118 118
  def assert_fix2i_error(type, num)
119
    return if !num.kind_of?(Fixnum)
119
    return if !num.fixnum?
120 120
    func = "FIX2#{type}".upcase
121 121
    assert_num2i_error_internal(func, num)
122 122
  end
test/-ext-/typeddata/test_typeddata.rb (working copy)
10 10

  
11 11
    assert_raise_with_message(TypeError, "wrong argument type Symbol (expected typed_data)") {Bug::TypedData.check(:e)}
12 12

  
13
    assert_raise_with_message(TypeError, "wrong argument type Fixnum (expected typed_data)") {Bug::TypedData.check(0)}
13
    assert_raise_with_message(TypeError, "wrong argument type Integer (expected typed_data)") {Bug::TypedData.check(0)}
14 14

  
15 15
    assert_raise_with_message(TypeError, "wrong argument type String (expected typed_data)") {Bug::TypedData.check("a")}
16 16

  
test/lib/test/unit/assertions.rb (working copy)
772 772
      end
773 773

  
774 774
      def assert_fixnum(v, msg=nil)
775
        assert_instance_of(Fixnum, v, msg)
775
        assert_instance_of(Integer, v, msg)
776
        assert_predicate(v, :fixnum?, msg)
776 777
      end
777 778

  
778 779
      def assert_bignum(v, msg=nil)
779
        assert_instance_of(Bignum, v, msg)
780
        assert_instance_of(Integer, v, msg)
781
        assert_predicate(v, :bignum?, msg)
780 782
      end
781 783

  
782 784
      class << (AssertFile = Struct.new(:failure_message).new)
test/lib/test/unit.rb (working copy)
8 8
require_relative '../envutil'
9 9
require 'test/unit/testcase'
10 10
require 'optparse'
11
require '-test-/testutil'
11 12

  
12 13
# See Test::Unit
13 14
module Test
test/ruby/test_bignum.rb (working copy)
16 16
  end
17 17
  BIGNUM_MIN_BITS = n
18 18

  
19
  T_ZERO = b.coerce(0).first
20
  T_ONE  = b.coerce(1).first
21
  T_MONE = b.coerce(-1).first
22
  T31  = b.coerce(2**31).first   # 2147483648
23
  T31P = b.coerce(T31 - 1).first # 2147483647
24
  T32  = b.coerce(2**32).first   # 4294967296
25
  T32P = b.coerce(T32 - 1).first # 4294967295
26
  T64  = b.coerce(2**64).first   # 18446744073709551616
27
  T64P = b.coerce(T64 - 1).first # 18446744073709551615
28
  T1024  = b.coerce(2**1024).first
29
  T1024P = b.coerce(T1024 - 1).first
19
  T_ZERO = 0.to_bignum
20
  T_ONE  = 1.to_bignum
21
  T_MONE = (-1).to_bignum
22
  T31  = (2**31).to_bignum   # 2147483648
23
  T31P = (T31 - 1).to_bignum # 2147483647
24
  T32  = (2**32).to_bignum   # 4294967296
25
  T32P = (T32 - 1).to_bignum # 4294967295
26
  T64  = (2**64).to_bignum   # 18446744073709551616
27
  T64P = (T64 - 1).to_bignum # 18446744073709551615
28
  T1024  = (2**1024).to_bignum
29
  T1024P = (T1024 - 1).to_bignum
30 30

  
31 31
  def setup
32 32
    @verbose = $VERBOSE
......
656 656
  end
657 657

  
658 658
  def test_too_big_to_s
659
    if (big = 2**31-1).is_a?(Fixnum)
659
    if (big = 2**31-1).fixnum?
660 660
      return
661 661
    end
662 662
    assert_raise_with_message(RangeError, /too big to convert/) {(1 << big).to_s}
test/ruby/test_hash.rb (working copy)
826 826
  def test_create
827 827
    assert_equal({1=>2, 3=>4}, @cls[[[1,2],[3,4]]])
828 828
    assert_raise(ArgumentError) { Hash[0, 1, 2] }
829
    assert_warning(/wrong element type Fixnum at 1 /) {@cls[[[1, 2], 3]]}
829
    assert_warning(/wrong element type Integer at 1 /) {@cls[[[1, 2], 3]]}
830 830
    bug5406 = '[ruby-core:39945]'
831 831
    assert_raise(ArgumentError, bug5406) { @cls[[[1, 2], [3, 4, 5]]] }
832 832
    assert_equal({1=>2, 3=>4}, @cls[1,2,3,4])
test/ruby/test_integer.rb (working copy)
109 109

  
110 110
  def test_succ
111 111
    assert_equal(2, 1.send(:succ))
112

  
113
    Fixnum.class_eval do
114
      alias succ_bak succ
115
      remove_method :succ
116
    end
117

  
118
    assert_equal(2, 1.succ)
119
    assert_equal(4294967297, 4294967296.succ)
120

  
121
  ensure
122
    Fixnum.class_eval do
123
      alias succ succ_bak
124
      remove_method :succ_bak
125
    end
126 112
  end
127 113

  
128 114
  def test_chr
test/ruby/test_numeric.rb (working copy)
28 28
    assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"}
29 29

  
30 30
    bug10711 = '[ruby-core:67405] [Bug #10711]'
31
    exp = "1.2 can't be coerced into Fixnum"
31
    exp = "1.2 can't be coerced into Integer"
32 32
    assert_raise_with_message(TypeError, exp, bug10711) { 1 & 1.2 }
33 33
  end
34 34

  
test/ruby/test_optimization.rb (working copy)
29 29
    assert_bignum FIXNUM_MAX + 1
30 30

  
31 31
    assert_equal 21, 10 + 11
32
    assert_redefine_method('Fixnum', '+', 'assert_equal 11, 10 + 11')
32
    assert_redefine_method('Integer', '+', 'assert_equal 11, 10 + 11')
33 33
  end
34 34

  
35 35
  def test_fixnum_minus
......
38 38
    assert_bignum FIXNUM_MIN - 1
39 39

  
40 40
    assert_equal 5, 8 - 3
41
    assert_redefine_method('Fixnum', '-', 'assert_equal 3, 8 - 3')
41
    assert_redefine_method('Integer', '-', 'assert_equal 3, 8 - 3')
42 42
  end
43 43

  
44 44
  def test_fixnum_mul
45 45
    assert_equal 15, 3 * 5
46
    assert_redefine_method('Fixnum', '*', 'assert_equal 5, 3 * 5')
46
    assert_redefine_method('Integer', '*', 'assert_equal 5, 3 * 5')
47 47
  end
48 48

  
49 49
  def test_fixnum_div
50 50
    assert_equal 3, 15 / 5
51
    assert_redefine_method('Fixnum', '/', 'assert_equal 5, 15 / 5')
51
    assert_redefine_method('Integer', '/', 'assert_equal 5, 15 / 5')
52 52
  end
53 53

  
54 54
  def test_fixnum_mod
55 55
    assert_equal 1, 8 % 7
56
    assert_redefine_method('Fixnum', '%', 'assert_equal 7, 8 % 7')
56
    assert_redefine_method('Integer', '%', 'assert_equal 7, 8 % 7')
57 57
  end
58 58

  
59 59
  def test_float_plus
test/ruby/test_regexp.rb (working copy)
1013 1013
  def test_error_message_on_failed_conversion
1014 1014
    bug7539 = '[ruby-core:50733]'
1015 1015
    assert_equal false, /x/=== 42
1016
    assert_raise_with_message(TypeError, 'no implicit conversion of Fixnum into String', bug7539) {
1016
    assert_raise_with_message(TypeError, 'no implicit conversion of Integer into String', bug7539) {
1017 1017
      Regexp.quote(42)
1018 1018
    }
1019 1019
  end
test/ruby/test_settracefunc.rb (working copy)
35 35
                 events.shift)
36 36
    assert_equal(["line", 4, __method__, self.class],
37 37
                 events.shift)
38
    assert_equal(["c-call", 4, :+, Fixnum],
38
    assert_equal(["c-call", 4, :+, Integer],
39 39
                 events.shift)
40
    assert_equal(["c-return", 4, :+, Fixnum],
40
    assert_equal(["c-return", 4, :+, Integer],
41 41
                 events.shift)
42 42
    assert_equal(["line", 5, __method__, self.class],
43 43
                 events.shift)
......
73 73
                 events.shift)
74 74
    assert_equal(["line", 5, :add, self.class],
75 75
                 events.shift)
76
    assert_equal(["c-call", 5, :+, Fixnum],
76
    assert_equal(["c-call", 5, :+, Integer],
77 77
                 events.shift)
78
    assert_equal(["c-return", 5, :+, Fixnum],
78
    assert_equal(["c-return", 5, :+, Integer],
79 79
                 events.shift)
80 80
    assert_equal(["return", 6, :add, self.class],
81 81
                 events.shift)
......
353 353
     ["c-return", 8, :new, Class],
354 354
     ["call", 4, :foo, ThreadTraceInnerClass],
355 355
     ["line", 5, :foo, ThreadTraceInnerClass],
356
     ["c-call", 5, :+, Fixnum],
357
     ["c-return", 5, :+, Fixnum],
356
     ["c-call", 5, :+, Integer],
357
     ["c-return", 5, :+, Integer],
358 358
     ["return", 6, :foo, ThreadTraceInnerClass],
359 359
     ["line", 9, __method__, self.class],
360 360
     ["c-call", 9, :set_trace_func, Thread]].each do |e|
......
768 768
    # pp events
769 769
    # expected_events =
770 770
    [[:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil],
771
     [:c_call, :times, Integer, Fixnum, nil],
771
     [:c_call, :times, Integer, Integer, nil],
772 772
     [:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil],
773 773
     [:b_return, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, 3],
774
     [:c_return, :times, Integer, Fixnum, 1],
774
     [:c_return, :times, Integer, Integer, 1],
775 775
     [:call, :method_for_test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil],
776 776
     [:b_call, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, nil],
777 777
     [:b_return, :test_tracepoint_block, TestSetTraceFunc, TestSetTraceFunc, 4],
vm.c (working copy)
1385 1385
static int
1386 1386
vm_redefinition_check_flag(VALUE klass)
1387 1387
{
1388
    if (klass == rb_cFixnum) return FIXNUM_REDEFINED_OP_FLAG;
1388
    if (klass == rb_cInteger) return INTEGER_REDEFINED_OP_FLAG;
1389 1389
    if (klass == rb_cFloat)  return FLOAT_REDEFINED_OP_FLAG;
1390 1390
    if (klass == rb_cString) return STRING_REDEFINED_OP_FLAG;
1391 1391
    if (klass == rb_cArray)  return ARRAY_REDEFINED_OP_FLAG;
1392 1392
    if (klass == rb_cHash)   return HASH_REDEFINED_OP_FLAG;
1393
    if (klass == rb_cBignum) return BIGNUM_REDEFINED_OP_FLAG;
1394 1393
    if (klass == rb_cSymbol) return SYMBOL_REDEFINED_OP_FLAG;
1395 1394
    if (klass == rb_cTime)   return TIME_REDEFINED_OP_FLAG;
1396 1395
    if (klass == rb_cRegexp) return REGEXP_REDEFINED_OP_FLAG;
......
1458 1457

  
1459 1458
#define OP(mid_, bop_) (mid = id##mid_, bop = BOP_##bop_, ruby_vm_redefined_flag[bop] = 0)
1460 1459
#define C(k) add_opt_method(rb_c##k, mid, bop)
1461
    OP(PLUS, PLUS), (C(Fixnum), C(Float), C(String), C(Array));
1462
    OP(MINUS, MINUS), (C(Fixnum), C(Float));
1463
    OP(MULT, MULT), (C(Fixnum), C(Float));
1464
    OP(DIV, DIV), (C(Fixnum), C(Float));
1465
    OP(MOD, MOD), (C(Fixnum), C(Float));
1466
    OP(Eq, EQ), (C(Fixnum), C(Float), C(String));
1467
    OP(Eqq, EQQ), (C(Fixnum), C(Bignum), C(Float), C(Symbol), C(String),
1460
    OP(PLUS, PLUS), (C(Integer), C(Float), C(String), C(Array));
1461
    OP(MINUS, MINUS), (C(Integer), C(Float));
1462
    OP(MULT, MULT), (C(Integer), C(Float));
1463
    OP(DIV, DIV), (C(Integer), C(Float));
1464
    OP(MOD, MOD), (C(Integer), C(Float));
1465
    OP(Eq, EQ), (C(Integer), C(Float), C(String));
1466
    OP(Eqq, EQQ), (C(Integer), C(Float), C(Symbol), C(String),
1468 1467
		   C(NilClass), C(TrueClass), C(FalseClass));
1469
    OP(LT, LT), (C(Fixnum), C(Float));
1470
    OP(LE, LE), (C(Fixnum), C(Float));
1471
    OP(GT, GT), (C(Fixnum), C(Float));
1472
    OP(GE, GE), (C(Fixnum), C(Float));
1468
    OP(LT, LT), (C(Integer), C(Float));
1469
    OP(LE, LE), (C(Integer), C(Float));
1470
    OP(GT, GT), (C(Integer), C(Float));
1471
    OP(GE, GE), (C(Integer), C(Float));
1473 1472
    OP(LTLT, LTLT), (C(String), C(Array));
1474 1473
    OP(AREF, AREF), (C(Array), C(Hash));
1475 1474
    OP(ASET, ASET), (C(Array), C(Hash));
1476 1475
    OP(Length, LENGTH), (C(Array), C(String), C(Hash));
1477 1476
    OP(Size, SIZE), (C(Array), C(String), C(Hash));
1478 1477
    OP(EmptyP, EMPTY_P), (C(Array), C(String), C(Hash));
1479
    OP(Succ, SUCC), (C(Fixnum), C(String), C(Time));
1478
    OP(Succ, SUCC), (C(Integer), C(String), C(Time));
1480 1479
    OP(EqTilde, MATCH), (C(Regexp), C(String));
1481 1480
    OP(Freeze, FREEZE), (C(String));
1482 1481
    OP(Max, MAX), (C(Array));
vm_core.h (working copy)
569 569
#define RUBY_VM_FIBER_MACHINE_STACK_SIZE_MIN  (  16 * 1024 * sizeof(VALUE)) /*   64 KB or  128 KB */
570 570

  
571 571
/* optimize insn */
572
#define FIXNUM_REDEFINED_OP_FLAG (1 << 0)
572
#define INTEGER_REDEFINED_OP_FLAG (1 << 0)
573 573
#define FLOAT_REDEFINED_OP_FLAG  (1 << 1)
574 574
#define STRING_REDEFINED_OP_FLAG (1 << 2)
575 575
#define ARRAY_REDEFINED_OP_FLAG  (1 << 3)
576 576
#define HASH_REDEFINED_OP_FLAG   (1 << 4)
577
#define BIGNUM_REDEFINED_OP_FLAG (1 << 5)
577
/* #define BIGNUM_REDEFINED_OP_FLAG (1 << 5) */
578 578
#define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
579 579
#define TIME_REDEFINED_OP_FLAG   (1 << 7)
580 580
#define REGEXP_REDEFINED_OP_FLAG (1 << 8)
vm_insnhelper.c (working copy)
1157 1157
opt_eq_func(VALUE recv, VALUE obj, CALL_INFO ci, CALL_CACHE cc)
1158 1158
{
1159 1159
    if (FIXNUM_2_P(recv, obj) &&
1160
	BASIC_OP_UNREDEFINED_P(BOP_EQ, FIXNUM_REDEFINED_OP_FLAG)) {
1160
	BASIC_OP_UNREDEFINED_P(BOP_EQ, INTEGER_REDEFINED_OP_FLAG)) {
1161 1161
	return (recv == obj) ? Qtrue : Qfalse;
1162 1162
    }
1163 1163
    else if (FLONUM_2_P(recv, obj) &&