Update copyright years
[muddle-interpreter.git] / src / object.c
1 /*
2 Copyright (C) 2017-2018 Keziah Wesley
3
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
7 later version.
8
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.
13
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/>.
17 */
18
19 #include "object.h"
20
21 uint32_t
22 list_length (const list_object * o)
23 {
24   const pool_object *p = POOL_OBJECT (o->val.head);
25   uint32_t n = 0;
26   while (p)
27     {
28       n++;
29       p = POOL_OBJECT (p->rest);
30     }
31   return n;
32 }
33
34 /*
35 static object *cons_new(evaltype type, value v, object *cdr) {
36     object o;
37     o.type = type;
38     o.v = v;
39     return cons(&o, cdr);
40 }
41 */
42
43 /*
44 object *cons(const object *car, const object *cdr) {
45     assert(car);
46     assert(cdr);
47     object *head = pool_alloc(1);
48     head->type = car->type;
49     head->rest = cdr->v.head;
50     head->v = car->v;
51     return head;
52 }
53 */
54
55 /*
56 static object rest(const object *lst) {
57     assert(lst);
58     object *head = OBJECT_OF_POOL_PTR(lst->v.head);
59     assert(head);
60     object o;
61     o.type = EVALTYPE_LIST;
62     o.rest = 0;
63     o.v.head = ((object*)head)->rest;
64     return o;
65 }
66 */
67
68 dope_object *
69 uv_dope (const uvector_object * o)
70 {
71   return (dope_object *) & HEAP_OBJECT (o->val.body)[(o->val.len + 1) / 2 +
72                                                      1];
73 }