mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 13:05:05 +02:00
WIP - opt:contract
This commit is contained in:
parent
b606ccf150
commit
7dce420886
1 changed files with 26 additions and 2 deletions
|
@ -228,8 +228,32 @@
|
||||||
)))
|
)))
|
||||||
|
|
||||||
;; Perform contraction phase of CPS optimizations
|
;; Perform contraction phase of CPS optimizations
|
||||||
(define (opt:contract ast)
|
(define (opt:contract exp)
|
||||||
ast) ;'TODO)
|
(cond
|
||||||
|
; Core forms:
|
||||||
|
((ast:lambda? exp)
|
||||||
|
;(let ((fnc (adb:get id)))
|
||||||
|
;; TODO: simplify if necessary
|
||||||
|
(ast:%make-lambda
|
||||||
|
(ast:lambda-id exp)
|
||||||
|
(ast:lambda-args exp)
|
||||||
|
(ast:lambda-body exp)));)
|
||||||
|
((ref? exp) exp)
|
||||||
|
((const? exp) exp)
|
||||||
|
((define? exp)
|
||||||
|
`(define ,(opt:contract (define->var exp))
|
||||||
|
,(opt:contract (define->exp exp))))
|
||||||
|
((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))))
|
||||||
|
; Application:
|
||||||
|
((app? exp)
|
||||||
|
(map (lambda (e) (opt:contract e)) exp))
|
||||||
|
(else
|
||||||
|
(error "CPS optimize [1] - Unknown expression" exp))))
|
||||||
|
|
||||||
(define (analyze-cps exp)
|
(define (analyze-cps exp)
|
||||||
(analyze exp -1) ;; Top-level is lambda ID -1
|
(analyze exp -1) ;; Top-level is lambda ID -1
|
||||||
|
|
Loading…
Add table
Reference in a new issue