mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-17 01:37:34 +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?
|
(compiled-macro?
|
||||||
((Cyc-get-cvar (cadr macro))
|
((Cyc-get-cvar (cadr macro))
|
||||||
exp
|
exp
|
||||||
(Cyc-er-rename mac-env)
|
(Cyc-er-rename mac-env mac-env) ;; TODO: use-env
|
||||||
Cyc-er-compare?))
|
(Cyc-er-compare? mac-env))) ;; TODO: wrong env (?)
|
||||||
(else
|
(else
|
||||||
(eval
|
(eval
|
||||||
(list
|
(list
|
||||||
(Cyc-get-cvar (cadr macro))
|
(Cyc-get-cvar (cadr macro))
|
||||||
(list 'quote exp)
|
(list 'quote exp)
|
||||||
(Cyc-er-rename mac-env)
|
(Cyc-er-rename mac-env mac-env)
|
||||||
Cyc-er-compare?)
|
(Cyc-er-compare? mac-env))
|
||||||
mac-env)))))
|
mac-env)))))
|
||||||
|
|
||||||
; TODO: get macro name, transformer
|
; TODO: get macro name, transformer
|
||||||
|
|
|
@ -423,7 +423,6 @@
|
||||||
;;; Explicit renaming macros
|
;;; Explicit renaming macros
|
||||||
|
|
||||||
;; ER macro rename function, based on code from Chibi scheme
|
;; ER macro rename function, based on code from Chibi scheme
|
||||||
(define (Cyc-er-rename mac-env)
|
|
||||||
; (lambda (sym) sym)) ; TODO: temporary placeholder, see below
|
; (lambda (sym) sym)) ; TODO: temporary placeholder, see below
|
||||||
|
|
||||||
;TODO: I think we're ready to cut back over to this now?
|
;TODO: I think we're ready to cut back over to this now?
|
||||||
|
@ -465,8 +464,11 @@
|
||||||
; a new lambda scope is introduced?
|
; a new lambda scope is introduced?
|
||||||
; - need to keep track of it for compiled macro expansion
|
; - need to keep track of it for compiled macro expansion
|
||||||
;
|
;
|
||||||
|
(define (Cyc-er-rename use-env mac-env)
|
||||||
((lambda (renames)
|
((lambda (renames)
|
||||||
(lambda (identifier)
|
(lambda (identifier)
|
||||||
|
;(Cyc-write `(ER rename ,identifier) (current-output-port))
|
||||||
|
;(Cyc-display "\n" (current-output-port))
|
||||||
((lambda (cell)
|
((lambda (cell)
|
||||||
(if cell
|
(if cell
|
||||||
(cdr cell)
|
(cdr cell)
|
||||||
|
@ -508,10 +510,11 @@
|
||||||
(begin . begin) ;; TODO: just a quick-fix, not a long-term solution
|
(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
|
;; TODO: this is not good enough, need to determine if these symbols
|
||||||
;; are the same identifier in their *environment of use*
|
;; are the same identifier in their *environment of use*
|
||||||
(eq? a b))
|
(lambda (a b)
|
||||||
|
(eq? a b)))
|
||||||
|
|
||||||
;; Name-mangling.
|
;; Name-mangling.
|
||||||
|
|
||||||
|
|
|
@ -440,16 +440,16 @@
|
||||||
;; Compiled macro, call directly
|
;; Compiled macro, call directly
|
||||||
(analyze (apply macro-op
|
(analyze (apply macro-op
|
||||||
(list (cons (car exp) (operands exp))
|
(list (cons (car exp) (operands exp))
|
||||||
(Cyc-er-rename a-env)
|
(Cyc-er-rename a-env a-env)
|
||||||
Cyc-er-compare?))
|
(Cyc-er-compare? a-env)))
|
||||||
a-env)
|
a-env)
|
||||||
;; Interpreted macro, build expression and eval
|
;; Interpreted macro, build expression and eval
|
||||||
(let ((expr (cons macro-op
|
(let ((expr (cons macro-op
|
||||||
(list (cons 'quote
|
(list (cons 'quote
|
||||||
(list (cons (car exp)
|
(list (cons (car exp)
|
||||||
(operands exp))))
|
(operands exp))))
|
||||||
(Cyc-er-rename a-env)
|
(Cyc-er-rename a-env a-env)
|
||||||
Cyc-er-compare?))))
|
(Cyc-er-compare? a-env)))))
|
||||||
(analyze
|
(analyze
|
||||||
(eval expr a-env) ;; Expand macro
|
(eval expr a-env) ;; Expand macro
|
||||||
a-env))))))
|
a-env))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue