]> gitweb.factorcode.org Git - factor.git/blob - vm/tuples.cpp
forwarding functions replaced with PRIMITIVE_FORWARD() macro
[factor.git] / vm / tuples.cpp
1 #include "master.hpp"
2
3 namespace factor
4 {
5
6 /* push a new tuple on the stack */
7 tuple *factor_vm::allot_tuple(cell layout_)
8 {
9         gc_root<tuple_layout> layout(layout_,this);
10         gc_root<tuple> t(allot<tuple>(tuple_size(layout.untagged())),this);
11         t->layout = layout.value();
12         return t.untagged();
13 }
14
15 inline void factor_vm::primitive_tuple()
16 {
17         gc_root<tuple_layout> layout(dpop(),this);
18         tuple *t = allot_tuple(layout.value());
19         fixnum i;
20         for(i = tuple_size(layout.untagged()) - 1; i >= 0; i--)
21                 t->data()[i] = F;
22
23         dpush(tag<tuple>(t));
24 }
25
26 PRIMITIVE_FORWARD(tuple)
27
28 /* push a new tuple on the stack, filling its slots from the stack */
29 inline void factor_vm::primitive_tuple_boa()
30 {
31         gc_root<tuple_layout> layout(dpop(),this);
32         gc_root<tuple> t(allot_tuple(layout.value()),this);
33         cell size = untag_fixnum(layout.untagged()->size) * sizeof(cell);
34         memcpy(t->data(),(cell *)(ds - (size - sizeof(cell))),size);
35         ds -= size;
36         dpush(t.value());
37 }
38
39 PRIMITIVE_FORWARD(tuple_boa)
40
41 }