diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-07-26 18:29:40 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-07-26 18:29:40 -0700 |
| commit | b8ed2e52cd7decd56b195df5363fcc0f17cc3805 (patch) | |
| tree | 1c650ce05c82ebaf21f3a8b5a259781c2c24843b /csc/linker-test.csc | |
| parent | Document the plan for symbols. (diff) | |
| download | chromatopelma-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/linker-test.csc')
| -rw-r--r-- | csc/linker-test.csc | 38 |
1 files changed, 23 insertions, 15 deletions
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)))))) |
