src/final.lisp: Rename from `debug.lisp'.
[sod] / src / final.lisp
diff --git a/src/final.lisp b/src/final.lisp
new file mode 100644 (file)
index 0000000..dd8834f
--- /dev/null
@@ -0,0 +1,47 @@
+;;; -*-lisp-*-
+;;;
+;;; Finishing touches for Sod
+;;;
+;;; (c) 2015 Straylight/Edgeware
+;;;
+
+;;;----- Licensing notice ---------------------------------------------------
+;;;
+;;; This file is part of the Sensble Object Design, an object system for C.
+;;;
+;;; SOD is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 2 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; SOD is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with SOD; if not, write to the Free Software Foundation,
+;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+(cl:in-package #:sod)
+
+;;;--------------------------------------------------------------------------
+;;; Debugging utilities.
+
+(export '*debugout-pathname*)
+(defvar *debugout-pathname* #p"debugout.c")
+
+(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."
+  (unless *builtin-module* (make-builtin-module))
+  (clear-the-decks)
+  (setf *module-map* (make-hash-table :test #'equal))
+  (with-open-file (out *debugout-pathname*
+                  :direction :output
+                  :if-exists :supersede
+                  :if-does-not-exist :create)
+    (output-module (read-module path) reason out)))
+
+;;;----- That's all, folks --------------------------------------------------