mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Issue #207 - Added constant folding
This commit is contained in:
parent
6e6a4239a4
commit
a758111aad
1 changed files with 13 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
||||||
;(define-library (cps-optimizations) ;; For debugging via local unit tests
|
;(define-library (cps-optimizations) ;; For debugging via local unit tests
|
||||||
(define-library (scheme cyclone cps-optimizations)
|
(define-library (scheme cyclone cps-optimizations)
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
|
(scheme eval)
|
||||||
(scheme cyclone util)
|
(scheme cyclone util)
|
||||||
(scheme cyclone ast)
|
(scheme cyclone ast)
|
||||||
(scheme cyclone primitives)
|
(scheme cyclone primitives)
|
||||||
|
@ -700,9 +701,18 @@
|
||||||
opt:contract
|
opt:contract
|
||||||
(reverse new-args)))))
|
(reverse new-args)))))
|
||||||
(else
|
(else
|
||||||
(cons
|
(let ((result
|
||||||
fnc
|
(cons
|
||||||
(map (lambda (e) (opt:contract e)) (cdr exp)))))))
|
fnc
|
||||||
|
(map (lambda (e) (opt:contract e)) (cdr exp)))))
|
||||||
|
(if (and (prim-call? exp)
|
||||||
|
(precompute-prim-app? result))
|
||||||
|
(with-handler
|
||||||
|
(lambda (err) result)
|
||||||
|
;; TODO: not good enough does not handler Cyc-fast-plus and friends
|
||||||
|
(eval result))
|
||||||
|
result))
|
||||||
|
))))
|
||||||
(else
|
(else
|
||||||
(error "CPS optimize [1] - Unknown expression" exp))))
|
(error "CPS optimize [1] - Unknown expression" exp))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue