* string->flonum now uses bytevectors as intermediate rep.
This commit is contained in:
parent
7ca0ddfa81
commit
691a42fe4e
BIN
bin/ikarus
BIN
bin/ikarus
Binary file not shown.
|
@ -5,16 +5,16 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
ikp
|
ikp
|
||||||
ikrt_string_to_flonum(ikp x, ikpcb* pcb){
|
ikrt_bytevector_to_flonum(ikp x, ikpcb* pcb){
|
||||||
double v = strtod(string_data(x), NULL);
|
double v = strtod((char*)x+off_bytevector_data, NULL);
|
||||||
ikp r = ik_alloc(pcb, flonum_size) + vector_tag;
|
ikp r = ik_alloc(pcb, flonum_size) + vector_tag;
|
||||||
ref(r, -vector_tag) = (ikp)flonum_tag;
|
ref(r, -vector_tag) = (ikp)flonum_tag;
|
||||||
flonum_data(r) = v;
|
flonum_data(r) = v;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ikp
|
ikp
|
||||||
ikrt_fl_plus(ikp x, ikp y,ikpcb* pcb){
|
ikrt_fl_plus(ikp x, ikp y,ikpcb* pcb){
|
||||||
ikp r = ik_alloc(pcb, flonum_size) + vector_tag;
|
ikp r = ik_alloc(pcb, flonum_size) + vector_tag;
|
||||||
|
|
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -13,12 +13,14 @@
|
||||||
(define (flonum->string x)
|
(define (flonum->string x)
|
||||||
(utf8-bytevector->string
|
(utf8-bytevector->string
|
||||||
(or (foreign-call "ikrt_flonum_to_bytevector" x
|
(or (foreign-call "ikrt_flonum_to_bytevector" x
|
||||||
(make-bytevector 80 0))
|
($make-bytevector 80))
|
||||||
(error 'flonum->string "~s is not a flonum" x))))
|
(error 'flonum->string "~s is not a flonum" x))))
|
||||||
|
|
||||||
(define (string->flonum x)
|
(define (string->flonum x)
|
||||||
(cond
|
(cond
|
||||||
[(string? x) (foreign-call "ikrt_string_to_flonum" x)]
|
[(string? x)
|
||||||
|
(foreign-call "ikrt_bytevector_to_flonum"
|
||||||
|
(string->utf8-bytevector x))]
|
||||||
[else
|
[else
|
||||||
(error 'string->flonum "~s is not a string" x)])))
|
(error 'string->flonum "~s is not a string" x)])))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue