]> gitweb.factorcode.org Git - factor.git/blob - vm/tuples.cpp
Merge branch 'new-math-parser' of git://factorcode.org/git/factor into new-math-parser
[factor.git] / vm / tuples.cpp
1 #include "master.hpp"
2
3 namespace factor
4 {
5
6 /* push a new tuple on the stack, filling its slots with f */
7 void factor_vm::primitive_tuple()
8 {
9         data_root<tuple_layout> layout(ctx->pop(),this);
10         tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
11         t->layout = layout.value();
12
13         memset_cell(t->data(),false_object,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 void factor_vm::primitive_tuple_boa()
20 {
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 }