summaryrefslogtreecommitdiff
path: root/src/emit.lisp
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-10 20:28:34 -0400
committerbd <bdunahu@operationnull.com>2025-04-10 20:28:34 -0400
commitc1507d153161413e4958362d19ae9aa9abedee47 (patch)
tree23c6f4538c1b385cb1e6f97d197b8afa18a45619 /src/emit.lisp
parentdf508744ec2975cec0ba05e8a4358c1c41265c4c (diff)
Add write raw bytes stage
Diffstat (limited to 'src/emit.lisp')
-rw-r--r--src/emit.lisp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/emit.lisp b/src/emit.lisp
index acc2772..48ebebe 100644
--- a/src/emit.lisp
+++ b/src/emit.lisp
@@ -2,7 +2,7 @@
(defun fits-in-X-bits (n)
"Returns the number of bits required to represent N"
- (ceiling (/ (log (ceiling n (log 2))) (log 2))))
+ (ceiling (/ (log n) (log 2))))
(defmacro generate-type-map (ops)
"Generates an alist where the key corresponds to an element in
@@ -11,8 +11,7 @@ number of bits required to represent all
concatenated with TYPE."
`(let ((i 0)
(opsize (fits-in-X-bits (length ,ops))))
- (mapcar (lambda (x)
- (incf i)
+ (mapcar (lambda (x) (incf i)
(cons x (util:format-as-binary i opsize)))
,ops)))
@@ -62,5 +61,7 @@ concatenated with TYPE."
(+ pos parse:line-number)))
(defun emit (p)
- (format t "~a~%" p)
(eval p))
+
+(defun ast->str (p)
+ (format nil "~a" p))