]> gitweb.factorcode.org Git - factor.git/commitdiff
string hashcodes are fixnums
authorSlava Pestov <slava@factorcode.org>
Sun, 29 Aug 2004 19:56:30 +0000 (19:56 +0000)
committerSlava Pestov <slava@factorcode.org>
Sun, 29 Aug 2004 19:56:30 +0000 (19:56 +0000)
TODO.FACTOR.txt
native/arithmetic.c
native/arithmetic.h
native/fixnum.c
native/memory.c
native/s48_bignum.c
native/string.c
native/word.c

index bbd9d6c13218e28e1c244d9096f0ac9cb6f59374..673606eb1375cb5081213b5357a632dba81be4d1 100644 (file)
@@ -6,7 +6,6 @@
   - index.html\r
   - if a directory is requested and URL does not end with /, redirect\r
 - minimize stage2 initialization code, just move it to source files\r
-_ push call/allot counts as ulong bignums\r
 \r
 + bignums:\r
 \r
index eb3b44b625e3dddd192de6cf7c692ea97a5a259d..ef3dcea3396b946fa2731f741bc3963da2aaf855 100644 (file)
@@ -1,6 +1,6 @@
 #include "factor.h"
 
-CELL tag_fixnum_or_bignum(FIXNUM x)
+CELL tag_integer(FIXNUM x)
 {
        if(x < FIXNUM_MIN || x > FIXNUM_MAX)
                return tag_object(s48_long_to_bignum(x));
@@ -8,6 +8,14 @@ CELL tag_fixnum_or_bignum(FIXNUM x)
                return tag_fixnum(x);
 }
 
+CELL tag_unsigned_integer(CELL x)
+{
+       if(x > FIXNUM_MAX)
+               return tag_object(s48_ulong_to_bignum(x));
+       else
+               return tag_fixnum(x);
+}
+
 CELL upgraded_arithmetic_type(CELL type1, CELL type2)
 {
        switch(type1)
index cdce0995141c16684d90e33886e70e7d45bd3dd8..2c716f0e570ba2bcabdef65b23f70a9803c77c09 100644 (file)
@@ -2,7 +2,8 @@
 
 CELL upgraded_arithmetic_type(CELL type1, CELL type2);
 
-CELL tag_fixnum_or_bignum(FIXNUM x);
+CELL tag_integer(FIXNUM x);
+CELL tag_unsigned_integer(CELL x);
 
 #define BINARY_OP(OP) \
 CELL OP(CELL x, CELL y) \
index 10694fc70bd31c4cb132db7a993a9acac4913c55..abef5af204a95ceec65e7483278e173ecbcf93bf 100644 (file)
@@ -40,12 +40,12 @@ CELL number_eq_fixnum(FIXNUM x, FIXNUM y)
 
 CELL add_fixnum(FIXNUM x, FIXNUM y)
 {
-       return tag_fixnum_or_bignum(x + y);
+       return tag_integer(x + y);
 }
 
 CELL subtract_fixnum(FIXNUM x, FIXNUM y)
 {
-       return tag_fixnum_or_bignum(x - y);
+       return tag_integer(x - y);
 }
 
 CELL multiply_fixnum(FIXNUM x, FIXNUM y)
@@ -59,7 +59,7 @@ CELL multiply_fixnum(FIXNUM x, FIXNUM y)
 
 CELL divint_fixnum(FIXNUM x, FIXNUM y)
 {
-       return tag_fixnum_or_bignum(x / y);
+       return tag_integer(x / y);
 }
 
 CELL divfloat_fixnum(FIXNUM x, FIXNUM y)
@@ -69,8 +69,8 @@ CELL divfloat_fixnum(FIXNUM x, FIXNUM y)
 
 CELL divmod_fixnum(FIXNUM x, FIXNUM y)
 {
-       dpush(tag_fixnum_or_bignum(x / y));
-       return tag_fixnum_or_bignum(x % y);
+       dpush(tag_integer(x / y));
+       return tag_integer(x % y);
 }
 
 CELL mod_fixnum(FIXNUM x, FIXNUM y)
@@ -125,12 +125,12 @@ CELL divide_fixnum(FIXNUM x, FIXNUM y)
        }
 
        if(y == 1)
-               return tag_fixnum_or_bignum(x);
+               return tag_integer(x);
        else
        {
                return tag_ratio(ratio(
-                       tag_fixnum_or_bignum(x),
-                       tag_fixnum_or_bignum(y)));
+                       tag_integer(x),
+                       tag_integer(y)));
        }
 }
 
index cef3c5edc8628bd2cc7cc2ce62dcf3ae0038b7cb..7cad2e945501e2b15c660e457a0872ce7d95eafb 100644 (file)
@@ -104,8 +104,8 @@ bool in_zone(ZONE* z, CELL pointer)
 void primitive_room(void)
 {
        /* push: free total */
-       dpush(tag_fixnum_or_bignum(active->limit - active->here));
-       dpush(tag_fixnum_or_bignum(active->limit - active->base));
+       dpush(tag_integer(active->limit - active->here));
+       dpush(tag_integer(active->limit - active->base));
 }
 
 void primitive_allot_profiling(void)
index 656d18d33335bc9b89d639b09d57990dcde2b19a..ac978de42fc41c441b763cf6592cc02173acbe56 100644 (file)
@@ -428,7 +428,7 @@ s48_bignum_to_long(bignum_type bignum)
 }
 
 bignum_type
-ulong_to_bignum(unsigned long n)
+s48_ulong_to_bignum(unsigned long n)
 {
   bignum_digit_type result_digits [BIGNUM_DIGITS_FOR_LONG];
   bignum_digit_type * end_digits = result_digits;
index c3215c3052e67d712792a09934b5bfb0f39654e5..17b5ce72d65353b3018169a20b540af2ba343c5d 100644 (file)
@@ -164,8 +164,7 @@ void primitive_string_eq(void)
 
 void primitive_string_hashcode(void)
 {
-       drepl(tag_object(s48_long_to_bignum(
-               untag_string(dpeek())->hashcode)));
+       drepl(tag_fixnum(untag_string(dpeek())->hashcode));
 }
 
 CELL index_of_ch(CELL index, STRING* string, CELL ch)
index f304ffe688224b4b84ec49d7c1b802f4f9dbc3da..9c225052b515d7f1d5867d2a055409f433ee0dd1 100644 (file)
@@ -78,7 +78,7 @@ void primitive_set_word_plist(void)
 
 void primitive_word_call_count(void)
 {
-       drepl(tag_fixnum(untag_word(dpeek())->call_count));
+       drepl(tag_unsigned_integer(untag_word(dpeek())->call_count));
 }
 
 void primitive_set_word_call_count(void)
@@ -89,7 +89,7 @@ void primitive_set_word_call_count(void)
 
 void primitive_word_allot_count(void)
 {
-       drepl(tag_fixnum(untag_word(dpeek())->allot_count));
+       drepl(tag_unsigned_integer(untag_word(dpeek())->allot_count));
 }
 
 void primitive_set_word_allot_count(void)