- 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
#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));
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)
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) \
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)
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)
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)
}
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)));
}
}
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)
}
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;
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)
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)
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)