Added (self-closure-call? ast self)

This commit is contained in:
Justin Ethier 2018-10-22 13:35:04 -04:00
parent c1e8996ddd
commit eb2ab6b74a

View file

@ -90,6 +90,8 @@
adbf:calls-self? adbf:set-calls-self!
with-fnc
with-fnc!
;; Helpers
self-closure-call?
)
(begin
;; The following two defines allow non-CPS functions to still be considered
@ -1782,6 +1784,20 @@
(list (convert exp #f '()))
#f))
;; Detect closure call of the form:
;; (%closure-ref
;; (cell-get (%closure-ref self$249 1))
;; 0)
(define (self-closure-call? ast self)
(and-let* (((tagged-list? '%closure-ref ast))
((tagged-list? 'cell-get (cadr ast)))
(inner-cref (cadadr ast))
((tagged-list? '%closure-ref inner-cref))
(equal? self (cadr inner-cref))
((equal? 0 (caddr ast)))
)
#t))
(define (analyze:find-named-lets exp)
(define (scan exp lp)
(cond