mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
WIP, eliminating more unused lambda's
This commit is contained in:
parent
2fd88a15e6
commit
8ed042573a
1 changed files with 38 additions and 24 deletions
|
@ -1468,7 +1468,20 @@
|
||||||
((app? exp)
|
((app? exp)
|
||||||
(let ((fn (car exp))
|
(let ((fn (car exp))
|
||||||
(args (map cc (cdr exp))))
|
(args (map cc (cdr exp))))
|
||||||
(if (lambda? fn)
|
(cond
|
||||||
|
((lambda? fn)
|
||||||
|
(cond
|
||||||
|
;; If the lambda argument is not used, flag so the C code is
|
||||||
|
;; all generated within the same function
|
||||||
|
((and (eq? (lambda-formals-type fn) 'args:fixed)
|
||||||
|
(with-var
|
||||||
|
(car (lambda-formals->list fn))
|
||||||
|
(lambda (var)
|
||||||
|
(zero? (adbv:ref-count var)))))
|
||||||
|
`(Cyc-seq
|
||||||
|
,@args
|
||||||
|
,@(map cc (lambda->exp fn))))
|
||||||
|
(else
|
||||||
(let* ((body (lambda->exp fn))
|
(let* ((body (lambda->exp fn))
|
||||||
(new-free-vars
|
(new-free-vars
|
||||||
(difference
|
(difference
|
||||||
|
@ -1490,11 +1503,12 @@
|
||||||
; No free vars, just create simple lambda
|
; No free vars, just create simple lambda
|
||||||
`((lambda ,(lambda->formals fn)
|
`((lambda ,(lambda->formals fn)
|
||||||
,@(map cc body))
|
,@(map cc body))
|
||||||
,@args)))
|
,@args))))))
|
||||||
|
(else
|
||||||
(let ((f (cc fn)))
|
(let ((f (cc fn)))
|
||||||
`((%closure-ref ,f 0)
|
`((%closure-ref ,f 0)
|
||||||
,f
|
,f
|
||||||
,@args)))))
|
,@args))))))
|
||||||
(else
|
(else
|
||||||
(error "unhandled exp: " exp))))
|
(error "unhandled exp: " exp))))
|
||||||
(cc exp))
|
(cc exp))
|
||||||
|
|
Loading…
Add table
Reference in a new issue