Pass additional environments to er macro functions

This commit is contained in:
Justin Ethier 2016-09-14 17:36:53 -04:00
parent 1e922a1128
commit a822bc9e91
3 changed files with 14 additions and 11 deletions

View file

@ -66,15 +66,15 @@
(compiled-macro?
((Cyc-get-cvar (cadr macro))
exp
(Cyc-er-rename mac-env)
Cyc-er-compare?))
(Cyc-er-rename mac-env mac-env) ;; TODO: use-env
(Cyc-er-compare? mac-env))) ;; TODO: wrong env (?)
(else
(eval
(list
(Cyc-get-cvar (cadr macro))
(list 'quote exp)
(Cyc-er-rename mac-env)
Cyc-er-compare?)
(Cyc-er-rename mac-env mac-env)
(Cyc-er-compare? mac-env))
mac-env)))))
; TODO: get macro name, transformer

View file

@ -423,7 +423,6 @@
;;; Explicit renaming macros
;; ER macro rename function, based on code from Chibi scheme
(define (Cyc-er-rename mac-env)
; (lambda (sym) sym)) ; TODO: temporary placeholder, see below
;TODO: I think we're ready to cut back over to this now?
@ -465,8 +464,11 @@
; a new lambda scope is introduced?
; - need to keep track of it for compiled macro expansion
;
(define (Cyc-er-rename use-env mac-env)
((lambda (renames)
(lambda (identifier)
;(Cyc-write `(ER rename ,identifier) (current-output-port))
;(Cyc-display "\n" (current-output-port))
((lambda (cell)
(if cell
(cdr cell)
@ -508,10 +510,11 @@
(begin . begin) ;; TODO: just a quick-fix, not a long-term solution
)))
(define (Cyc-er-compare? a b)
(define (Cyc-er-compare? use-env)
;; TODO: this is not good enough, need to determine if these symbols
;; are the same identifier in their *environment of use*
(eq? a b))
(lambda (a b)
(eq? a b)))
;; Name-mangling.

View file

@ -440,16 +440,16 @@
;; Compiled macro, call directly
(analyze (apply macro-op
(list (cons (car exp) (operands exp))
(Cyc-er-rename a-env)
Cyc-er-compare?))
(Cyc-er-rename a-env a-env)
(Cyc-er-compare? a-env)))
a-env)
;; Interpreted macro, build expression and eval
(let ((expr (cons macro-op
(list (cons 'quote
(list (cons (car exp)
(operands exp))))
(Cyc-er-rename a-env)
Cyc-er-compare?))))
(Cyc-er-rename a-env a-env)
(Cyc-er-compare? a-env)))))
(analyze
(eval expr a-env) ;; Expand macro
a-env))))))