Unsafe cell functions

This commit is contained in:
Justin Ethier 2016-07-25 23:26:43 -04:00
parent facaf608ae
commit fa24f4db37
3 changed files with 12 additions and 1 deletions

View file

@ -161,6 +161,7 @@ object Cyc_num_cmp_va_list(void *data, int argc,
int (fn_op(void *, object, object)), object n,
va_list ns);
object Cyc_eq(object x, object y);
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);

View file

@ -235,6 +235,7 @@ gc_heap_root *gc_get_heap()
object cell_get(object cell)
{
// FUTURE: always use unsafe car here, since computed by compiler
return car(cell);
}
@ -1225,6 +1226,15 @@ object Cyc_eq(object x, object y)
return boolean_f;
}
object Cyc_set_cell(void *data, object l, object val)
{
// FUTURE: always use "unsafe" car here, since set-cell is added by cyclone
gc_mut_update((gc_thread_data *) data, car(l), val);
car(l) = val;
add_mutation(data, l, -1, val);
return l;
}
object Cyc_set_car(void *data, object l, object val)
{
if (Cyc_is_pair(l) == boolean_f)

View file

@ -518,7 +518,7 @@
((eq? p 'cons) "make_pair")
((eq? p 'cell) "make_cell")
((eq? p 'cell-get) "cell_get")
((eq? p 'set-cell!) "Cyc_set_car")
((eq? p 'set-cell!) "Cyc_set_cell")
((eq? p 'set-global!) "global_set")
(else
(error "unhandled primitive: " p))))