aboutsummaryrefslogtreecommitdiffstats
path: root/csc/codegen.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-26 18:29:40 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-26 18:29:40 -0700
commitb8ed2e52cd7decd56b195df5363fcc0f17cc3805 (patch)
tree1c650ce05c82ebaf21f3a8b5a259781c2c24843b /csc/codegen.csc
parenta8b7dc2c48f29de2aff5786beedcbe5bc0f3ac50 (diff)
downloadchromatopelma-b8ed2e52cd7decd56b195df5363fcc0f17cc3805.tar.zst
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.
Diffstat (limited to 'csc/codegen.csc')
-rw-r--r--csc/codegen.csc6
1 files changed, 4 insertions, 2 deletions
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 '()))))))