mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 00:07:36 +02:00
Allow a program to use cond-expand for imports
This commit is contained in:
parent
3fe1dca790
commit
d57f55f406
1 changed files with 14 additions and 8 deletions
22
cyclone.scm
22
cyclone.scm
|
@ -288,6 +288,14 @@
|
||||||
;; - imports
|
;; - imports
|
||||||
;; - remaining program
|
;; - remaining program
|
||||||
(define (import-reduction expr)
|
(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
|
(let ((results
|
||||||
(foldl
|
(foldl
|
||||||
(lambda (ex accum)
|
(lambda (ex accum)
|
||||||
|
@ -298,14 +306,12 @@
|
||||||
(else
|
(else
|
||||||
(cons (car accum) (cons e (cdr accum))))))
|
(cons (car accum) (cons e (cdr accum))))))
|
||||||
(cond
|
(cond
|
||||||
;; TODO: this part does not work yet, would need to load
|
((tagged-list? 'cond-expand ex)
|
||||||
;; the base macro environment first
|
(let ((ex* (expand ex (macro:get-env) rename-env)))
|
||||||
;((tagged-list? 'cond-expand ex)
|
;(trace:info `(DEBUG ,ex* ,ex))
|
||||||
; (let ((ex* (expand ex (macro:get-env) '())))
|
(if (tagged-list? 'import ex*)
|
||||||
; (trace:info `(DEBUG ,ex* ,ex))
|
(process ex*)
|
||||||
; (if (tagged-list? 'import ex*)
|
(process ex))))
|
||||||
; (process ex*)
|
|
||||||
; (process ex))))
|
|
||||||
(else
|
(else
|
||||||
(process ex))))
|
(process ex))))
|
||||||
(cons '() '())
|
(cons '() '())
|
||||||
|
|
Loading…
Add table
Reference in a new issue