mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
Pass additional environments to er macro functions
This commit is contained in:
parent
1e922a1128
commit
a822bc9e91
3 changed files with 14 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue