diff --git a/bin/Makefile b/bin/Makefile index 8395138..9f6baf6 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -7,12 +7,12 @@ all: ikarus ikarus: ikarus-collect.o ikarus-runtime.o ikarus-main.o ikarus-fasl.o \ ikarus-exec.o ikarus-print.o ikarus-enter.o ikarus-symbol-table.o \ - ikarus-weak-pairs.o ikarus-numerics.o + ikarus-weak-pairs.o ikarus-numerics.o ikarus-flonums.o $(CC) $(LDFLAGS) -o ikarus \ ikarus-main.o ikarus-runtime.o \ ikarus-fasl.o ikarus-exec.o ikarus-print.o ikarus-enter.o \ ikarus-symbol-table.o ikarus-collect.o ikarus-weak-pairs.o \ - ikarus-numerics.o + ikarus-numerics.o ikarus-flonums.o ikarus-main.o: ikarus-main.c ikarus.h $(CC) $(CFLAGS) -c ikarus-main.c @@ -45,6 +45,9 @@ ikarus-symbol-table.o: ikarus-symbol-table.c ikarus.h ikarus-numerics.o: ikarus-numerics.c ikarus.h $(CC) $(CFLAGS) -c ikarus-numerics.c +ikarus-flonums.o: ikarus-flonums.c ikarus.h + $(CC) $(CFLAGS) -c ikarus-flonums.c + ikarus.h: ikarus-data.h touch ikarus.h diff --git a/bin/ikarus b/bin/ikarus index b07b1fd..e4791ef 100755 Binary files a/bin/ikarus and b/bin/ikarus differ diff --git a/bin/ikarus-data.h b/bin/ikarus-data.h index b3f449b..b45f849 100644 --- a/bin/ikarus-data.h +++ b/bin/ikarus-data.h @@ -196,4 +196,9 @@ #define disp_bignum_data wordsize #define off_bignum_data (disp_bignum_data - vector_tag) +#define flonum_tag ((ikp)0xFF) +#define flonum_size 16 +#define disp_flonum_data 8 +#define off_flonum_data (disp_flonum_data - vector_tag) + #endif diff --git a/src/ikarus.boot b/src/ikarus.boot index 7109030..4a10504 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/libnumerics.ss b/src/libnumerics.ss index 6299fcc..381192f 100644 --- a/src/libnumerics.ss +++ b/src/libnumerics.ss @@ -1,4 +1,23 @@ +(let () + (define (flonum? x) + (foreign-call "ikrt_is_flonum" x)) + (define (flonum->string x) + (or (foreign-call "ikrt_flonum_to_string" x) + (error 'flonum->string "~s is not a flonum" x))) + (define (string->flonum x) + (cond + [(string? x) (foreign-call "ikrt_string_to_flonum" x)] + [else + (error 'string->flonum "~s is not a string" x)])) + + (primitive-set! 'flonum? flonum?) + (primitive-set! 'flonum->string flonum->string) + (primitive-set! 'string->flonum string->flonum) +) + + + (let () (define bignum? diff --git a/src/makefile.ss b/src/makefile.ss index a01af5d..b79bc60 100755 --- a/src/makefile.ss +++ b/src/makefile.ss @@ -92,6 +92,8 @@ char-downcase max min complex? real? rational? exact? inexact? integer? string->number + + flonum? flonum->string string->flonum )) (define system-primitives