projects
/
scheme.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove redundant range definition
[scheme.git]
/
codegen.scm
diff --git
a/codegen.scm
b/codegen.scm
index 7a12fc2228795b588cfbf117d3f1e7712f282be6..10e005f8ad90e840aad396da4a0cdb5032163f6c 100644
(file)
--- a/
codegen.scm
+++ b/
codegen.scm
@@
-76,11
+76,6
@@
('linux (emit "mov $1, %rax"))) ; syscall 1 (write)
(emit "syscall"))
('linux (emit "mov $1, %rax"))) ; syscall 1 (write)
(emit "syscall"))
-(define (range s n)
- (if (= 0 n) '()
- (append (range s (- n 1))
- (list (+ s (- n 1))))))
-
(define wordsize 8)
(define (codegen-let bindings body si env)
(define wordsize 8)
(define (codegen-let bindings body si env)
@@
-349,15
+344,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
+518,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))
@@
-559,7
+556,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