Setup for tracking loop vars

This commit is contained in:
Justin Ethier 2019-09-16 21:25:21 -04:00
parent e6c23e25c1
commit b6732b988a

View file

@ -779,6 +779,12 @@ if (acc) {
(is-in? (cdr S))))) (is-in? (cdr S)))))
(is-in? mutable-variables)) (is-in? mutable-variables))
(define mutated-loop-vars '())
(define (mark-mutated-loop-var sym)
(set! mutated-loop-vars (cons sym mutated-loop-vars)))
(define (mutated-loop-var? sym)
(member sym mutated-loop-var))
; analyze-mutable-variables : exp -> void ; analyze-mutable-variables : exp -> void
(define (analyze-mutable-variables exp) (define (analyze-mutable-variables exp)
(cond (cond
@ -803,6 +809,14 @@ if (acc) {
; Application: ; Application:
((app? exp) ((app? exp)
(map analyze-mutable-variables exp) (map analyze-mutable-variables exp)
;; Check if the application is a sentinel indicating the
;; var may be used for a recursive loop.
;(when (and (= 2 (length exp))
; (ast:lambda? (car exp))
; (not (cadr exp)))
; ;; Candidate, see if the var is set to a lambda
; (with-var
;)
(void)) (void))
(else (else
(error "unknown expression type: " exp)))) (error "unknown expression type: " exp))))