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