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