some more bootstrapping fixes
parent
df455b5de8
commit
ed63d91759
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
ERROR: I/O error: [ "primitive_read_line_fd_8" "Resource temporarily unavailable" ]
|
ERROR: I/O error: [ "primitive_read_line_fd_8" "Resource temporarily unavailable" ]
|
||||||
|
|
||||||
|
- bignum=
|
||||||
- fixup-words is crusty
|
- fixup-words is crusty
|
||||||
- decide if overflow is a fatal error
|
- decide if overflow is a fatal error
|
||||||
- f >n: crashes
|
- f >n: crashes
|
||||||
|
|
|
@ -49,7 +49,7 @@ USE: vectors
|
||||||
|
|
||||||
: (hashcode) ( key table -- index )
|
: (hashcode) ( key table -- index )
|
||||||
#! Compute the index of the bucket for a key.
|
#! Compute the index of the bucket for a key.
|
||||||
>r hashcode HEX: ffffff bitand r> vector-length pred mod ;
|
>r hashcode HEX: ffffff bitand r> vector-length mod ;
|
||||||
|
|
||||||
: hash* ( key table -- [ key | value ] )
|
: hash* ( key table -- [ key | value ] )
|
||||||
#! Look up a value in the hashtable. First the bucket is
|
#! Look up a value in the hashtable. First the bucket is
|
||||||
|
|
|
@ -39,6 +39,7 @@ USE: io-internals
|
||||||
USE: math
|
USE: math
|
||||||
USE: namespaces
|
USE: namespaces
|
||||||
USE: parser
|
USE: parser
|
||||||
|
USE: prettyprint
|
||||||
USE: stack
|
USE: stack
|
||||||
USE: stdio
|
USE: stdio
|
||||||
USE: streams
|
USE: streams
|
||||||
|
@ -77,4 +78,5 @@ USE: unparser
|
||||||
|
|
||||||
print-banner
|
print-banner
|
||||||
room.
|
room.
|
||||||
|
|
||||||
init-interpreter ;
|
init-interpreter ;
|
||||||
|
|
|
@ -48,6 +48,7 @@ USE: unparser
|
||||||
[ cons? ] [ 4 cons-hashcode ]
|
[ cons? ] [ 4 cons-hashcode ]
|
||||||
[ string? ] [ str-hashcode ]
|
[ string? ] [ str-hashcode ]
|
||||||
[ fixnum? ] [ ( return the object ) ]
|
[ fixnum? ] [ ( return the object ) ]
|
||||||
|
[ bignum? ] [ ( return the object ) ]
|
||||||
[ drop t ] [ drop 0 ]
|
[ drop t ] [ drop 0 ]
|
||||||
] cond ;
|
] cond ;
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ USE: unparser
|
||||||
: room. ( -- )
|
: room. ( -- )
|
||||||
room
|
room
|
||||||
unparse write " bytes total, " write
|
unparse write " bytes total, " write
|
||||||
unparse write " bytes used" print ;
|
unparse write " bytes free" print ;
|
||||||
|
|
||||||
! No compiler...
|
! No compiler...
|
||||||
: inline ;
|
: inline ;
|
||||||
|
|
|
@ -34,7 +34,7 @@ INLINE void add_fixnum(CELL x, CELL y)
|
||||||
CELL_TO_INTEGER(untag_fixnum_fast(x) + untag_fixnum_fast(y));
|
CELL_TO_INTEGER(untag_fixnum_fast(x) + untag_fixnum_fast(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void add_bignum(CELL x, CELL y)
|
void add_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
+ ((BIGNUM*)UNTAG(y))->n));
|
+ ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -48,7 +48,7 @@ INLINE void subtract_fixnum(CELL x, CELL y)
|
||||||
CELL_TO_INTEGER(untag_fixnum_fast(x) - untag_fixnum_fast(y));
|
CELL_TO_INTEGER(untag_fixnum_fast(x) - untag_fixnum_fast(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void subtract_bignum(CELL x, CELL y)
|
void subtract_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
- ((BIGNUM*)UNTAG(y))->n));
|
- ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -63,7 +63,7 @@ INLINE void multiply_fixnum(CELL x, CELL y)
|
||||||
* (BIGNUM_2)untag_fixnum_fast(y));
|
* (BIGNUM_2)untag_fixnum_fast(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void multiply_bignum(CELL x, CELL y)
|
void multiply_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
* ((BIGNUM*)UNTAG(y))->n));
|
* ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -80,7 +80,7 @@ INLINE void divmod_fixnum(CELL x, CELL y)
|
||||||
env.dt = q.rem;
|
env.dt = q.rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void divmod_bignum(CELL x, CELL y)
|
void divmod_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
dpush(tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
dpush(tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
/ ((BIGNUM*)UNTAG(y))->n)));
|
/ ((BIGNUM*)UNTAG(y))->n)));
|
||||||
|
@ -96,7 +96,7 @@ INLINE void mod_fixnum(CELL x, CELL y)
|
||||||
env.dt = x % y;
|
env.dt = x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void mod_bignum(CELL x, CELL y)
|
void mod_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
% ((BIGNUM*)UNTAG(y))->n));
|
% ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -110,7 +110,7 @@ INLINE void and_fixnum(CELL x, CELL y)
|
||||||
env.dt = x & y;
|
env.dt = x & y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void and_bignum(CELL x, CELL y)
|
void and_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
& ((BIGNUM*)UNTAG(y))->n));
|
& ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -124,7 +124,7 @@ INLINE void or_fixnum(CELL x, CELL y)
|
||||||
env.dt = x | y;
|
env.dt = x | y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void or_bignum(CELL x, CELL y)
|
void or_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
| ((BIGNUM*)UNTAG(y))->n));
|
| ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -138,7 +138,7 @@ INLINE void xor_fixnum(CELL x, CELL y)
|
||||||
env.dt = x ^ y;
|
env.dt = x ^ y;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void xor_bignum(CELL x, CELL y)
|
void xor_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
^ ((BIGNUM*)UNTAG(y))->n));
|
^ ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -153,7 +153,7 @@ INLINE void shiftleft_fixnum(CELL x, CELL y)
|
||||||
<< (BIGNUM_2)untag_fixnum_fast(y));
|
<< (BIGNUM_2)untag_fixnum_fast(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void shiftleft_bignum(CELL x, CELL y)
|
void shiftleft_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
<< ((BIGNUM*)UNTAG(y))->n));
|
<< ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -168,7 +168,7 @@ INLINE void shiftright_fixnum(CELL x, CELL y)
|
||||||
>> (BIGNUM_2)untag_fixnum_fast(y));
|
>> (BIGNUM_2)untag_fixnum_fast(y));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void shiftright_bignum(CELL x, CELL y)
|
void shiftright_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_object(bignum(((BIGNUM*)UNTAG(x))->n
|
||||||
>> ((BIGNUM*)UNTAG(y))->n));
|
>> ((BIGNUM*)UNTAG(y))->n));
|
||||||
|
@ -182,7 +182,7 @@ INLINE void less_fixnum(CELL x, CELL y)
|
||||||
env.dt = tag_boolean((FIXNUM)x < (FIXNUM)y);
|
env.dt = tag_boolean((FIXNUM)x < (FIXNUM)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void less_bignum(CELL x, CELL y)
|
void less_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
||||||
< ((BIGNUM*)UNTAG(y))->n);
|
< ((BIGNUM*)UNTAG(y))->n);
|
||||||
|
@ -196,7 +196,7 @@ INLINE void lesseq_fixnum(CELL x, CELL y)
|
||||||
env.dt = tag_boolean((FIXNUM)x <= (FIXNUM)y);
|
env.dt = tag_boolean((FIXNUM)x <= (FIXNUM)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void lesseq_bignum(CELL x, CELL y)
|
void lesseq_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
||||||
<= ((BIGNUM*)UNTAG(y))->n);
|
<= ((BIGNUM*)UNTAG(y))->n);
|
||||||
|
@ -210,7 +210,7 @@ INLINE void greater_fixnum(CELL x, CELL y)
|
||||||
env.dt = tag_boolean((FIXNUM)x > (FIXNUM)y);
|
env.dt = tag_boolean((FIXNUM)x > (FIXNUM)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void greater_bignum(CELL x, CELL y)
|
void greater_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
||||||
> ((BIGNUM*)UNTAG(y))->n);
|
> ((BIGNUM*)UNTAG(y))->n);
|
||||||
|
@ -224,7 +224,7 @@ INLINE void greatereq_fixnum(CELL x, CELL y)
|
||||||
env.dt = tag_boolean((FIXNUM)x >= (FIXNUM)y);
|
env.dt = tag_boolean((FIXNUM)x >= (FIXNUM)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void greatereq_bignum(CELL x, CELL y)
|
void greatereq_bignum(CELL x, CELL y)
|
||||||
{
|
{
|
||||||
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
env.dt = tag_boolean(((BIGNUM*)UNTAG(x))->n
|
||||||
>= ((BIGNUM*)UNTAG(y))->n);
|
>= ((BIGNUM*)UNTAG(y))->n);
|
||||||
|
|
|
@ -67,8 +67,8 @@ bool in_zone(ZONE* z, CELL pointer)
|
||||||
|
|
||||||
void primitive_room(void)
|
void primitive_room(void)
|
||||||
{
|
{
|
||||||
/* push: limit here */
|
/* push: free total */
|
||||||
dpush(env.dt);
|
dpush(env.dt);
|
||||||
env.dt = tag_fixnum(active->limit - active->base);
|
env.dt = tag_fixnum(active->limit - active->base);
|
||||||
dpush(tag_fixnum(active->here - active->base));
|
dpush(tag_fixnum(active->limit - active->here));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ STRING* allot_string(CELL capacity)
|
||||||
/* uses same algorithm as java.lang.String for compatibility */
|
/* uses same algorithm as java.lang.String for compatibility */
|
||||||
void hash_string(STRING* str)
|
void hash_string(STRING* str)
|
||||||
{
|
{
|
||||||
CELL hash = 0;
|
FIXNUM hash = 0;
|
||||||
int i;
|
CELL i;
|
||||||
for(i = 0; i < str->capacity; i++)
|
for(i = 0; i < str->capacity; i++)
|
||||||
hash = 31*hash + string_nth(str,i);
|
hash = 31*hash + string_nth(str,i);
|
||||||
str->hashcode = hash;
|
str->hashcode = hash;
|
||||||
|
@ -23,7 +23,7 @@ void hash_string(STRING* str)
|
||||||
/* untagged */
|
/* untagged */
|
||||||
STRING* string(CELL capacity, CELL fill)
|
STRING* string(CELL capacity, CELL fill)
|
||||||
{
|
{
|
||||||
int i;
|
CELL i;
|
||||||
|
|
||||||
STRING* string = allot_string(capacity);
|
STRING* string = allot_string(capacity);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ STRING* string(CELL capacity, CELL fill)
|
||||||
STRING* grow_string(STRING* string, CELL capacity, CHAR fill)
|
STRING* grow_string(STRING* string, CELL capacity, CHAR fill)
|
||||||
{
|
{
|
||||||
/* later on, do an optimization: if end of array is here, just grow */
|
/* later on, do an optimization: if end of array is here, just grow */
|
||||||
int i;
|
CELL i;
|
||||||
|
|
||||||
STRING* new_string = allot_string(capacity);
|
STRING* new_string = allot_string(capacity);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ STRING* from_c_string(const char* c_string)
|
||||||
{
|
{
|
||||||
CELL length = strlen(c_string);
|
CELL length = strlen(c_string);
|
||||||
STRING* s = allot_string(length);
|
STRING* s = allot_string(length);
|
||||||
int i;
|
CELL i;
|
||||||
|
|
||||||
for(i = 0; i < length; i++)
|
for(i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ STRING* from_c_string(const char* c_string)
|
||||||
char* to_c_string(STRING* s)
|
char* to_c_string(STRING* s)
|
||||||
{
|
{
|
||||||
STRING* _c_str = allot_string(s->capacity + 1 /* null byte */);
|
STRING* _c_str = allot_string(s->capacity + 1 /* null byte */);
|
||||||
int i;
|
CELL i;
|
||||||
|
|
||||||
char* c_str = (char*)(_c_str + 1);
|
char* c_str = (char*)(_c_str + 1);
|
||||||
|
|
||||||
|
@ -147,14 +147,14 @@ void primitive_string_eq(void)
|
||||||
CELL with = dpop();
|
CELL with = dpop();
|
||||||
check_non_empty(with);
|
check_non_empty(with);
|
||||||
if(typep(STRING_TYPE,with))
|
if(typep(STRING_TYPE,with))
|
||||||
env.dt = tag_boolean(string_eq(s1,UNTAG(with)));
|
env.dt = tag_boolean(string_eq(s1,(STRING*)UNTAG(with)));
|
||||||
else
|
else
|
||||||
env.dt = F;
|
env.dt = F;
|
||||||
}
|
}
|
||||||
|
|
||||||
void primitive_string_hashcode(void)
|
void primitive_string_hashcode(void)
|
||||||
{
|
{
|
||||||
env.dt = tag_fixnum(untag_string(env.dt)->hashcode);
|
env.dt = tag_object(bignum(untag_string(env.dt)->hashcode));
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE CELL index_of_ch(CELL index, STRING* string, CELL ch)
|
INLINE CELL index_of_ch(CELL index, STRING* string, CELL ch)
|
||||||
|
|
|
@ -3,7 +3,7 @@ typedef struct {
|
||||||
/* untagged */
|
/* untagged */
|
||||||
CELL capacity;
|
CELL capacity;
|
||||||
/* untagged */
|
/* untagged */
|
||||||
CELL hashcode;
|
FIXNUM hashcode;
|
||||||
} STRING;
|
} STRING;
|
||||||
|
|
||||||
INLINE STRING* untag_string(CELL tagged)
|
INLINE STRING* untag_string(CELL tagged)
|
||||||
|
|
Loading…
Reference in New Issue