diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index b40e0219..d65bc7b0 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -179,7 +179,6 @@ object Cyc_set_cell(void *, object l, object val); object Cyc_set_car(void *, object l, object val); object Cyc_set_cdr(void *, object l, object val); object Cyc_length(void *d, object l); -integer_type Cyc_length_as_object(void *d, object l); object Cyc_vector_length(void *data, object v); object Cyc_vector_ref(void *d, object v, object k); object Cyc_vector_set(void *d, object v, object k, object obj); diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 2be404ac..8afe40ad 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -355,12 +355,6 @@ typedef struct { int value; int padding; // Prevent mem corruption if sizeof(int) < sizeof(ptr) } integer_type; -#define make_int(n,v) \ - integer_type n; \ - n.hdr.mark = gc_color_red; \ - n.hdr.grayed = 0; \ - n.tag = integer_tag; \ - n.value = v; typedef struct { gc_header_type hdr; diff --git a/runtime.c b/runtime.c index e4a62420..2274525d 100644 --- a/runtime.c +++ b/runtime.c @@ -1368,8 +1368,8 @@ object Cyc_is_procedure(void *data, object o) tag == closure1_tag || tag == closureN_tag || tag == primitive_tag) { return boolean_t; } else if (tag == pair_tag) { - integer_type l = Cyc_length_as_object(data, o); - if (l.value > 0 && Cyc_is_symbol(car(o)) == boolean_t) { + int i = obj_obj2int(Cyc_length(data, o)); + if (i > 0 && Cyc_is_symbol(car(o)) == boolean_t) { if (strncmp(((symbol) car(o))->desc, "primitive", 10) == 0 || strncmp(((symbol) car(o))->desc, "procedure", 10) == 0) { return boolean_t; @@ -1481,19 +1481,6 @@ object Cyc_vector_ref(void *data, object v, object k) return ((vector) v)->elements[idx]; } -integer_type Cyc_length_as_object(void *data, object l) -{ - make_int(len, 0); - while ((l != NULL)) { - if (is_value_type(l) || ((list) l)->tag != pair_tag) { - Cyc_rt_raise2(data, "length - invalid parameter, expected list", l); - } - l = cdr(l); - len.value++; - } - return len; -} - object Cyc_vector_length(void *data, object v) { if ((v != NULL) && !is_value_type(v) && ((list) v)->tag == vector_tag) { @@ -3250,30 +3237,30 @@ void _Cyc_91end_91thread_67(void *data, object cont, object args) void __87(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_sum, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_sum, cont, cont, args); } void __91(void *data, object cont, object args) { Cyc_check_num_args(data, "-", 1, args); { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_sub, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_sub, cont, cont, args); }} void __85(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_mul, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_mul, cont, cont, args); } void __95(void *data, object cont, object args) { Cyc_check_num_args(data, "/", 1, args); { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_div, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_div, cont, cont, args); }} void _Cyc_91cvar_127(void *data, object cont, object args) @@ -3432,33 +3419,33 @@ void _cell(void *data, object cont, object args) void __123(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_num_eq, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_num_eq, cont, cont, args); } void __125(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_num_gt, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_num_gt, cont, cont, args); } void __121(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_num_lt, cont, cont, args); + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_num_lt, cont, cont, args); } void __125_123(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_num_gte, cont, cont, + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_num_gte, cont, cont, args); } void __121_123(void *data, object cont, object args) { - integer_type argc = Cyc_length_as_object(data, args); - dispatch(data, argc.value, (function_type) dispatch_num_lte, cont, cont, + int argc = obj_obj2int(Cyc_length(data, args)); + dispatch(data, argc, (function_type) dispatch_num_lte, cont, cont, args); } @@ -3581,9 +3568,6 @@ void _cyc_system(void *data, object cont, object args) return_closcall1(data, cont, obj); }} -//void _error(void *data, object cont, object args) { -// integer_type argc = Cyc_length_as_object(args); -// dispatch_va(data, argc.value, dispatch_error, cont, cont, args); } void _Cyc_91current_91exception_91handler(void *data, object cont, object args) { object handler = Cyc_current_exception_handler(data);