mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
Get rid of make_empty_bignum
This commit is contained in:
parent
97d3acb3af
commit
6d02427d1b
2 changed files with 12 additions and 22 deletions
|
@ -370,15 +370,6 @@ typedef struct {
|
|||
#define alloc_bignum(data, p) \
|
||||
bignum_type *p = gc_alloc_bignum((gc_thread_data *)data);
|
||||
|
||||
// TODO: the following macro is obsolete
|
||||
#define make_empty_bignum(n) \
|
||||
bignum_type n; \
|
||||
n.hdr.mark = gc_color_red; \
|
||||
n.hdr.grayed = 0; \
|
||||
n.tag = bignum_tag; \
|
||||
mp_init(&(n.bn));
|
||||
/* TODO: check return value of mp_init */
|
||||
|
||||
typedef struct {
|
||||
gc_header_type hdr;
|
||||
tag_type tag;
|
||||
|
|
25
runtime.c
25
runtime.c
|
@ -1898,12 +1898,11 @@ object Cyc_string2number_(void *data, object cont, object str)
|
|||
if (rv == STR2INT_SUCCESS) {
|
||||
_return_closcall1(data, cont, obj_int2obj(result));
|
||||
} else if (str_is_bignum(rv, s)) {
|
||||
make_empty_bignum(bn);
|
||||
|
||||
// TODO: check return value
|
||||
mp_read_radix(&(bignum_value(&bn)), s, 10);
|
||||
|
||||
_return_closcall1(data, cont, &bn);
|
||||
alloc_bignum(data, bn);
|
||||
if (MP_OKAY != mp_read_radix(&(bignum_value(bn)), s, 10)) {
|
||||
Cyc_rt_raise2(data, "Error converting string to bignum", str);
|
||||
}
|
||||
_return_closcall1(data, cont, bn);
|
||||
} else {
|
||||
char *str_end;
|
||||
n = strtold(s, &str_end);
|
||||
|
@ -3153,10 +3152,10 @@ void Cyc_expt(void *data, object cont, object x, object y)
|
|||
if (obj_obj2int(y) < 0) {
|
||||
Cyc_expt_double(data, cont, (double)obj_obj2int(x), (double)obj_obj2int(y));
|
||||
} else {
|
||||
make_empty_bignum(bn);
|
||||
Cyc_int2bignum(obj_obj2int(x), &(bn.bn));
|
||||
mp_expt_d(&bignum_value(&bn), obj_obj2int(y), &bignum_value(&bn));
|
||||
return_closcall1(data, cont, Cyc_bignum_normalize(data, &bn));
|
||||
alloc_bignum(data, bn);
|
||||
Cyc_int2bignum(obj_obj2int(x), &(bn->bn));
|
||||
mp_expt_d(&bignum_value(bn), obj_obj2int(y), &bignum_value(bn));
|
||||
return_closcall1(data, cont, Cyc_bignum_normalize(data, bn));
|
||||
}
|
||||
} else if (is_object_type(y) && type_of(y) == double_tag) {
|
||||
Cyc_expt_double(data, cont, (double)obj_obj2int(x), double_value(y));
|
||||
|
@ -3181,9 +3180,9 @@ void Cyc_expt(void *data, object cont, object x, object y)
|
|||
if (obj_obj2int(y) < 0) {
|
||||
Cyc_expt_double(data, cont, mp_get_double(&bignum_value(x)), (double)obj_obj2int(y));
|
||||
} else {
|
||||
make_empty_bignum(bn);
|
||||
mp_expt_d(&bignum_value(x), obj_obj2int(y), &bignum_value(&bn));
|
||||
return_closcall1(data, cont, Cyc_bignum_normalize(data, &bn));
|
||||
alloc_bignum(data, bn);
|
||||
mp_expt_d(&bignum_value(x), obj_obj2int(y), &bignum_value(bn));
|
||||
return_closcall1(data, cont, Cyc_bignum_normalize(data, bn));
|
||||
}
|
||||
} else if (is_object_type(y) && type_of(y) == double_tag) {
|
||||
Cyc_expt_double(data, cont, mp_get_double(&bignum_value(x)), double_value(y));
|
||||
|
|
Loading…
Add table
Reference in a new issue