diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-15 15:11:25 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-15 15:11:25 -0800 |
commit | 06b285ac2c60fd5f8dd5eee24c794d7ef21fee46 (patch) | |
tree | c78baf400f6358cee1de8dc748578c246497d669 /share | |
parent | 29e448c01f92b1fe54511bdaf5564c774a91cb09 (diff) | |
download | txr-06b285ac2c60fd5f8dd5eee24c794d7ef21fee46.tar.gz txr-06b285ac2c60fd5f8dd5eee24c794d7ef21fee46.tar.bz2 txr-06b285ac2c60fd5f8dd5eee24c794d7ef21fee46.zip |
Functions for error reporting out of macros.
* eval.c (eval_init): Register sys:ctx-form and sys:ctx-name
intrinsics.
* lisplib.c (error_set_entries, error_instantiate): New static
functions.
(lisplib_init): Register autoloading of error.tl via
new functions.
* share/txr/stdlib/error.tl: New file.
* struct.c (make_struct_type): Purge deferred warnings.
* unwind.c (uw_late_init): Register purge-deferred-warning
intrinsic.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/error.tl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/share/txr/stdlib/error.tl b/share/txr/stdlib/error.tl new file mode 100644 index 00000000..355b39e6 --- /dev/null +++ b/share/txr/stdlib/error.tl @@ -0,0 +1,46 @@ +;; Copyright 2017 +;; Kaz Kylheku <kaz@kylheku.com> +;; Vancouver, Canada +;; All rights reserved. +;; +;; Redistribution and use in source and binary forms, with or without +;; modification, are permitted provided that the following conditions are met: +;; +;; 1. Redistributions of source code must retain the above copyright notice, this +;; list of conditions and the following disclaimer. +;; +;; 2. Redistributions in binary form must reproduce the above copyright notice, +;; this list of conditions and the following disclaimer in the documentation +;; and/or other materials provided with the distribution. +;; +;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(defun sys:loc (ctx) + (iflet ((loc (source-loc-str (sys:ctx-form ctx)))) + `(@loc) ` "")) + +(defun compile-error (ctx fmt . args) + (let ((loc (sys:loc ctx)) + (name (sys:ctx-name ctx))) + (throwf 'eval-error `@loc~s: @fmt` name . args))) + +(defun compile-warning (ctx fmt . args) + (let ((loc (sys:loc ctx)) + (name (sys:ctx-name ctx))) + (throwf 'warning `@loc~s: @fmt` name . args))) + +(defun compile-defr-warning (ctx tag fmt . args) + (let ((loc (sys:loc ctx)) + (name (sys:ctx-name ctx))) + (catch + (throw 'warning (fmt `@loc~s: @fmt` name . args) . tag) + (continue ())))) |