Revert "lists: Add list literal doc example."
[factor.git] / vm / arrays.hpp
blob6be877b63d412cb45f3878c487904286d22f88eb
1 namespace factor {
3 inline cell array_nth(array* array, cell slot) {
4 FACTOR_ASSERT(slot < array_capacity(array));
5 FACTOR_ASSERT(array->type() == ARRAY_TYPE);
6 return array->data()[slot];
9 inline void factor_vm::set_array_nth(array* array, cell slot, cell value) {
10 FACTOR_ASSERT(slot < array_capacity(array));
11 FACTOR_ASSERT(array->type() == ARRAY_TYPE);
12 cell* slot_ptr = &array->data()[slot];
13 *slot_ptr = value;
14 write_barrier(slot_ptr);
17 struct growable_array {
18 cell count;
19 data_root<array> elements;
21 // Allocates memory
22 growable_array(factor_vm* parent, cell capacity = 10)
23 : count(0),
24 elements(parent->allot_array(capacity, false_object), parent) {}
26 void reallot_array(cell count);
27 void add(cell elt);
28 void append(array* elts);
29 void trim();