aboutsummaryrefslogtreecommitdiff
path: root/constructor.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-09-01 21:26:01 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-09-01 21:26:01 +0100
commit700c3b1d1b3ed835ffab3fd502ab91baba8e2d1f (patch)
tree69029747231d8fa60d3cb05f965e796d2211f021 /constructor.c
parentcc56a2ee2b5703f9ea5ac63a86870af188845c30 (diff)
downloadalisp-700c3b1d1b3ed835ffab3fd502ab91baba8e2d1f.tar.gz
alisp-700c3b1d1b3ed835ffab3fd502ab91baba8e2d1f.tar.bz2
alisp-700c3b1d1b3ed835ffab3fd502ab91baba8e2d1f.zip
Move implementation files into their own folder
main.c and test.c generate binary executables so they can stay in the main folder, but the rest can go into their own dedicated folder to make it look nicer
Diffstat (limited to 'constructor.c')
-rw-r--r--constructor.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/constructor.c b/constructor.c
deleted file mode 100644
index e0fab52..0000000
--- a/constructor.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 2025 Aryadev Chavali
-
- * This program 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 Unlicense for details.
-
- * You may distribute and modify this code under the terms of the Unlicense,
- * which you should have received a copy of along with this program. If not,
- * please go to <https://unlicense.org/>.
-
- * Created: 2025-08-20
- * Description: Lisp constructors/destructors
- */
-
-#include <malloc.h>
-
-#include "./alisp.h"
-
-lisp_t *make_int(i64 i)
-{
- return tag_int(i);
-}
-
-lisp_t *cons(sys_t *sys, lisp_t *car, lisp_t *cdr)
-{
- cons_t *cons = calloc(1, sizeof(*cons));
- cons->car = car;
- cons->cdr = cdr;
-
- lisp_t *lcons = tag_cons(cons);
- sys_register(sys, lcons);
- return lcons;
-}
-
-lisp_t *make_vec(sys_t *sys, u64 capacity)
-{
- vec_t *vec = calloc(1, sizeof(*vec));
- vec_init(vec, capacity);
- lisp_t *ptr = tag_vec(vec);
- sys_register(sys, ptr);
- return ptr;
-}
-
-lisp_t *intern(sys_t *sys, sv_t sv)
-{
- char *str = sym_table_find(&sys->symtable, sv);
- return tag_sym(str);
-}
-
-lisp_t *car(lisp_t *lsp)
-{
- if (!IS_TAG(lsp, CONS))
- return NIL;
- else
- return CAR(lsp);
-}
-
-lisp_t *cdr(lisp_t *lsp)
-{
- if (!IS_TAG(lsp, CONS))
- return NIL;
- else
- return CDR(lsp);
-}