mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-11 06:47:37 +02:00
Setup test harness
This commit is contained in:
parent
b76da942a0
commit
348b85c492
2 changed files with 94 additions and 58 deletions
|
@ -17,8 +17,8 @@
|
||||||
; can write initial analyze, but can't get too far without being able
|
; can write initial analyze, but can't get too far without being able
|
||||||
; to uniquely ID each lambda
|
; to uniquely ID each lambda
|
||||||
|
|
||||||
;(define-library (cps-optimizations)
|
(define-library (cps-optimizations)
|
||||||
(define-library (scheme cyclone cps-optimizations)
|
;(define-library (scheme cyclone cps-optimizations)
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme cyclone util)
|
(scheme cyclone util)
|
||||||
(scheme cyclone ast)
|
(scheme cyclone ast)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
(scheme cyclone transforms)
|
(cps-optimizations)
|
||||||
|
; (scheme cyclone transforms)
|
||||||
(scheme cyclone pretty-print)
|
(scheme cyclone pretty-print)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,41 +11,95 @@
|
||||||
;; (cons
|
;; (cons
|
||||||
;; x
|
;; x
|
||||||
;; (cons y z))))
|
;; (cons y z))))
|
||||||
|
;
|
||||||
|
;(define code
|
||||||
|
;'(((lambda ()
|
||||||
|
; 0
|
||||||
|
; ((lambda (x$3 y$2 z$1)
|
||||||
|
; (write (cons x$3 (cons y$2 z$1))))
|
||||||
|
; 1
|
||||||
|
; 2
|
||||||
|
; 3))))
|
||||||
|
;)
|
||||||
|
;
|
||||||
|
;;; thought - can either CPS or CPS-opti convert the CPS code
|
||||||
|
;;; to prevent wrapping non-cont prims in functions, but just
|
||||||
|
;;; add them directly to calling lambda's?
|
||||||
|
;(pretty-print
|
||||||
|
; (cps-convert code))
|
||||||
|
;
|
||||||
|
;
|
||||||
|
;((lambda (result)
|
||||||
|
; <lambda-body>)
|
||||||
|
; (prim ...))
|
||||||
|
;
|
||||||
|
;can we convert that to (assuming prim does not require a continuation):
|
||||||
|
;
|
||||||
|
; <lambda-body>
|
||||||
|
;
|
||||||
|
; with `(prim ...)` replacing any occurences of `result`.
|
||||||
|
;
|
||||||
|
;then, what would this look like? ->
|
||||||
|
;also, what does it mean for other phases after CPS?
|
||||||
|
;at a minimum, it is going to require changes to the cgen phase because that
|
||||||
|
;makes some assumptions about there only being one prim per function, I believe
|
||||||
|
;
|
||||||
|
;;; Original:
|
||||||
|
;#;(#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(6
|
||||||
|
; ()
|
||||||
|
; ((#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(5
|
||||||
|
; (r$2)
|
||||||
|
; ((#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(4
|
||||||
|
; (x$3 y$2 z$1)
|
||||||
|
; ((#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(3
|
||||||
|
; (r$4)
|
||||||
|
; ((#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(2
|
||||||
|
; (r$3)
|
||||||
|
; ((write #((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(1 (r$1) ((r$1 %halt))))
|
||||||
|
; r$3))))
|
||||||
|
; (cons x$3 r$4)))))
|
||||||
|
; (cons y$2 z$1)))))
|
||||||
|
; 1
|
||||||
|
; 2
|
||||||
|
; 3))))
|
||||||
|
; 0)))))
|
||||||
|
;
|
||||||
|
;;; TODO: update
|
||||||
|
;(#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(6
|
||||||
|
; ()
|
||||||
|
; ((#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(5
|
||||||
|
; (r$2)
|
||||||
|
; ((#((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(4
|
||||||
|
; (x$3 y$2 z$1)
|
||||||
|
; ((write #((record-marker)
|
||||||
|
; #((record-marker) #f (id args body))
|
||||||
|
; #(1 (r$1) ((r$1 %halt))))
|
||||||
|
; (cons x$3 (cons y$2 z$1))))))
|
||||||
|
; 1
|
||||||
|
; 2
|
||||||
|
; 3))))
|
||||||
|
; 0)))))
|
||||||
|
|
||||||
(define code
|
(define code
|
||||||
'(((lambda ()
|
'(#((record-marker)
|
||||||
0
|
|
||||||
((lambda (x$3 y$2 z$1)
|
|
||||||
(write (cons x$3 (cons y$2 z$1))))
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3))))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; thought - can either CPS or CPS-opti convert the CPS code
|
|
||||||
;; to prevent wrapping non-cont prims in functions, but just
|
|
||||||
;; add them directly to calling lambda's?
|
|
||||||
(pretty-print
|
|
||||||
(cps-convert code))
|
|
||||||
|
|
||||||
|
|
||||||
((lambda (result)
|
|
||||||
<lambda-body>)
|
|
||||||
(prim ...))
|
|
||||||
|
|
||||||
can we convert that to (assuming prim does not require a continuation):
|
|
||||||
|
|
||||||
<lambda-body>
|
|
||||||
|
|
||||||
with `(prim ...)` replacing any occurences of `result`.
|
|
||||||
|
|
||||||
then, what would this look like? ->
|
|
||||||
also, what does it mean for other phases after CPS?
|
|
||||||
at a minimum, it is going to require changes to the cgen phase because that
|
|
||||||
makes some assumptions about there only being one prim per function, I believe
|
|
||||||
|
|
||||||
;; Original:
|
|
||||||
#;(#((record-marker)
|
|
||||||
#((record-marker) #f (id args body))
|
#((record-marker) #f (id args body))
|
||||||
#(6
|
#(6
|
||||||
()
|
()
|
||||||
|
@ -74,25 +129,6 @@ makes some assumptions about there only being one prim per function, I believe
|
||||||
2
|
2
|
||||||
3))))
|
3))))
|
||||||
0)))))
|
0)))))
|
||||||
|
)
|
||||||
;; TODO: update
|
(pretty-print
|
||||||
(#((record-marker)
|
(contract-prims code))
|
||||||
#((record-marker) #f (id args body))
|
|
||||||
#(6
|
|
||||||
()
|
|
||||||
((#((record-marker)
|
|
||||||
#((record-marker) #f (id args body))
|
|
||||||
#(5
|
|
||||||
(r$2)
|
|
||||||
((#((record-marker)
|
|
||||||
#((record-marker) #f (id args body))
|
|
||||||
#(4
|
|
||||||
(x$3 y$2 z$1)
|
|
||||||
((write #((record-marker)
|
|
||||||
#((record-marker) #f (id args body))
|
|
||||||
#(1 (r$1) ((r$1 %halt))))
|
|
||||||
(cons x$3 (cons y$2 z$1))))))
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3))))
|
|
||||||
0)))))
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue