cyclone/cps-opt-analyze-call-graph-test.scm
2018-12-28 06:03:57 -05:00

36 lines
1.2 KiB
Scheme

;; Some notes:
;; Need a new pass to identify all variables that contribute to each computed variable. Maybe write this as a separate program again, will need to flesh this out.
;;
;; Need another pass to flag all vars that cannot be inlined (or just add this to current checks). I think if any contribution var is mutated or passed to a function outside the module being compiled, then the var cannot be inlined. It is probably possible to be a bit smarter?
;;
;; Will have to assess how badly this hurts performance.
;;
(import
(scheme base)
(scheme write)
)
(define (queue-empty) (cons '() '()))
(define objects-dumped (queue-empty))
(define object-queue (queue-empty))
(define (queue->list queue) (car queue))
(define (queue-put! queue x)
(let ((entry (cons x '())))
(if (null? (car queue))
(set-car! queue entry)
(set-cdr! (cdr queue) entry))
(set-cdr! queue entry)
x))
(define (test obj)
(let ((m (length (queue->list objects-dumped))))
(queue-put! objects-dumped obj)
(queue-put! object-queue obj)
m)
)
(queue-put! objects-dumped 'a)
(queue-put! objects-dumped 'b)
(write (queue->list objects-dumped))
(write (test 'c))