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 9707578..c7cb148 100644 (file)
@@ -545,7 +545,7 @@ static const SodClass *const ~A__cpl[] = {
       (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 @@ static const SodClass *const ~A__cpl[] = {
     (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 45bb690..510a0a8 100644 (file)
@@ -42,7 +42,6 @@
 (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 3ca4411..2626726 100644 (file)
 ;;;--------------------------------------------------------------------------
 ;;; 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)