mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
WIP - passing AST lambda's to closure-convert
This commit is contained in:
parent
8f8df24b15
commit
7b76453591
1 changed files with 11 additions and 10 deletions
|
@ -1618,16 +1618,16 @@
|
|||
(let ((fn (car exp))
|
||||
(args (map cc (cdr exp))))
|
||||
(cond
|
||||
((lambda? fn)
|
||||
((ast:lambda? fn)
|
||||
(cond
|
||||
;; If the lambda argument is not used, flag so the C code is
|
||||
;; all generated within the same function
|
||||
((and #f
|
||||
(> optimization-level 0)
|
||||
(eq? (lambda-formals-type fn) 'args:fixed)
|
||||
(pair? (lambda-formals->list fn))
|
||||
(eq? (ast:lambda-formals-type fn) 'args:fixed)
|
||||
(pair? (ast:lambda-formals->list fn))
|
||||
(with-var
|
||||
(car (lambda-formals->list fn))
|
||||
(car (ast:lambda-formals->list fn))
|
||||
(lambda (var)
|
||||
(zero? (adbv:ref-count var))))
|
||||
;; Non-CPS args
|
||||
|
@ -1640,12 +1640,12 @@
|
|||
args))
|
||||
`(Cyc-seq
|
||||
,@args
|
||||
,@(map cc (lambda->exp fn))))
|
||||
,@(map cc (ast:lambda-body fn))))
|
||||
(else
|
||||
(let* ((body (lambda->exp fn))
|
||||
(let* ((body (ast:lambda-body fn))
|
||||
(new-free-vars
|
||||
(difference
|
||||
(difference (free-vars body) (lambda-formals->list fn))
|
||||
(difference (free-vars body) (ast:lambda-formals->list fn))
|
||||
globals))
|
||||
(new-free-vars? (> (length new-free-vars) 0)))
|
||||
(if new-free-vars?
|
||||
|
@ -1654,16 +1654,17 @@
|
|||
`((%closure
|
||||
(lambda
|
||||
,(list->lambda-formals
|
||||
(cons new-self-var (lambda-formals->list fn))
|
||||
(lambda-formals-type fn))
|
||||
(cons new-self-var (ast:lambda-formals->list fn))
|
||||
(ast:lambda-formals-type fn))
|
||||
,(convert (car body) new-self-var new-free-vars))
|
||||
,@(map (lambda (v) (cc v))
|
||||
new-free-vars))
|
||||
,@args))
|
||||
; No free vars, just create simple lambda
|
||||
`((lambda ,(lambda->formals fn)
|
||||
`((lambda ,(ast:lambda-args fn)
|
||||
,@(map cc body))
|
||||
,@args))))))
|
||||
((lambda? fn) (error `(Unexpected lambda in closure-convert ,exp)))
|
||||
(else
|
||||
(let ((f (cc fn)))
|
||||
`((%closure-ref ,f 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue