1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

Fix the elisp memoizer code for syncase-in-boot-9

* lang/elisp/interface.scm:
* lang/elisp/internals/lambda.scm:
* lang/elisp/primitives/syntax.scm:
* lang/elisp/transform.scm: Use (lang elisp expand) as the transformer,
  because we really are intending this code for the memoizer and not the
  compiler.

* lang/elisp/expand.scm: A null expander.

* lang/elisp/interface.scm (use-elisp-file, use-elisp-library):
* lang/elisp/transform.scm (scheme): Turn these defmacros into
  procedure->memoizing-macro calls, given that without syncase we have no
  defmacro either.

* lang/elisp/primitives/fns.scm (macroexpand): Comment out, as Scheme's
  macro expander (temporarily on hiatus) won't work with elisp.
This commit is contained in:
Andy Wingo 2009-04-25 19:09:19 +02:00
parent 97ce9dbf21
commit 39f30ea29d
6 changed files with 57 additions and 36 deletions

4
lang/elisp/expand.scm Normal file
View file

@ -0,0 +1,4 @@
(define-module (lang elisp expand)
#:export (expand))
(define (expand x) x)

View file

@ -1,4 +1,5 @@
(define-module (lang elisp interface) (define-module (lang elisp interface)
#:use-syntax (lang elisp expand)
#:use-module (lang elisp internals evaluation) #:use-module (lang elisp internals evaluation)
#:use-module (lang elisp internals fset) #:use-module (lang elisp internals fset)
#:use-module ((lang elisp internals load) #:select ((load . elisp:load))) #:use-module ((lang elisp internals load) #:select ((load . elisp:load)))
@ -66,31 +67,39 @@ one of the directories of @code{load-path}."
(string->symbol (string-append "imports:" (string->symbol (string-append "imports:"
(number->string counter))))))) (number->string counter)))))))
(define-macro (use-elisp-file file-name . imports) (define use-elisp-file
"Load Elisp code file @var{file-name} and import its definitions (procedure->memoizing-macro
(lambda (exp env)
"Load Elisp code file @var{file-name} and import its definitions
into the current Scheme module. If any @var{imports} are specified, into the current Scheme module. If any @var{imports} are specified,
they are interpreted as selection and renaming specifiers as per they are interpreted as selection and renaming specifiers as per
@code{use-modules}." @code{use-modules}."
(let ((export-module-name (export-module-name))) (let ((file-name (cadr exp))
`(begin (env (cddr exp)))
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name)) (let ((export-module-name (export-module-name)))
(beautify-user-module! (resolve-module ',export-module-name)) `(begin
(load-elisp-file ,file-name) (fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
(use-modules (,export-module-name ,@imports)) (beautify-user-module! (resolve-module ',export-module-name))
(fluid-set! ,elisp-export-module #f)))) (load-elisp-file ,file-name)
(use-modules (,export-module-name ,@imports))
(fluid-set! ,elisp-export-module #f)))))))
(define-macro (use-elisp-library library . imports) (define use-elisp-library
"Load Elisp library @var{library} and import its definitions into (procedure->memoizing-macro
(lambda (exp env)
"Load Elisp library @var{library} and import its definitions into
the current Scheme module. If any @var{imports} are specified, they the current Scheme module. If any @var{imports} are specified, they
are interpreted as selection and renaming specifiers as per are interpreted as selection and renaming specifiers as per
@code{use-modules}." @code{use-modules}."
(let ((export-module-name (export-module-name))) (let ((library (cadr exp))
`(begin (env (cddr exp)))
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name)) (let ((export-module-name (export-module-name)))
(beautify-user-module! (resolve-module ',export-module-name)) `(begin
(load-elisp-library ,library) (fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
(use-modules (,export-module-name ,@imports)) (beautify-user-module! (resolve-module ',export-module-name))
(fluid-set! ,elisp-export-module #f)))) (load-elisp-library ,library)
(use-modules (,export-module-name ,@imports))
(fluid-set! ,elisp-export-module #f)))))))
(define (export-to-elisp . defs) (define (export-to-elisp . defs)
"Export procedures and variables specified by @var{defs} to Elisp. "Export procedures and variables specified by @var{defs} to Elisp.

View file

@ -1,4 +1,5 @@
(define-module (lang elisp internals lambda) (define-module (lang elisp internals lambda)
#:use-syntax (lang elisp expand)
#:use-module (lang elisp internals fset) #:use-module (lang elisp internals fset)
#:use-module (lang elisp transform) #:use-module (lang elisp transform)
#:export (parse-formals #:export (parse-formals

View file

@ -26,7 +26,8 @@
(fset 'symbol-function fref/error-if-void) (fset 'symbol-function fref/error-if-void)
(fset 'macroexpand macroexpand) ;; FIXME -- lost in the syncase conversion
;; (fset 'macroexpand macroexpand)
(fset 'subrp (fset 'subrp
(lambda (obj) (lambda (obj)

View file

@ -1,4 +1,5 @@
(define-module (lang elisp primitives syntax) (define-module (lang elisp primitives syntax)
#:use-syntax (lang elisp expand)
#:use-module (lang elisp internals evaluation) #:use-module (lang elisp internals evaluation)
#:use-module (lang elisp internals fset) #:use-module (lang elisp internals fset)
#:use-module (lang elisp internals lambda) #:use-module (lang elisp internals lambda)

View file

@ -1,4 +1,5 @@
(define-module (lang elisp transform) (define-module (lang elisp transform)
#:use-syntax (lang elisp expand)
#:use-module (lang elisp internals trace) #:use-module (lang elisp internals trace)
#:use-module (lang elisp internals fset) #:use-module (lang elisp internals fset)
#:use-module (lang elisp internals evaluation) #:use-module (lang elisp internals evaluation)
@ -26,23 +27,27 @@
(define (syntax-error x) (define (syntax-error x)
(error "Syntax error in expression" x)) (error "Syntax error in expression" x))
(define-macro (scheme exp . module) (define scheme
(let ((m (if (null? module) (procedure->memoizing-macro
the-root-module (lambda (exp env)
(save-module-excursion (let ((exp (cadr exp))
(lambda () (module (cddr exp)))
;; In order for `resolve-module' to work as (let ((m (if (null? module)
;; expected, the current module must contain the the-root-module
;; `app' variable. This is not true for #:pure (save-module-excursion
;; modules, specifically (lang elisp base). So, (lambda ()
;; switch to the root module (guile) before calling ;; In order for `resolve-module' to work as
;; resolve-module. ;; expected, the current module must contain the
(set-current-module the-root-module) ;; `app' variable. This is not true for #:pure
(resolve-module (car module))))))) ;; modules, specifically (lang elisp base). So,
(let ((x `(,eval (,quote ,exp) ,m))) ;; switch to the root module (guile) before calling
;;(write x) ;; resolve-module.
;;(newline) (set-current-module the-root-module)
x))) (resolve-module (car module)))))))
(let ((x `(,eval (,quote ,exp) ,m)))
;;(write x)
;;(newline)
x))))))
(define (transformer x) (define (transformer x)
(cond ((pair? x) (cond ((pair? x)