OBJECT_PTR eval_make_array(OBJECT_PTR size, OBJECT_PTR default_value) { int sz = get_int_value(size); uintptr_t *raw_ptr; uintptr_t ptr; int i; assert(IS_INTEGER_OBJECT(size)); //see comment in main.c for why we're not using object_alloc() //posix_memalign((void **)&raw_ptr, 16, sizeof(unsigned int *)); //*((int *)raw_ptr) = sz; ptr = object_alloc(sz+1, ARRAY_TAG); //set_heap(ptr, 0, size); //set_heap(ptr, 0, (uintptr_t)raw_ptr + INTEGER_TAG); *((uintptr_t *)ptr) = sz; for(i=0; i<sz; i++) set_heap(ptr, i + 1, clone_object(default_value)); return ptr + ARRAY_TAG; }
BOOLEAN is_dynamic_memory_object(OBJECT_PTR obj) { return IS_CONS_OBJECT(obj) || IS_ARRAY_OBJECT(obj) || IS_CLOSURE_OBJECT(obj) || IS_MACRO_OBJECT(obj) || IS_CONTINUATION_OBJECT(obj) || IS_INTEGER_OBJECT(obj) || IS_FLOAT_OBJECT(obj) || IS_NATIVE_FN_OBJECT(obj) || IS_FUNCTION2_OBJECT(obj) || IS_MACRO2_OBJECT(obj); }