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/linker-test.csc | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'csc/linker-test.csc') diff --git a/csc/linker-test.csc b/csc/linker-test.csc index cc07a74..d3481a9 100644 --- a/csc/linker-test.csc +++ b/csc/linker-test.csc @@ -27,37 +27,45 @@ (test link-labels (assert-equal - '((jmp (const 1)) - (jmp (const 0))) + '((jmp (const 3)) + (jmp (const 2)) + (jmp (const 1)) + (jmp (const 1))) (link '(((label 0) (jmp (label 1)) (label 1) + (jmp (label 0)) + (label init) (jmp (label 0)))) (make-map compare-globals)))) (test link-labels-are-unique-per-program (assert-equal - '((jmp (const 1)) - (jmp (const 0)) - (jmp (const 3)) - (jmp (const 2))) + '((jmp (const 2)) + (jmp (const 1)) + (jmp (const 1)) + (jmp (const 5)) + (jmp (const 4)) + (jmp (const 4))) (link '(((label 0) - (jmp (label 1)) - (label 1) - (jmp (label 0))) - ((label 0) - (jmp (label 1)) - (label 1) - (jmp (label 0)))) + (jmp (label 0)) + (label init) + (jmp (label 0))) + ((label 0) + (jmp (label 0)) + (label init) + (jmp (label 0)))) (make-map compare-globals)))) (test link-globals (assert-equal - '((peek (local 0) (const 10))) + '((jmp (const 1)) + (peek (local 0) (const 10))) (link - '(((peek (local 0) (global cons (csc based))))) + '(((label init) + (peek (local 0) (global cons (csc based))))) (alist->map compare-globals '(((global cons (csc based)) . 10)))))) -- cgit v1.3.1