mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-04 19:56:34 +02:00
Cleanup
This commit is contained in:
parent
b10bd48648
commit
449e4bd425
3 changed files with 84 additions and 60 deletions
|
@ -494,8 +494,10 @@ 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);
|
||||||
#define Cyc_vector_ref_unsafe(d, v, k) \
|
#define Cyc_vector_ref_unsafe(d, v, k) \
|
||||||
((vector) v)->elements[obj_obj2int(k)]
|
((vector) v)->elements[obj_obj2int(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);
|
||||||
//object Cyc_vector_set_unsafe(void *d, object v, object k, object obj);
|
object Cyc_vector_set_unsafe(void *d, object v, object k, object obj);
|
||||||
|
object Cyc_vector_set_cps(void *d, object cont, object v, object k, object obj);
|
||||||
|
object Cyc_vector_set_unsafe_cps(void *d, object cont, object v, object k, object obj);
|
||||||
object Cyc_vector_set2(void *d, object cont, object v, object k, object obj);
|
object Cyc_vector_set2(void *d, object cont, object v, object k, object obj);
|
||||||
object Cyc_vector_set_unsafe2(void *d, object cont, object v, object k, object obj);
|
object Cyc_vector_set_unsafe2(void *d, object cont, object v, object k, object obj);
|
||||||
object Cyc_make_vector(void *data, object cont, int argc, object len, ...);
|
object Cyc_make_vector(void *data, object cont, int argc, object len, ...);
|
||||||
|
@ -842,8 +844,10 @@ static inline object Cyc_cdr(void *data, object lis)
|
||||||
|
|
||||||
list malloc_make_pair(object, object);
|
list malloc_make_pair(object, object);
|
||||||
object Cyc_set_cell(void *, object l, object val);
|
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_set_car_cps(void *, object cont, object l, object val);
|
||||||
|
object Cyc_set_cdr_cps(void *, object cont, object l, object val);
|
||||||
object Cyc_set_car2(void *, object cont, object l, object val);
|
object Cyc_set_car2(void *, object cont, object l, object val);
|
||||||
object Cyc_set_cdr2(void *, object cont, object l, object val);
|
object Cyc_set_cdr2(void *, object cont, object l, object val);
|
||||||
object Cyc_length(void *d, object l);
|
object Cyc_length(void *d, object l);
|
||||||
|
|
124
runtime.c
124
runtime.c
|
@ -2124,62 +2124,67 @@ object Cyc_set_cell(void *data, object l, object val)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
//object Cyc_set_car(void *data, object l, object val)
|
object Cyc_set_car(void *data, object l, object val)
|
||||||
//{
|
{
|
||||||
// if (Cyc_is_pair(l) == boolean_f) {
|
if (Cyc_is_pair(l) == boolean_f) {
|
||||||
// Cyc_invalid_type_error(data, pair_tag, l);
|
Cyc_invalid_type_error(data, pair_tag, l);
|
||||||
// }
|
}
|
||||||
// Cyc_verify_mutable(data, l);
|
Cyc_verify_mutable(data, l);
|
||||||
// gc_mut_update((gc_thread_data *) data, car(l), val);
|
gc_mut_update((gc_thread_data *) data, car(l), val);
|
||||||
// car(l) = val;
|
car(l) = val;
|
||||||
// add_mutation(data, l, -1, val);
|
add_mutation(data, l, -1, val);
|
||||||
// return l;
|
return l;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//object Cyc_set_cdr(void *data, object l, object val)
|
|
||||||
//{
|
|
||||||
// if (Cyc_is_pair(l) == boolean_f) {
|
|
||||||
// Cyc_invalid_type_error(data, pair_tag, l);
|
|
||||||
// }
|
|
||||||
// Cyc_verify_mutable(data, l);
|
|
||||||
// gc_mut_update((gc_thread_data *) data, cdr(l), val);
|
|
||||||
// cdr(l) = val;
|
|
||||||
// add_mutation(data, l, -1, val);
|
|
||||||
// return l;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//object Cyc_vector_set(void *data, object v, object k, object obj)
|
|
||||||
//{
|
|
||||||
// int idx;
|
|
||||||
// Cyc_check_vec(data, v);
|
|
||||||
// Cyc_check_fixnum(data, k);
|
|
||||||
// Cyc_verify_mutable(data, v);
|
|
||||||
// idx = unbox_number(k);
|
|
||||||
//
|
|
||||||
// if (idx < 0 || idx >= ((vector) v)->num_elements) {
|
|
||||||
// Cyc_rt_raise2(data, "vector-set! - invalid index", k);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// gc_mut_update((gc_thread_data *) data, ((vector) v)->elements[idx], obj);
|
|
||||||
//
|
|
||||||
// ((vector) v)->elements[idx] = obj;
|
|
||||||
// add_mutation(data, v, idx, obj);
|
|
||||||
// return v;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//object Cyc_vector_set_unsafe(void *data, object v, object k, object obj)
|
|
||||||
//{
|
|
||||||
// int idx = unbox_number(k);
|
|
||||||
// gc_mut_update((gc_thread_data *) data, ((vector) v)->elements[idx], obj);
|
|
||||||
// ((vector) v)->elements[idx] = obj;
|
|
||||||
// add_mutation(data, v, idx, obj);
|
|
||||||
// return v;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
object Cyc_set_cdr(void *data, object l, object val)
|
||||||
|
{
|
||||||
|
if (Cyc_is_pair(l) == boolean_f) {
|
||||||
|
Cyc_invalid_type_error(data, pair_tag, l);
|
||||||
|
}
|
||||||
|
Cyc_verify_mutable(data, l);
|
||||||
|
gc_mut_update((gc_thread_data *) data, cdr(l), val);
|
||||||
|
cdr(l) = val;
|
||||||
|
add_mutation(data, l, -1, val);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
object Cyc_vector_set(void *data, object v, object k, object obj)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
Cyc_check_vec(data, v);
|
||||||
|
Cyc_check_fixnum(data, k);
|
||||||
|
Cyc_verify_mutable(data, v);
|
||||||
|
idx = unbox_number(k);
|
||||||
|
|
||||||
|
if (idx < 0 || idx >= ((vector) v)->num_elements) {
|
||||||
|
Cyc_rt_raise2(data, "vector-set! - invalid index", k);
|
||||||
|
}
|
||||||
|
|
||||||
|
gc_mut_update((gc_thread_data *) data, ((vector) v)->elements[idx], obj);
|
||||||
|
|
||||||
|
((vector) v)->elements[idx] = obj;
|
||||||
|
add_mutation(data, v, idx, obj);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
object Cyc_vector_set_unsafe(void *data, object v, object k, object obj)
|
||||||
|
{
|
||||||
|
int idx = unbox_number(k);
|
||||||
|
gc_mut_update((gc_thread_data *) data, ((vector) v)->elements[idx], obj);
|
||||||
|
((vector) v)->elements[idx] = obj;
|
||||||
|
add_mutation(data, v, idx, obj);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
// JAE TODO: comment below in progress
|
||||||
// TODO: rename these as (EG) Cyc_set_car_cps. Uncomment non-CPS above and we can use them for unsafe compilation
|
// TODO: rename these as (EG) Cyc_set_car_cps. Uncomment non-CPS above and we can use them for unsafe compilation
|
||||||
//
|
//
|
||||||
object Cyc_set_car2(void *data, object cont, object l, object val)
|
object Cyc_set_car2(void *data, object cont, object l, object val)
|
||||||
|
{
|
||||||
|
return Cyc_set_car_cps(data, cont, l, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
object Cyc_set_car_cps(void *data, object cont, object l, object val)
|
||||||
{
|
{
|
||||||
if (Cyc_is_pair(l) == boolean_f) {
|
if (Cyc_is_pair(l) == boolean_f) {
|
||||||
Cyc_invalid_type_error(data, pair_tag, l);
|
Cyc_invalid_type_error(data, pair_tag, l);
|
||||||
|
@ -2203,6 +2208,11 @@ object Cyc_set_car2(void *data, object cont, object l, object val)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Cyc_set_cdr2(void *data, object cont, object l, object val)
|
object Cyc_set_cdr2(void *data, object cont, object l, object val)
|
||||||
|
{
|
||||||
|
return Cyc_set_cdr_cps(data, cont, l, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
object Cyc_set_cdr_cps(void *data, object cont, object l, object val)
|
||||||
{
|
{
|
||||||
if (Cyc_is_pair(l) == boolean_f) {
|
if (Cyc_is_pair(l) == boolean_f) {
|
||||||
Cyc_invalid_type_error(data, pair_tag, l);
|
Cyc_invalid_type_error(data, pair_tag, l);
|
||||||
|
@ -2226,6 +2236,11 @@ object Cyc_set_cdr2(void *data, object cont, object l, object val)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Cyc_vector_set2(void *data, object cont, object v, object k, object obj)
|
object Cyc_vector_set2(void *data, object cont, object v, object k, object obj)
|
||||||
|
{
|
||||||
|
return Cyc_vector_set_cps(data, cont, v, k, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
object Cyc_vector_set_cps(void *data, object cont, object v, object k, object obj)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
Cyc_check_vec(data, v);
|
Cyc_check_vec(data, v);
|
||||||
|
@ -2254,6 +2269,11 @@ object Cyc_vector_set2(void *data, object cont, object v, object k, object obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Cyc_vector_set_unsafe2(void *data, object cont, object v, object k, object obj)
|
object Cyc_vector_set_unsafe2(void *data, object cont, object v, object k, object obj)
|
||||||
|
{
|
||||||
|
return Cyc_vector_set_unsafe_cps(data, cont, v, k, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
object Cyc_vector_set_unsafe_cps(void *data, object cont, object v, object k, object obj)
|
||||||
{
|
{
|
||||||
int idx = unbox_number(k);
|
int idx = unbox_number(k);
|
||||||
int do_gc = 0;
|
int do_gc = 0;
|
||||||
|
|
|
@ -634,8 +634,8 @@
|
||||||
"Cyc_vector_ref"))
|
"Cyc_vector_ref"))
|
||||||
((eq? p 'vector-set!)
|
((eq? p 'vector-set!)
|
||||||
(if emit-unsafe
|
(if emit-unsafe
|
||||||
"Cyc_vector_set_unsafe2"
|
"Cyc_vector_set_unsafe_cps"
|
||||||
"Cyc_vector_set2"))
|
"Cyc_vector_set_cps"))
|
||||||
((eq? p 'string-append) "Cyc_string_append")
|
((eq? p 'string-append) "Cyc_string_append")
|
||||||
((eq? p 'string-cmp) "Cyc_string_cmp")
|
((eq? p 'string-cmp) "Cyc_string_cmp")
|
||||||
((eq? p 'string->symbol) "Cyc_string2symbol")
|
((eq? p 'string->symbol) "Cyc_string2symbol")
|
||||||
|
@ -653,8 +653,8 @@
|
||||||
(if emit-unsafe
|
(if emit-unsafe
|
||||||
"Cyc_length_unsafe"
|
"Cyc_length_unsafe"
|
||||||
"Cyc_length"))
|
"Cyc_length"))
|
||||||
((eq? p 'set-car!) "Cyc_set_car2")
|
((eq? p 'set-car!) "Cyc_set_car_cps")
|
||||||
((eq? p 'set-cdr!) "Cyc_set_cdr2")
|
((eq? p 'set-cdr!) "Cyc_set_cdr_cps")
|
||||||
((eq? p 'eq?) "Cyc_eq")
|
((eq? p 'eq?) "Cyc_eq")
|
||||||
((eq? p 'eqv?) "Cyc_eq")
|
((eq? p 'eqv?) "Cyc_eq")
|
||||||
((eq? p 'equal?) "equalp")
|
((eq? p 'equal?) "equalp")
|
||||||
|
|
Loading…
Add table
Reference in a new issue