WIP, eliminating more unused lambda's

This commit is contained in:
Justin Ethier 2017-07-07 14:14:16 +00:00
parent 2fd88a15e6
commit 8ed042573a

View file

@ -1468,7 +1468,20 @@
((app? exp)
(let ((fn (car 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))
(new-free-vars
(difference
@ -1490,11 +1503,12 @@
; No free vars, just create simple lambda
`((lambda ,(lambda->formals fn)
,@(map cc body))
,@args)))
,@args))))))
(else
(let ((f (cc fn)))
`((%closure-ref ,f 0)
,f
,@args)))))
,@args))))))
(else
(error "unhandled exp: " exp))))
(cc exp))