2 Copyright (C) 2017-2018 Keziah Wesley
4 You can redistribute and/or modify this file under the terms of the
5 GNU Affero General Public License as published by the Free Software
6 Foundation, either version 3 of the License, or (at your option) any
9 This file is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Affero General Public License for more details.
14 You should have received a copy of the GNU Affero General Public
15 License along with this file. If not, see
16 <http://www.gnu.org/licenses/>.
23 extern pool_object *pool;
26 extern object *vhp_base;
30 pool_alloc (uint32_t len)
38 POOL_OBJECT (pool_ptr p)
41 return (pool_object *) 0;
46 pool_copy_array (const pool_object * objs, uint32_t len)
50 pool_ptr p = pool_alloc (len);
51 for (int i = 0; i < len; i++)
53 pool[p + i] = (pool_object)
55 .type = objs[i].type,.rest = p + i + 1,.val = objs[i].val};
57 pool[p + len - 1].rest = 0;
62 pool_copy_array_rev (const pool_object * objs, uint32_t len)
66 pool_ptr p = pool_alloc (len);
67 for (int i = 0; i < len; i++)
69 pool[p + i] = (pool_object)
71 .type = objs[len - i - 1].type,.rest = p + i + 1,.val =
72 objs[len - i - 1].val};
74 pool[p + len - 1].rest = 0;
79 HEAP_OBJECT (heap_ptr p)
86 heap_alloc (uint32_t len)
91 vhp += len + DOPE_LEN;
96 heap_copy_array_rev (const object * objs, uint32_t len)
98 heap_ptr p = heap_alloc (len);
99 object *xs = HEAP_OBJECT (p);
100 for (int i = 0; i < (int) len; i++)
102 xs[i] = objs[len - 1 - (unsigned) i];
111 return (uv_val *) & vhp_base[p];
115 ATOM_BODY (heap_ptr p)
118 return (atom_body *) (&vhp_base[p]);