]> gitweb.factorcode.org Git - factor.git/blob - vm/arrays.hpp
VM: Remove unnecessary explicit keywords
[factor.git] / vm / arrays.hpp
1 namespace factor {
2
3 inline cell array_nth(array* array, cell slot) {
4 #ifdef FACTOR_DEBUG
5   FACTOR_ASSERT(slot < array_capacity(array));
6   FACTOR_ASSERT(array->type() == ARRAY_TYPE);
7 #endif
8   return array->data()[slot];
9 }
10
11 inline void factor_vm::set_array_nth(array* array, cell slot, cell value) {
12 #ifdef FACTOR_DEBUG
13   FACTOR_ASSERT(slot < array_capacity(array));
14   FACTOR_ASSERT(array->type() == ARRAY_TYPE);
15 #endif
16   cell* slot_ptr = &array->data()[slot];
17   *slot_ptr = value;
18   write_barrier(slot_ptr);
19 }
20
21 struct growable_array {
22   cell count;
23   data_root<array> elements;
24
25   growable_array(factor_vm* parent, cell capacity = 10)
26       : count(0),
27         elements(parent->allot_array(capacity, false_object), parent) {}
28
29   void add(cell elt);
30   void append(array* elts);
31   void trim();
32 };
33
34 }