Return immediate integers

This commit is contained in:
Justin Ethier 2016-04-02 00:48:02 -04:00
parent 8845991c71
commit 3a79a0f181
2 changed files with 15 additions and 14 deletions

View file

@ -98,16 +98,16 @@ object Cyc_global_set(void *thd, object *glo, object value);
return_closcall1(data, cont, &d)
#define return_exact_double_op(data, cont, OP, z) \
make_int(i, 0); \
int i = 0; \
Cyc_check_num(data, z); \
if (obj_is_int(z)) { \
i.value = obj_obj2int(z); \
i = obj_obj2int(z); \
} else if (type_of(z) == integer_tag) { \
i.value = (int)OP(((integer_type *)z)->value); \
i = (int)OP(((integer_type *)z)->value); \
} else { \
i.value = (int)OP(((double_type *)z)->value); \
i = (int)OP(((double_type *)z)->value); \
} \
return_closcall1(data, cont, &i)
return_closcall1(data, cont, obj_int2obj(i))
#define unbox_number(n) \
((obj_is_int(n) ? obj_obj2int(n) : \

View file

@ -1108,7 +1108,7 @@ object Cyc_list2string(void *data, object cont, object lst){
object Cyc_string2number2_(void *data, object cont, int argc, object str, ...)
{
object base = nil;
int base_num;
int base_num, result;
va_list ap;
va_start(ap, str);
if (argc > 1) {
@ -1120,20 +1120,21 @@ object Cyc_string2number2_(void *data, object cont, int argc, object str, ...)
base_num = obj_is_int(base) ? obj_obj2int(base) : integer_value(base);
Cyc_check_str(data, str);
if (base_num == 2) {
make_int(result, binstr2int(string_str(str)));
return_closcall1(data, cont, &result);
result = binstr2int(string_str(str));
return_closcall1(data, cont, obj_int2obj(result));
}else if (base_num == 8) {
make_int(result, octstr2int(string_str(str)));
return_closcall1(data, cont, &result);
result = octstr2int(string_str(str));
return_closcall1(data, cont, obj_int2obj(result));
}else if (base_num == 16) {
make_int(result, hexstr2int(string_str(str)));
return_closcall1(data, cont, &result);
result = hexstr2int(string_str(str));
return_closcall1(data, cont, obj_int2obj(result));
}
}
Cyc_string2number_(data, cont, str);
}
object Cyc_string2number_(void *data, object cont, object str){
int result;
double n;
Cyc_check_obj(data, string_tag, str);
Cyc_check_str(data, str);
@ -1142,8 +1143,8 @@ object Cyc_string2number_(void *data, object cont, object str){
n = atof(((string_type *) str)->str);
if (ceilf(n) == n) {
make_int(result, (int)n);
return_closcall1(data, cont, &result);
result = (int)n;
return_closcall1(data, cont, obj_int2obj(result));
}
else {
make_double(result, n);