From 144c5845fc455850e05c14e52731037ff49ed5bb Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 16 Jan 2018 19:46:16 -0500 Subject: [PATCH] Fixes for renaming local bindings Still need to associate them with a macro --- scheme/eval.sld | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scheme/eval.sld b/scheme/eval.sld index fa4c8f41..6744835b 100644 --- a/scheme/eval.sld +++ b/scheme/eval.sld @@ -917,11 +917,11 @@ (map cdr a-lookup) ltype)) ) - (newline) - (display "/* ") - (display (list 'expand a-lookup)) - (newline) - (display "*/ ") +;; (newline) +;; (display "/* ") +;; (display (list 'expand a-lookup)) +;; (newline) +;; (display "*/ ") `(lambda ,new-formals ;,(lambda->formals exp) ,@(_expand-body '() @@ -1120,7 +1120,6 @@ (cond ((or (const? this-exp) (prim? this-exp) - (ref? this-exp) (quote? this-exp) (define-c? this-exp)) ;(log this-exp) @@ -1131,6 +1130,18 @@ rename-env local-env local-renamed)) + ((ref? this-exp) + (let* ((renamed (assoc this-exp local-renamed)) + (sym (if renamed + (cdr renamed) ;; Extract renamed symbol + this-exp))) + (_expand-body + (cons sym result) + (cdr exp) + env + rename-env + local-env + local-renamed))) ((define? this-exp) ;(log this-exp) (_expand-body