projects
/
scheme.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
WIP in let-binding pattern match stuff
[scheme.git]
/
codegen.scm
diff --git
a/codegen.scm
b/codegen.scm
index 52df26ece76527068fd89a7c397c3ca632aeaef4..fb856a54a7da63314890bc6c739ce9cc03c69a01 100644
(file)
--- a/
codegen.scm
+++ b/
codegen.scm
@@
-349,15
+349,15
@@
(set! bound (append (lambda-args e) bound))
(collect (lambda-body e))))
(set! bound (append (lambda-args e) bound))
(collect (lambda-body e))))
- ('app (f
old
-map collect e))
- ('if (f
old
-map collect (cdr e)))
+ ('app (f
lat
-map collect e))
+ ('if (f
lat
-map collect (cdr e)))
('let
('let
- (let ([bind-fvs (f
old
-map (lambda (a)
+ (let ([bind-fvs (f
lat
-map (lambda (a)
(begin
(set! bound (cons (car a) bound))
(collect (cdr a))))
(let-bindings e))])
(begin
(set! bound (cons (car a) bound))
(collect (cdr a))))
(let-bindings e))])
- (append bind-fvs (f
old
-map collect (let-body e)))))
+ (append bind-fvs (f
lat
-map collect (let-body e)))))
(else '())))
(collect prog))
(else '())))
(collect prog))
@@
-523,7
+523,9
@@
(define (codegen program)
(set! cur-label 0)
(set! cur-lambda 0)
(define (codegen program)
(set! cur-label 0)
(set! cur-lambda 0)
- (let* ((extract-res-0 (extract-strings program))
+ (let* ([body (program-body program)]
+
+ (extract-res-0 (extract-strings body))
(strings (car extract-res-0))
(extract-res-1 (extract-lambdas (cdr extract-res-0)))
(lambdas (car extract-res-1))
(strings (car extract-res-0))
(extract-res-1 (extract-lambdas (cdr extract-res-0)))
(lambdas (car extract-res-1))
@@
-541,7
+543,7
@@
(emit "movq %rsp, %rbp") ; set up the base pointer
(emit "movq %rsp, %rbp") ; set up the base pointer
- (codegen-expr xform-prog
wordsize
'())
+ (codegen-expr xform-prog
(- wordsize)
'())
; exit syscall
(emit "mov %rax, %rdi")
; exit syscall
(emit "mov %rax, %rdi")
@@
-559,7
+561,7
@@
(define (compile-to-binary program output t)
(set! target t)
(define (compile-to-binary program output t)
(set! target t)
- (when (not (eq? (typecheck program) '
int)) (error #f "not an i
nt"))
+ (when (not (eq? (typecheck program) '
Int)) (error #f "not an I
nt"))
(let ([tmp-path "/tmp/a.s"])
(when (file-exists? tmp-path) (delete-file tmp-path))
(with-output-to-file tmp-path
(let ([tmp-path "/tmp/a.s"])
(when (file-exists? tmp-path) (delete-file tmp-path))
(with-output-to-file tmp-path