X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Falloc.c;h=ccd96913fbff18e8b8bbd2ee673086a9f692595f;hb=e3dcc1d3966fb95a5a232daa193c6b5d89a06b7e;hp=ad55630b7a0c8ddb75174c8d476a771b442c3ebe;hpb=3eadff410d2d08246d6f195ef209ed9d88c99be5;p=muddle-interpreter.git diff --git a/src/alloc.c b/src/alloc.c index ad55630..ccd9691 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -17,6 +17,7 @@ License along with this file. If not, see */ #include "alloc.h" +#include "atom.h" #include "object.h" extern pool_object *pool; @@ -41,6 +42,22 @@ POOL_OBJECT (pool_ptr p) return &pool[p]; } +pool_ptr +pool_copy_array (const pool_object * objs, uint32_t len) +{ + if (!len) + return 0; + pool_ptr p = pool_alloc (len); + for (int i = 0; i < len; i++) + { + pool[p + i] = (pool_object) + { + .type = objs[i].type,.rest = p + i + 1,.val = objs[i].val}; + } + pool[p + len - 1].rest = 0; + return p; +} + pool_ptr pool_copy_array_rev (const pool_object * objs, uint32_t len) { @@ -86,3 +103,17 @@ heap_copy_array_rev (const object * objs, uint32_t len) } return p; } + +uv_val * +UV_VAL (heap_ptr p) +{ + assert (p > 0); + return (uv_val *) & vhp_base[p]; +} + +atom_body * +ATOM_BODY (heap_ptr p) +{ + assert (p); + return (atom_body *) (&vhp_base[p]); +}