void factor_vm::primitive_resize_byte_array() { data_root<byte_array> array(ctx->pop(),this); array.untag_check(this); cell capacity = unbox_array_size(); ctx->push(tag<byte_array>(reallot_array(array.untagged(),capacity))); }
void factor_vm::primitive_resize_array() { data_root<array> a(dpop(),this); a.untag_check(this); cell capacity = unbox_array_size(); dpush(tag<array>(reallot_array(a.untagged(),capacity))); }
// Allocates memory void growable_array::add(cell elt_) { factor_vm* parent = elements.parent; data_root<object> elt(elt_, parent); if (count == array_capacity(elements.untagged())) { reallot_array(2 * count); } parent->set_array_nth(elements.untagged(), count++, elt.value()); }
// Allocates memory void growable_array::append(array* elts_) { factor_vm* parent = elements.parent; data_root<array> elts(elts_, parent); cell capacity = array_capacity(elts.untagged()); if (count + capacity > array_capacity(elements.untagged())) { reallot_array(2 * (count + capacity)); } for (cell index = 0; index < capacity; index++) parent->set_array_nth(elements.untagged(), count++, array_nth(elts.untagged(), index)); }
/* Allocates memory */ cell factor_vm::add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_) { gc_root<array> cache_entries(cache_entries_,this); gc_root<object> klass(klass_,this); gc_root<word> method(method_,this); cell pic_size = array_capacity(cache_entries.untagged()); gc_root<array> new_cache_entries(reallot_array(cache_entries.untagged(),pic_size + 2),this); set_array_nth(new_cache_entries.untagged(),pic_size,klass.value()); set_array_nth(new_cache_entries.untagged(),pic_size + 1,method.value()); return new_cache_entries.value(); }
// Allocates memory void growable_array::trim() { reallot_array(count); }
void factor_vm::primitive_resize_array() { array* a = untag_check<array>(dpop()); cell capacity = unbox_array_size(); dpush(tag<array>(reallot_array(a,capacity))); }
inline void factorvm::vmprim_resize_byte_array() { byte_array *array = untag_check<byte_array>(dpop()); cell capacity = unbox_array_size(); dpush(tag<byte_array>(reallot_array(array,capacity))); }