From 4ef881bd15c9c4e2e9b20da2c091e80d4d530119 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 31 Dec 2006 15:02:22 +0000 Subject: * Merge YARV git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 68 +++++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index e812389c3..43fbfe863 100644 --- a/numeric.c +++ b/numeric.c @@ -11,7 +11,6 @@ **********************************************************************/ #include "ruby.h" -#include "env.h" #include #include #include @@ -180,7 +179,7 @@ rb_num_coerce_relop(VALUE x, VALUE y) static VALUE num_sadded(VALUE x, VALUE name) { - ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */ + // ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */ /* Numerics should be values; singleton_methods should not be added to them */ rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", @@ -1699,7 +1698,7 @@ int_int_p(VALUE num) /* * call-seq: * int.odd? -> true or false - * + * * Returns true if int is an odd number. */ @@ -1707,7 +1706,7 @@ static VALUE int_odd_p(VALUE num) { if (rb_funcall(num, '%', 1, INT2FIX(2)) != INT2FIX(0)) { - return Qtrue; + return Qtrue; } return Qfalse; } @@ -1715,7 +1714,7 @@ int_odd_p(VALUE num) /* * call-seq: * int.even? -> true or false - * + * * Returns true if int is an even number. */ @@ -1723,11 +1722,29 @@ static VALUE int_even_p(VALUE num) { if (rb_funcall(num, '%', 1, INT2FIX(2)) == INT2FIX(0)) { - return Qtrue; + return Qtrue; } return Qfalse; } +/* + * call-seq: + * fixnum.next => integer + * fixnum.succ => integer + * + * Returns the Integer equal to int + 1. + * + * 1.next #=> 2 + * (-1).next #=> 0 + */ + +static VALUE +fix_succ(VALUE num) +{ + long i = FIX2LONG(num) + 1; + return LONG2NUM(i); +} + /* * call-seq: * int.next => integer @@ -2788,28 +2805,36 @@ int_downto(VALUE from, VALUE to) * 0 1 2 3 4 */ +VALUE yarv_invoke_Integer_times_special_block(VALUE); + static VALUE int_dotimes(VALUE num) { - RETURN_ENUMERATOR(num, 0, 0); - if (FIXNUM_P(num)) { - long i, end; + VALUE val; - end = FIX2LONG(num); - for (i=0; i