From e33ea30174c46fa2f75abe9341a936a7f597ced3 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 29 Aug 2015 13:19:33 +0100 Subject: [PATCH] src/debug.lisp: New small utility function for interactive testing. Testing at the command line is OK when things can be expected to work, but it's annoying when they're likely to break. This simple function makes things pleasant to debug from inside SLIME. --- src/Makefile.am | 3 +++ src/debug.lisp | 38 ++++++++++++++++++++++++++++++++++++++ src/sod.asd | 3 +++ 3 files changed, 44 insertions(+) create mode 100644 src/debug.lisp diff --git a/src/Makefile.am b/src/Makefile.am index 856d0c1..fd70ab3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -87,6 +87,9 @@ dist_pkglispsrc_DATA += method-proto.lisp method-impl.lisp dist_pkglispsrc_DATA += sod-frontend.asd dist_pkglispsrc_DATA += frontend.lisp optparse.lisp +## Interactive testing. +dist_pkglispsrc_DATA += debug.lisp + ###-------------------------------------------------------------------------- ### Constructing an output image. diff --git a/src/debug.lisp b/src/debug.lisp new file mode 100644 index 0000000..e281397 --- /dev/null +++ b/src/debug.lisp @@ -0,0 +1,38 @@ +;;; -*-lisp-*- +;;; +;;; Debugging utilities 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) + +(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-output-to-string (out) + (output-module (read-module path) reason out))) + +;;;----- That's all, folks -------------------------------------------------- diff --git a/src/sod.asd b/src/sod.asd index a618e39..986615f 100644 --- a/src/sod.asd +++ b/src/sod.asd @@ -164,6 +164,9 @@ ("classes" "class-layout-proto" "class-layout-impl" "method-proto" "method-impl" "output-proto")))) + ;; Debugging and interactive testing. + (:file "debug" :depends-on ("builtin" "module-output")))) + ;;;-------------------------------------------------------------------------- ;;; Testing. -- 2.11.0