1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +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)
#:use-syntax (lang elisp expand)
#:use-module (lang elisp internals evaluation)
#:use-module (lang elisp internals fset)
#: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:"
(number->string counter)))))))
(define-macro (use-elisp-file file-name . imports)
(define use-elisp-file
(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,
they are interpreted as selection and renaming specifiers as per
@code{use-modules}."
(let ((file-name (cadr exp))
(env (cddr exp)))
(let ((export-module-name (export-module-name)))
`(begin
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
(beautify-user-module! (resolve-module ',export-module-name))
(load-elisp-file ,file-name)
(use-modules (,export-module-name ,@imports))
(fluid-set! ,elisp-export-module #f))))
(fluid-set! ,elisp-export-module #f)))))))
(define-macro (use-elisp-library library . imports)
(define use-elisp-library
(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
are interpreted as selection and renaming specifiers as per
@code{use-modules}."
(let ((library (cadr exp))
(env (cddr exp)))
(let ((export-module-name (export-module-name)))
`(begin
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
(beautify-user-module! (resolve-module ',export-module-name))
(load-elisp-library ,library)
(use-modules (,export-module-name ,@imports))
(fluid-set! ,elisp-export-module #f))))
(fluid-set! ,elisp-export-module #f)))))))
(define (export-to-elisp . defs)
"Export procedures and variables specified by @var{defs} to Elisp.

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
(define-module (lang elisp transform)
#:use-syntax (lang elisp expand)
#:use-module (lang elisp internals trace)
#:use-module (lang elisp internals fset)
#:use-module (lang elisp internals evaluation)
@ -26,7 +27,11 @@
(define (syntax-error x)
(error "Syntax error in expression" x))
(define-macro (scheme exp . module)
(define scheme
(procedure->memoizing-macro
(lambda (exp env)
(let ((exp (cadr exp))
(module (cddr exp)))
(let ((m (if (null? module)
the-root-module
(save-module-excursion
@ -42,7 +47,7 @@
(let ((x `(,eval (,quote ,exp) ,m)))
;;(write x)
;;(newline)
x)))
x))))))
(define (transformer x)
(cond ((pair? x)