mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-20 22:29:16 +02:00
Replace const variables
This commit is contained in:
parent
b746646801
commit
e06ece8e36
1 changed files with 12 additions and 3 deletions
|
@ -46,7 +46,9 @@
|
||||||
adbv:set-assigned!
|
adbv:set-assigned!
|
||||||
adbv:assigned-locally?
|
adbv:assigned-locally?
|
||||||
adbv:set-assigned-locally!
|
adbv:set-assigned-locally!
|
||||||
adbv:const-value?
|
adbv:const?
|
||||||
|
adbv:set-const!
|
||||||
|
adbv:const-value
|
||||||
adbv:set-const-value!
|
adbv:set-const-value!
|
||||||
adbv:ref-by
|
adbv:ref-by
|
||||||
adbv:set-ref-by!
|
adbv:set-ref-by!
|
||||||
|
@ -75,7 +77,7 @@
|
||||||
(assigned adbv:assigned? adbv:set-assigned!)
|
(assigned adbv:assigned? adbv:set-assigned!)
|
||||||
(assigned-locally adbv:assigned-locally? adbv:set-assigned-locally!)
|
(assigned-locally adbv:assigned-locally? adbv:set-assigned-locally!)
|
||||||
(const adbv:const? adbv:set-const!)
|
(const adbv:const? adbv:set-const!)
|
||||||
(const-value adbv:const-value? adbv:set-const-value!)
|
(const-value adbv:const-value adbv:set-const-value!)
|
||||||
(ref-by adbv:ref-by adbv:set-ref-by!)
|
(ref-by adbv:ref-by adbv:set-ref-by!)
|
||||||
)
|
)
|
||||||
(define (adb:make-var)
|
(define (adb:make-var)
|
||||||
|
@ -296,7 +298,11 @@
|
||||||
(ast:lambda-args exp)
|
(ast:lambda-args exp)
|
||||||
(opt:contract (ast:lambda-body exp))))))
|
(opt:contract (ast:lambda-body exp))))))
|
||||||
((const? exp) exp)
|
((const? exp) exp)
|
||||||
((ref? exp) exp)
|
((ref? exp)
|
||||||
|
(let ((var (adb:get/default exp #f)))
|
||||||
|
(if (and var (adbv:const? var))
|
||||||
|
(adbv:const-value var)
|
||||||
|
exp)))
|
||||||
((prim? exp) exp)
|
((prim? exp) exp)
|
||||||
((quote? exp) exp)
|
((quote? exp) exp)
|
||||||
((define? exp)
|
((define? exp)
|
||||||
|
@ -310,6 +316,9 @@
|
||||||
,(opt:contract (if->else exp))))
|
,(opt:contract (if->else exp))))
|
||||||
; Application:
|
; Application:
|
||||||
((app? exp)
|
((app? exp)
|
||||||
|
;; TODO: check for ast:lambda, and if so check for any const args.
|
||||||
|
;; if there are any, need to remove them from lambda args and
|
||||||
|
;; calling params
|
||||||
(map (lambda (e) (opt:contract e)) exp))
|
(map (lambda (e) (opt:contract e)) exp))
|
||||||
(else
|
(else
|
||||||
(error "CPS optimize [1] - Unknown expression" exp))))
|
(error "CPS optimize [1] - Unknown expression" exp))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue