From 9e3116423f15269e06b2dad558f07f400e02d210 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 23 Aug 2022 19:22:05 -0700 Subject: Insert references, not values into the map. This fixes a bug in compiler.csc. --- lib/csc/compiler.csc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'lib/csc/compiler.csc') 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)))))) -- cgit v1.3.1