Allow a program to use cond-expand for imports

This commit is contained in:
Justin Ethier 2017-02-02 18:29:09 -05:00
parent 3fe1dca790
commit d57f55f406

View file

@ -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 '() '())