#include #include #include #include #include #include #include #include "../defines/BUILTIN_PARAMETER_DECLARATION.h" #include "list.h" struct value* builtin_list( BUILTIN_PARAMETER_DECLARATION) { ENTER; struct value* retval = NULL; struct value* tail = NULL; for (struct value* moving = arguments; moving->kind == vk_list; moving = moving->subclass.list.rest) { struct value* element = moving->subclass.list.first; struct value* result = evalfunc(element, environment, gc); struct value* link = new_list_value(gc, result); if (tail) { tail->subclass.list.rest = link; gc_dec_external_refcount(gc, tail); tail = gc_inc_external_refcount(gc, link); } else { retval = gc_inc_external_refcount(gc, link); tail = gc_inc_external_refcount(gc, link); } gc_dec_external_refcount(gc, link); gc_dec_external_refcount(gc, result); } struct value* null = new_null_value(gc); if (tail) { tail->subclass.list.rest = null; } else { TODO; } gc_dec_external_refcount(gc, null); gc_dec_external_refcount(gc, tail); EXIT; return retval; }