From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: src/: Disentangle some pieces of module-parsing preparation. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/e7d43325b56fc912c6ae55225e55529aff12b6ed src/: Disentangle some pieces of module-parsing preparation. 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. --- diff --git a/src/builtin.lisp b/src/builtin.lisp index 9707578..c7cb148 100644 --- a/src/builtin.lisp +++ b/src/builtin.lisp @@ -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 -------------------------------------------------- diff --git a/src/final.lisp b/src/final.lisp index 45bb690..510a0a8 100644 --- a/src/final.lisp +++ b/src/final.lisp @@ -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 diff --git a/src/module-impl.lisp b/src/module-impl.lisp index 3ca4411..2626726 100644 --- a/src/module-impl.lisp +++ b/src/module-impl.lisp @@ -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)