mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 04:25:06 +02:00
Issue #158 - Removed make_int macro
Also removed some related code that became redundant.
This commit is contained in:
parent
2b04c3b253
commit
57562071c9
3 changed files with 20 additions and 43 deletions
|
@ -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_car(void *, object l, object val);
|
||||||
object Cyc_set_cdr(void *, object l, object val);
|
object Cyc_set_cdr(void *, object l, object val);
|
||||||
object Cyc_length(void *d, object l);
|
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_length(void *data, object v);
|
||||||
object Cyc_vector_ref(void *d, object v, object k);
|
object Cyc_vector_ref(void *d, object v, object k);
|
||||||
object Cyc_vector_set(void *d, object v, object k, object obj);
|
object Cyc_vector_set(void *d, object v, object k, object obj);
|
||||||
|
|
|
@ -355,12 +355,6 @@ typedef struct {
|
||||||
int value;
|
int value;
|
||||||
int padding; // Prevent mem corruption if sizeof(int) < sizeof(ptr)
|
int padding; // Prevent mem corruption if sizeof(int) < sizeof(ptr)
|
||||||
} integer_type;
|
} 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 {
|
typedef struct {
|
||||||
gc_header_type hdr;
|
gc_header_type hdr;
|
||||||
|
|
56
runtime.c
56
runtime.c
|
@ -1368,8 +1368,8 @@ object Cyc_is_procedure(void *data, object o)
|
||||||
tag == closure1_tag || tag == closureN_tag || tag == primitive_tag) {
|
tag == closure1_tag || tag == closureN_tag || tag == primitive_tag) {
|
||||||
return boolean_t;
|
return boolean_t;
|
||||||
} else if (tag == pair_tag) {
|
} else if (tag == pair_tag) {
|
||||||
integer_type l = Cyc_length_as_object(data, o);
|
int i = obj_obj2int(Cyc_length(data, o));
|
||||||
if (l.value > 0 && Cyc_is_symbol(car(o)) == boolean_t) {
|
if (i > 0 && Cyc_is_symbol(car(o)) == boolean_t) {
|
||||||
if (strncmp(((symbol) car(o))->desc, "primitive", 10) == 0 ||
|
if (strncmp(((symbol) car(o))->desc, "primitive", 10) == 0 ||
|
||||||
strncmp(((symbol) car(o))->desc, "procedure", 10) == 0) {
|
strncmp(((symbol) car(o))->desc, "procedure", 10) == 0) {
|
||||||
return boolean_t;
|
return boolean_t;
|
||||||
|
@ -1481,19 +1481,6 @@ object Cyc_vector_ref(void *data, object v, object k)
|
||||||
return ((vector) v)->elements[idx];
|
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)
|
object Cyc_vector_length(void *data, object v)
|
||||||
{
|
{
|
||||||
if ((v != NULL) && !is_value_type(v) && ((list) v)->tag == vector_tag) {
|
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)
|
void __87(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_sum, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_sum, cont, cont, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __91(void *data, object cont, object args)
|
void __91(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
Cyc_check_num_args(data, "-", 1, args);
|
Cyc_check_num_args(data, "-", 1, args);
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_sub, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_sub, cont, cont, args);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
void __85(void *data, object cont, object args)
|
void __85(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_mul, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_mul, cont, cont, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __95(void *data, object cont, object args)
|
void __95(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
Cyc_check_num_args(data, "/", 1, args);
|
Cyc_check_num_args(data, "/", 1, args);
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_div, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_div, cont, cont, args);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
void _Cyc_91cvar_127(void *data, object cont, object 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)
|
void __123(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_num_eq, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_num_eq, cont, cont, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __125(void *data, object cont, object args)
|
void __125(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_num_gt, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_num_gt, cont, cont, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __121(void *data, object cont, object args)
|
void __121(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_num_lt, cont, cont, args);
|
dispatch(data, argc, (function_type) dispatch_num_lt, cont, cont, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __125_123(void *data, object cont, object args)
|
void __125_123(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_num_gte, cont, cont,
|
dispatch(data, argc, (function_type) dispatch_num_gte, cont, cont,
|
||||||
args);
|
args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __121_123(void *data, object cont, object args)
|
void __121_123(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
integer_type argc = Cyc_length_as_object(data, args);
|
int argc = obj_obj2int(Cyc_length(data, args));
|
||||||
dispatch(data, argc.value, (function_type) dispatch_num_lte, cont, cont,
|
dispatch(data, argc, (function_type) dispatch_num_lte, cont, cont,
|
||||||
args);
|
args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3581,9 +3568,6 @@ void _cyc_system(void *data, object cont, object args)
|
||||||
return_closcall1(data, cont, obj);
|
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)
|
void _Cyc_91current_91exception_91handler(void *data, object cont, object args)
|
||||||
{
|
{
|
||||||
object handler = Cyc_current_exception_handler(data);
|
object handler = Cyc_current_exception_handler(data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue