mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-20 06:09:17 +02:00
Build macro env on top of global env
This commit is contained in:
parent
1244ea5342
commit
9a3d370de4
3 changed files with 9 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
|||
;; This module contains a front-end for the compiler itself.
|
||||
;;
|
||||
(import (scheme base)
|
||||
(scheme eval)
|
||||
(scheme file)
|
||||
(scheme read)
|
||||
(scheme write)
|
||||
|
@ -121,7 +122,7 @@
|
|||
(append
|
||||
macros
|
||||
*defined-macros*)))
|
||||
(macro:load-env! *defined-macros*)
|
||||
(macro:load-env! *defined-macros* (create-environment '() '()))
|
||||
;TODO: try this again, make sure macro is loaded:
|
||||
(trace:info (list 'defined-macros *defined-macros*))
|
||||
(trace:info (list 'macro-env (macro:get-env)))
|
||||
|
|
|
@ -27,13 +27,13 @@
|
|||
(cons (cons name body) *macro:defined-macros*))
|
||||
#t)
|
||||
|
||||
(define (macro:load-env! defined-macros)
|
||||
(define (macro:load-env! defined-macros base-env)
|
||||
(set! *macro:env* (env:extend-environment
|
||||
(map car defined-macros)
|
||||
(map (lambda (v)
|
||||
(list 'macro (cdr v)))
|
||||
defined-macros)
|
||||
env:the-empty-environment)))
|
||||
base-env)))
|
||||
|
||||
(define (macro:get-env) *macro:env*)
|
||||
|
||||
|
@ -54,10 +54,10 @@
|
|||
(let* ((macro (assoc (car exp) defined-macros))
|
||||
(compiled-macro? (or (macro? (Cyc-get-cvar (cdr macro)))
|
||||
(procedure? (cdr macro)))))
|
||||
(newline)
|
||||
(display "/* ")
|
||||
(display (list 'macro:expand exp macro compiled-macro?))
|
||||
(display "*/ ")
|
||||
;(newline)
|
||||
;(display "/* ")
|
||||
;(display (list 'macro:expand exp macro compiled-macro?))
|
||||
;(display "*/ ")
|
||||
;; Invoke ER macro
|
||||
(cond
|
||||
((not macro)
|
||||
|
|
|
@ -791,7 +791,7 @@
|
|||
; Newer macro expansion code, but not ready yet
|
||||
((symbol? (car exp))
|
||||
(let ((val (env:lookup (car exp) env #f)))
|
||||
(if val
|
||||
(if (tagged-list? 'macro val)
|
||||
(expand ; Could expand into another macro
|
||||
(macro:expand 'val exp env *defined-macros*)
|
||||
;(macro:expand2 exp val env)
|
||||
|
|
Loading…
Add table
Reference in a new issue