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/codegen-test.csc | |
| parent | a8b7dc2c48f29de2aff5786beedcbe5bc0f3ac50 (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/codegen-test.csc')
| -rw-r--r-- | csc/codegen-test.csc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/csc/codegen-test.csc b/csc/codegen-test.csc index 01eda04..03f6b11 100644 --- a/csc/codegen-test.csc +++ b/csc/codegen-test.csc @@ -34,7 +34,8 @@ (test codegen-apply (define p (test-var)) (assert-equal - '((peek (local 1) (local 0) (const 5)) + '((label init) + (peek (local 1) (local 0) (const 5)) (mov (local 2) (local 1)) (mov (local 1) (const 10)) (jmp (local 2))) @@ -47,7 +48,8 @@ (test codegen-call-global (define p (test-var)) (assert-equal - '((peek (local 1) (local 0) (global cons (csc based))) + '((label init) + (peek (local 1) (local 0) (global cons (csc based))) (mov (local 3) (local 1)) (mov (local 1) (const 5)) (mov (local 2) (const ())) @@ -62,11 +64,12 @@ (define f (test-label)) (define ret (test-var)) (assert-equal - '((mov (local 1) (label 0)) - (jmp (label 0)) - (label 0) + '((label 0) (mov (local 2) (local 1)) - (jmp (local 2))) + (jmp (local 2)) + (label init) + (mov (local 1) (label 0)) + (jmp (label 0))) (ir2->ir3 (make-fix (list (make-closure f (list ret) @@ -83,10 +86,7 @@ (define g2 (test-var)) (define g3 (test-var)) (assert-equal - '((mov (local 1) (const 0)) - (mov (local 2) (const 1)) - (jmp (label 0)) - (label 0) + '((label 0) (mov (local 127) (local 1)) (mov (local 1) (local 2)) (mov (local 2) (local 127)) @@ -95,6 +95,10 @@ (label 1) (mov (local 2) (local 1)) (mov (local 1) (local 3)) + (jmp (label 0)) + (label init) + (mov (local 1) (const 0)) + (mov (local 2) (const 1)) (jmp (label 0))) (ir2->ir3 (make-fix @@ -108,7 +112,8 @@ (test codegen-branch (define p (test-var)) (assert-equal - '((peek (local 1) (local 0) (const 1)) + '((label init) + (peek (local 1) (local 0) (const 1)) (jmpif (const #t) (label 0)) (mov (local 2) (local 1)) (mov (local 1) (const 10)) |
