From b8ed2e52cd7decd56b195df5363fcc0f17cc3805 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 26 Jul 2022 18:29:40 -0700 Subject: Fix an issue with how the linker combined files. I inserted jump statements into the bytecode at the beginning of each compilation unit, to jump to the init label. The point is that now the bytecode can be executed from start to finish, and assuming the libraries were ordered correctly, it will run the full program. --- csc/codegen.csc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'csc/codegen.csc') diff --git a/csc/codegen.csc b/csc/codegen.csc index f97beec..1fd7099 100644 --- a/csc/codegen.csc +++ b/csc/codegen.csc @@ -248,7 +248,9 @@ (set! locals-map (insert locals-map x local-count)) local-count))))) (append - (ir2->bytecode (fix-body expr) (make-locals-map '())) (loop for func in (fix-functions expr) collect (list 'label (translate-label (closure-name func))) - append (ir2->bytecode (closure-body func) (make-locals-map (closure-arguments func)))))))) + append (ir2->bytecode (closure-body func) (make-locals-map (closure-arguments func)))) + (list + (list 'label 'init)) + (ir2->bytecode (fix-body expr) (make-locals-map '())))))) -- cgit v1.3.1