aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-08-23 19:22:05 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-08-23 19:22:05 -0700
commit9e3116423f15269e06b2dad558f07f400e02d210 (patch)
treea93adc2372973285fbeb8cb84ea43a3f0551d798
parentdc8a480c65fabf35b99398120aeccca8f2874c6d (diff)
downloadchromatopelma-9e3116423f15269e06b2dad558f07f400e02d210.tar.zst
Insert references, not values into the map.
This fixes a bug in compiler.csc.
-rw-r--r--lib/csc/compiler.csc11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/csc/compiler.csc b/lib/csc/compiler.csc
index e2e682e..ee6ca0f 100644
--- a/lib/csc/compiler.csc
+++ b/lib/csc/compiler.csc
@@ -3,7 +3,6 @@
add-library-search-dirs
compile)
(import (scheme base)
- (csc format)
(only (scheme file)
call-with-input-file
file-exists?)
@@ -33,7 +32,8 @@
%define-syntax
%library-define
%library-ref
- %sequence)
+ %sequence
+ library-ref-name)
(only (csc ir2)
*tail*)
(only (csc linker)
@@ -132,9 +132,7 @@
(define (ir1->bytecode expr)
(define c (closure-convert (ir1->ir2 expr (lambda (x) *tail*))))
- (printf "ir2 =\n{}\n" c)
(define b (ir2->ir3 c))
- (printf "ir3 =\n{}\n" b)
b)
@@ -161,8 +159,8 @@
(let loop ((expr expanded-body))
(match expr
- ((% %library-define (% %library-ref name _) val)
- (set! env (insert env name val)))
+ ((% %library-define ref _)
+ (set! env (insert env (library-ref-name ref) ref)))
((% %define-syntax name val)
(set! env (insert env name val)))
((% %sequence head tail)
@@ -199,7 +197,6 @@
((('import . imports1) ('import . imports2) . rest)
(compile (cons (cons 'import (append imports1 imports2)) rest)))
((('import . imports) . body)
- (printf "imports {}\n" imports)
(define compiled-body (ir1->bytecode (expand-body 'main body (make-import-map imports))))
(encode (link (revappend library-code (list compiled-body (list (list 'exit (list 'const 0))))))))
(_ (error "unexpected form in compile" program))))))