Add beginning of Lips compiler, DynASM
diff --git a/src/lisp/compiler.h b/src/lisp/compiler.h
new file mode 100644
index 0000000..9342a12
--- /dev/null
+++ b/src/lisp/compiler.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "lisp.h"
+#include <stdbool.h>
+
+struct function
+{
+ char *name;
+ int nargs; // number of arguments
+
+ union {
+ struct value (*def0) ();
+ struct value (*def1) (struct value);
+ struct value (*def2) (struct value, struct value);
+ struct value (*def3) (struct value, struct value, struct value);
+ void *code_ptr;
+ unsigned long code_addr;
+ };
+
+ struct function *prev;
+};
+
+struct environment
+{
+ struct function *first;
+};
+
+struct variable
+{
+ char *name;
+ int number;
+ struct variable *prev;
+};
+
+// local environment
+struct local
+{
+ // temps are accessed at ebp - 8 * (num_vars + temp)
+ bool temps[ 64 ];
+ int num_vars;
+ struct variable *first;
+};
+
+// First pass populates local
+void firstpass (struct value val, struct environment *env, struct local *local);
+// Second pass generates code
+void secondpass (struct value val, struct environment *env,
+ struct local *local);
+void toplevel (struct value val, struct environment *env);
+void compile (struct istream *is);
+struct function *find_function (struct environment *env, char *name);