mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 12:35:05 +02:00
Optimize-out function arguments that are not needed.
This commit is contained in:
parent
496ff85859
commit
5f002237cd
1 changed files with 27 additions and 5 deletions
|
@ -317,11 +317,33 @@
|
||||||
; Application:
|
; Application:
|
||||||
((app? exp)
|
((app? exp)
|
||||||
(cond
|
(cond
|
||||||
((ast:lambda? exp)
|
((and (ast:lambda? (car exp))
|
||||||
TODO: walk param/arg lists, checking for any const args.
|
(= (length (ast:lambda-args (car exp)))
|
||||||
if there are any, need to remove them from lambda args and
|
(length (app->args exp))))
|
||||||
calling params
|
(let ((new-params '())
|
||||||
)
|
(new-args '())
|
||||||
|
(args (cdr exp)))
|
||||||
|
;(trace:error `(DEBUG contract ,args ,(ast:lambda-args (car exp)) ,exp))
|
||||||
|
(for-each
|
||||||
|
(lambda (param)
|
||||||
|
(let ((var (adb:get/default param #f)))
|
||||||
|
(cond
|
||||||
|
((and var (adbv:const? var))
|
||||||
|
#f)
|
||||||
|
(else
|
||||||
|
;; Collect the params/args not optimized-out
|
||||||
|
(set! new-args (cons (car args) new-args))
|
||||||
|
(set! new-params (cons param new-params))))
|
||||||
|
(set! args (cdr args))))
|
||||||
|
(ast:lambda-args (car exp)))
|
||||||
|
(map
|
||||||
|
opt:contract
|
||||||
|
(cons
|
||||||
|
(ast:%make-lambda
|
||||||
|
(ast:lambda-id (car exp))
|
||||||
|
(reverse new-params)
|
||||||
|
(ast:lambda-body (car exp)))
|
||||||
|
(reverse new-args)))))
|
||||||
(else
|
(else
|
||||||
(map (lambda (e) (opt:contract e)) exp))))
|
(map (lambda (e) (opt:contract e)) exp))))
|
||||||
(else
|
(else
|
||||||
|
|
Loading…
Add table
Reference in a new issue