X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Fobject.c;fp=src%2Fobject.c;h=a2a81a62e478134ddd188ec4188c0fbe9a2c869d;hb=8d55156675587a770c5654362bcbd3d2a98e4aa9;hp=0000000000000000000000000000000000000000;hpb=d6e1960007fcac962144382332f7a9c8c56fa3a1;p=muddle-interpreter.git diff --git a/src/object.c b/src/object.c new file mode 100644 index 0000000..a2a81a6 --- /dev/null +++ b/src/object.c @@ -0,0 +1,66 @@ +/* +Copyright (C) 2017 Keziah Wesley + +You can redistribute and/or modify this file under the terms of the +GNU Affero General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any +later version. + +This file is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public +License along with this file. If not, see +. +*/ + +#include "object.h" + +uint32_t +list_length (const list_object * o) +{ + const pool_object *p = POOL_OBJECT (o->head); + uint32_t n = 0; + while (p) + { + n++; + p = POOL_OBJECT (p->rest); + } + return n; +} + +/* +static object *cons_new(evaltype type, value v, object *cdr) { + object o; + o.type = type; + o.v = v; + return cons(&o, cdr); +} +*/ + +/* +object *cons(const object *car, const object *cdr) { + assert(car); + assert(cdr); + object *head = pool_alloc(1); + head->type = car->type; + head->rest = cdr->v.head; + head->v = car->v; + return head; +} +*/ + +/* +static object rest(const object *lst) { + assert(lst); + object *head = OBJECT_OF_POOL_PTR(lst->v.head); + assert(head); + object o; + o.type = EVALTYPE_LIST; + o.rest = 0; + o.v.head = ((object*)head)->rest; + return o; +} +*/