From d57f55f40671a9abb66684abf9381a7f2e599cae Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 2 Feb 2017 18:29:09 -0500 Subject: [PATCH] Allow a program to use cond-expand for imports --- cyclone.scm | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cyclone.scm b/cyclone.scm index 4d8052e9..ca7d1c68 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -288,6 +288,14 @@ ;; - imports ;; - remaining program (define (import-reduction expr) + ;; TODO: consolidate this with other macro loading code + (define rename-env (env:extend-environment '() '() '())) + (let ((macros (filter + (lambda (v) + (Cyc-macro? (Cyc-get-cvar (cdr v)))) + (Cyc-global-vars)))) + (macro:load-env! macros (create-environment '() '()))) + ;; (let ((results (foldl (lambda (ex accum) @@ -298,14 +306,12 @@ (else (cons (car accum) (cons e (cdr accum)))))) (cond - ;; TODO: this part does not work yet, would need to load - ;; the base macro environment first - ;((tagged-list? 'cond-expand ex) - ; (let ((ex* (expand ex (macro:get-env) '()))) - ; (trace:info `(DEBUG ,ex* ,ex)) - ; (if (tagged-list? 'import ex*) - ; (process ex*) - ; (process ex)))) + ((tagged-list? 'cond-expand ex) + (let ((ex* (expand ex (macro:get-env) rename-env))) + ;(trace:info `(DEBUG ,ex* ,ex)) + (if (tagged-list? 'import ex*) + (process ex*) + (process ex)))) (else (process ex)))) (cons '() '())