factor/vm/tuples.cpp

35 lines
886 B
C++
Raw Normal View History

2009-05-02 05:04:19 -04:00
#include "master.hpp"
2009-05-04 02:46:13 -04:00
namespace factor
{
/* push a new tuple on the stack, filling its slots with f */
2013-03-25 17:05:05 -04:00
/* Allocates memory */
void factor_vm::primitive_tuple()
2009-05-02 05:04:19 -04:00
{
data_root<tuple_layout> layout(ctx->pop(),this);
2009-10-31 03:58:00 -04:00
tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
t->layout = layout.value();
memset_cell(t->data(),false_object,tuple_size(layout.untagged()) - sizeof(cell));
ctx->push(t.value());
2009-05-02 05:04:19 -04:00
}
/* push a new tuple on the stack, filling its slots from the stack */
2013-03-25 17:05:05 -04:00
/* Allocates memory */
void factor_vm::primitive_tuple_boa()
2009-05-02 05:04:19 -04:00
{
data_root<tuple_layout> layout(ctx->pop(),this);
2009-10-31 03:58:00 -04:00
tagged<tuple> t(allot<tuple>(tuple_size(layout.untagged())));
t->layout = layout.value();
2009-05-04 05:50:24 -04:00
cell size = untag_fixnum(layout.untagged()->size) * sizeof(cell);
memcpy(t->data(),(cell *)(ctx->datastack - size + sizeof(cell)),size);
ctx->datastack -= size;
2009-10-31 03:58:00 -04:00
ctx->push(t.value());
2009-05-02 05:04:19 -04:00
}
2009-05-04 02:46:13 -04:00
}