]> gitweb.factorcode.org Git - factor.git/blob - vm/tuples.cpp
Put brackets around ipv6 addresses in `inet6 present`
[factor.git] / vm / tuples.cpp
1 #include "master.hpp"
2
3 namespace factor {
4
5 // push a new tuple on the stack, filling its slots with f
6 // Allocates memory
7 void factor_vm::primitive_tuple() {
8   data_root<tuple_layout> layout(ctx->pop(), this);
9   tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
10   t->layout = layout.value();
11
12   memset_cell(t->data(), false_object,
13               tuple_size(layout.untagged()) - sizeof(cell));
14
15   ctx->push(t.value());
16 }
17
18 // push a new tuple on the stack, filling its slots from the stack
19 // Allocates memory
20 void factor_vm::primitive_tuple_boa() {
21   data_root<tuple_layout> layout(ctx->pop(), this);
22   tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
23   t->layout = layout.value();
24
25   cell size = untag_fixnum(layout.untagged()->size) * sizeof(cell);
26   memcpy(t->data(), (cell*)(ctx->datastack - size + sizeof(cell)), size);
27   ctx->datastack -= size;
28
29   ctx->push(t.value());
30 }
31
32 }