Bug fixes for beta expansion

This commit is contained in:
Justin Ethier 2017-05-15 13:37:30 +00:00
parent 7794f3edce
commit eee5695c1f

View file

@ -635,8 +635,8 @@
;; TODO: was testing this with the fibc program ;; TODO: was testing this with the fibc program
;; TODO: real solution is to have a separate beta expansion phase after opt:contract. ;; TODO: real solution is to have a separate beta expansion phase after opt:contract.
;; will need to pass over all the code and expand here in the (app?) clause ;; will need to pass over all the code and expand here in the (app?) clause
;(if (beta-expand? exp) (if (beta-expand? exp)
; (set! exp (beta-expand exp))) (set! exp (beta-expand exp)))
;; END ;; END
(let* ((fnc (opt:contract (car exp)))) (let* ((fnc (opt:contract (car exp))))
@ -1171,6 +1171,7 @@
(car fnc*) (car fnc*)
fnc*))) fnc*)))
(and (ast:lambda? fnc) (and (ast:lambda? fnc)
(not (adbv:reassigned? var))
(not (fnc-depth>? (ast:lambda-body fnc) 4)))) (not (fnc-depth>? (ast:lambda-body fnc) 4))))
))) )))
(else #f))) (else #f)))
@ -1213,10 +1214,12 @@
(if (adbv:cont? var) maybe-cont #f))) (if (adbv:cont? var) maybe-cont #f)))
#f)) #f))
) )
(trace:error `(JAE beta expand ,exp ,var ,fnc ,formals ,cont)) ;(trace:error `(JAE beta expand ,exp ,var ,fnc ,formals ,cont))
(cond (cond
;; TODO: what if fnc has no cont? do we need to handle differently? ;; TODO: what if fnc has no cont? do we need to handle differently?
((and (ast:lambda? fnc) ((and (ast:lambda? fnc)
(not (adbv:reassigned? var)) ;; Failsafe
(not (adbv:cont? var)) ;; TEST, don't delete a continuation
(list? formals) (list? formals)
(= (length args) (length formals))) (= (length args) (length formals)))
;(trace:error `(JAE DEBUG beta expand ,exp)) ;(trace:error `(JAE DEBUG beta expand ,exp))