Added Cyc_is_immutable

This commit is contained in:
Justin Ethier 2019-06-11 17:46:16 -04:00
parent cdbf81c56a
commit 4b6b672892
2 changed files with 16 additions and 1 deletions

View file

@ -67,7 +67,7 @@ void gc_init_heap(long heap_size);
#define Cyc_verify_mutable(data, obj) { \
if (immutable(obj)) Cyc_immutable_obj_error(data, obj); }
#define Cyc_verify_immutable(data, obj) { \
if (is_object_type(obj) && !immutable(obj)) Cyc_mutable_obj_error(data, obj); }
if (boolean_f == Cyc_is_immutable(obj)) Cyc_mutable_obj_error(data, obj); }
#define Cyc_check_type(data, fnc_test, tag, obj) { \
if ((boolean_f == fnc_test(obj))) Cyc_invalid_type_error(data, tag, obj); }
#define Cyc_check_type2(data, fnc_test, tag, obj) { \
@ -472,6 +472,7 @@ object Cyc_is_procedure(void *data, object o);
#define Cyc_is_eof_object(o) (make_boolean(is_object_type(o) && ((list) o)->tag == eof_tag))
#define Cyc_is_cvar(o) (make_boolean(is_object_type(o) && ((list) o)->tag == cvar_tag))
#define Cyc_is_opaque(o) (make_boolean(is_object_type(o) && ((list) o)->tag == c_opaque_tag))
object Cyc_is_immutable(object obj);
/**@}*/
/**

View file

@ -1877,6 +1877,20 @@ object Cyc_is_procedure(void *data, object o)
// return boolean_f;
//}
object Cyc_is_immutable(object obj)
{
if (is_object_type(obj) &&
(type_of(obj) == pair_tag ||
type_of(obj) == vector_tag ||
type_of(obj) == bytevector_tag ||
type_of(obj) == string_tag
) &&
!immutable(obj) ) {
return boolean_f;
}
return boolean_t;
}
object Cyc_set_cell(void *data, object l, object val)
{
// FUTURE: always use "unsafe" car here, since set-cell is added by cyclone