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:
parent
97ce9dbf21
commit
39f30ea29d
6 changed files with 57 additions and 36 deletions
4
lang/elisp/expand.scm
Normal file
4
lang/elisp/expand.scm
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(define-module (lang elisp expand)
|
||||||
|
#:export (expand))
|
||||||
|
|
||||||
|
(define (expand x) x)
|
|
@ -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
|
||||||
|
(procedure->memoizing-macro
|
||||||
|
(lambda (exp env)
|
||||||
"Load Elisp code file @var{file-name} and import its definitions
|
"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 ((file-name (cadr exp))
|
||||||
|
(env (cddr exp)))
|
||||||
(let ((export-module-name (export-module-name)))
|
(let ((export-module-name (export-module-name)))
|
||||||
`(begin
|
`(begin
|
||||||
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
|
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
|
||||||
(beautify-user-module! (resolve-module ',export-module-name))
|
(beautify-user-module! (resolve-module ',export-module-name))
|
||||||
(load-elisp-file ,file-name)
|
(load-elisp-file ,file-name)
|
||||||
(use-modules (,export-module-name ,@imports))
|
(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
|
"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 ((library (cadr exp))
|
||||||
|
(env (cddr exp)))
|
||||||
(let ((export-module-name (export-module-name)))
|
(let ((export-module-name (export-module-name)))
|
||||||
`(begin
|
`(begin
|
||||||
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
|
(fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
|
||||||
(beautify-user-module! (resolve-module ',export-module-name))
|
(beautify-user-module! (resolve-module ',export-module-name))
|
||||||
(load-elisp-library ,library)
|
(load-elisp-library ,library)
|
||||||
(use-modules (,export-module-name ,@imports))
|
(use-modules (,export-module-name ,@imports))
|
||||||
(fluid-set! ,elisp-export-module #f))))
|
(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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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,7 +27,11 @@
|
||||||
(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
|
||||||
|
(procedure->memoizing-macro
|
||||||
|
(lambda (exp env)
|
||||||
|
(let ((exp (cadr exp))
|
||||||
|
(module (cddr exp)))
|
||||||
(let ((m (if (null? module)
|
(let ((m (if (null? module)
|
||||||
the-root-module
|
the-root-module
|
||||||
(save-module-excursion
|
(save-module-excursion
|
||||||
|
@ -42,7 +47,7 @@
|
||||||
(let ((x `(,eval (,quote ,exp) ,m)))
|
(let ((x `(,eval (,quote ,exp) ,m)))
|
||||||
;;(write x)
|
;;(write x)
|
||||||
;;(newline)
|
;;(newline)
|
||||||
x)))
|
x))))))
|
||||||
|
|
||||||
(define (transformer x)
|
(define (transformer x)
|
||||||
(cond ((pair? x)
|
(cond ((pair? x)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue