mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Optimize (if #f x y) to just y
This commit is contained in:
parent
c1451e26ae
commit
0fb83a8100
1 changed files with 16 additions and 6 deletions
|
@ -368,9 +368,14 @@
|
|||
((set!? exp)
|
||||
`(set! ,(opt:contract (set!->var exp))
|
||||
,(opt:contract (set!->exp exp))))
|
||||
((if? exp) `(if ,(opt:contract (if->condition exp))
|
||||
,(opt:contract (if->then exp))
|
||||
,(opt:contract (if->else exp))))
|
||||
((if? exp)
|
||||
(cond
|
||||
((not (if->condition exp))
|
||||
(opt:contract (if->else exp)))
|
||||
(else
|
||||
`(if ,(opt:contract (if->condition exp))
|
||||
,(opt:contract (if->then exp))
|
||||
,(opt:contract (if->else exp))))))
|
||||
; Application:
|
||||
((app? exp)
|
||||
(let* ((fnc (opt:contract (car exp))))
|
||||
|
@ -442,9 +447,14 @@
|
|||
((set!? exp)
|
||||
`(set! ,(set!->var exp)
|
||||
,(opt:inline-prims (set!->exp exp) refs)))
|
||||
((if? exp) `(if ,(opt:inline-prims (if->condition exp) refs)
|
||||
,(opt:inline-prims (if->then exp) refs)
|
||||
,(opt:inline-prims (if->else exp) refs)))
|
||||
((if? exp)
|
||||
(cond
|
||||
((not (if->condition exp))
|
||||
(opt:contract (if->else exp)))
|
||||
(else
|
||||
`(if ,(opt:inline-prims (if->condition exp) refs)
|
||||
,(opt:inline-prims (if->then exp) refs)
|
||||
,(opt:inline-prims (if->else exp) refs)))))
|
||||
; Application:
|
||||
((app? exp)
|
||||
;(trace:error `(app? ,exp ,(ast:lambda? (car exp))
|
||||
|
|
Loading…
Add table
Reference in a new issue