chiark / gitweb /
src/: Disentangle some pieces of module-parsing preparation.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 Jun 2018 18:58:28 +0000 (19:58 +0100)
Have `*module-map*' initialized in strictly one place, rather than a
`defparameter' and sneakily in `test-module'.  This is now a
`clear-the-decks' operation.  Use `defvar-unbound' to leave a trap for
the incautious who try to use it before the decks are cleared.

src/builtin.lisp
src/final.lisp
src/module-impl.lisp

index 97075785ee569b5e695ae527ee5a7da7612021b3..c7cb1488fd01bd62f12aeed20bcc4abde4c03c22 100644 (file)
@@ -545,7 +545,7 @@ (defun bootstrap-classes (module)
       (add-to-module module class))))
 
 (export '*builtin-module*)
-(defvar *builtin-module* nil
+(defvar-unbound *builtin-module*
   "The builtin module.")
 
 (export 'make-builtin-module)
@@ -582,6 +582,6 @@ (defun make-builtin-module ()
     (setf *builtin-module* module)))
 
 (define-clear-the-decks builtin-module
-  (unless *builtin-module* (make-builtin-module)))
+  (unless (boundp '*builtin-module*) (make-builtin-module)))
 
 ;;;----- That's all, folks --------------------------------------------------
index 45bb69078647df1a8e8e956946fbdfb9e986a127..510a0a87064c03c99e3aad201325178a79585108 100644 (file)
@@ -42,7 +42,6 @@ (export 'test-module)
 (defun test-module (path reason)
   "Reset the translator's state, read a module from PATH and output it with
    REASON, returning the result as a string."
-  (setf *module-map* (make-hash-table :test #'equal))
   (with-open-file (out *debugout-pathname*
                   :direction :output
                   :if-exists :supersede
index 3ca44114954aa857625ced8e144e4ea0cb6c7e24..262672667733d395a3f336f58daa7a60a27eff10 100644 (file)
@@ -56,8 +56,10 @@ (defmethod finalize-module ((module module))
 ;;;--------------------------------------------------------------------------
 ;;; Module objects.
 
-(defparameter *module-map* (make-hash-table :test #'equal)
+(defvar-unbound *module-map*
   "Hash table mapping true names to module objects.")
+(define-clear-the-decks reset-module-map
+  (setf *module-map* (make-hash-table :test #'equal)))
 
 (defun build-module
     (name thunk &key (truename (probe-file name)) location)