diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-07-29 16:42:27 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-07-29 16:42:27 -0700 |
| commit | 0ddb8fb300b916605baa2552eec3dc77b4e6e154 (patch) | |
| tree | a4c9bf70efcf8a950f2e85ecb22b9094e791ca63 /csc/codegen.csc | |
| parent | 6521edcf224b7e044e9fa42a6f9c92fcf738cb34 (diff) | |
| download | chromatopelma-0ddb8fb300b916605baa2552eec3dc77b4e6e154.tar.zst | |
Fix some compilation errors in the compiler.
Diffstat (limited to 'csc/codegen.csc')
| -rw-r--r-- | csc/codegen.csc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/csc/codegen.csc b/csc/codegen.csc index 1fd7099..7712427 100644 --- a/csc/codegen.csc +++ b/csc/codegen.csc @@ -207,6 +207,9 @@ (if (label? proc) (list 'jmp (list 'label proc-temp)) (list 'jmp (list 'local proc-temp)))))) + ((% %tail) + (list + (list 'jmp (list 'label 0)))) (_ (error "Unexpected form in ir2->bytecode expr")))) @@ -225,7 +228,7 @@ ; Converts an IR2 program into bytecode. (define (ir2->ir3 expr) (define label-map (make-map compare-labels)) - (define next-label-id 0) + (define next-label-id 1) ; start at 1 because label 0 is used for tail. (define (translate-label x) (or (lookup label-map x #f) (let ((id next-label-id)) @@ -248,9 +251,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)))) (list - (list 'label 'init)) - (ir2->bytecode (fix-body expr) (make-locals-map '())))))) + (list 'label 0)))))) |
