Add GC stub, let1
diff --git a/src/lisp/Jmk b/src/lisp/Jmk
index 673f586..37fa788 100644
--- a/src/lisp/Jmk
+++ b/src/lisp/Jmk
@@ -9,7 +9,7 @@
preset(debug)
preset(warn)
-archetype(c)
+archetype(c, asm)
CFLAGS += -Ivendor/luajit/dynasm
@@ -18,7 +18,8 @@
compiler.o \
lib/std.o \
plat/linux.o \
- istream.o
+ istream.o \
+ gc.o
LUA = vendor/luajit/src/host/minilua
diff --git a/src/lisp/compiler.dasc b/src/lisp/compiler.dasc
index cd64ce7..41b9ad1 100644
--- a/src/lisp/compiler.dasc
+++ b/src/lisp/compiler.dasc
@@ -32,6 +32,15 @@
dasm_State *d;
unsigned int npc = 8;
+extern void _do_gc(unsigned int ebp, unsigned int esp);
+
+static void compile_gc()
+{
+ | push esp;
+ | push ebp;
+ | call (_do_gc);
+}
+
struct function *find_function(struct environment *env, char *name)
{
struct function *f = env->first;
diff --git a/src/lisp/gc.c b/src/lisp/gc.c
new file mode 100644
index 0000000..21e38e2
--- /dev/null
+++ b/src/lisp/gc.c
@@ -0,0 +1,23 @@
+#include "gc.h"
+#include "lisp.h"
+
+void _mark(unsigned int value)
+{
+
+}
+
+void _sweep()
+{
+
+}
+
+void _do_gc(unsigned int esp, unsigned int ebp)
+{
+ unsigned int *esp_p = (unsigned int *)esp,
+ *ebp_p = (unsigned int *)ebp;
+
+ for (int i = 0; esp_p + i < ebp_p; i++)
+ {
+ _mark(esp_p[i]);
+ }
+}
diff --git a/src/lisp/gc.h b/src/lisp/gc.h
new file mode 100644
index 0000000..da5982a
--- /dev/null
+++ b/src/lisp/gc.h
@@ -0,0 +1,5 @@
+#pragma once
+
+void _do_gc(unsigned int esp, unsigned int ebp);
+void _mark(unsigned int value);
+void _sweep();
diff --git a/src/lisp/test.lisp b/src/lisp/test.lisp
index 32152f1..a8ad05e 100644
--- a/src/lisp/test.lisp
+++ b/src/lisp/test.lisp
@@ -6,7 +6,7 @@
(print (add-two (* 4 3)))
(print (- 3 6))))
-(defun main()
+(defun main ()
(let1 (a 3)
(print "a is")
- (print a)))
\ No newline at end of file
+ (print a)))