-
Notifications
You must be signed in to change notification settings - Fork 4
/
note.lisp
45 lines (39 loc) · 1.77 KB
/
note.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(in-package #:cleavir-conditions)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Condition type PROGRAM-NOTE
;;;
;;; PROGRAM-NOTE can be used for information that a programmer may wish to be
;;; informed of but which does not warrant even a STYLE-WARNING. This could
;;; include optimization hints or notes that the compiler will ignore some
;;; declaration because it is not smart enough to use it, for example.
;;; Essentially, there is no problem with the code itself per se, but the
;;; compiler is not doing its best with it.
(define-condition program-note (program-condition) ())
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Function NOTE
;;;
;;; Signal a compiler note. The MUFFLE-NOTE restart can be used to prevent any
;;; reporting from being done. Otherwise, the note will be displayed on
;;; *error-output*.
;;; We have no simple-program-note class for reasons of internal hygeine,
;;; so unlike cl:error and cl:warn, we only accept condition type specifiers
;;; as DATUM.
(defun note (datum &rest arguments)
(let ((note (apply #'make-condition datum arguments)))
(restart-case (signal note)
(muffle-note ()
:report "Silence note."
(return-from note nil)))
;;; TODO: Maybe display origin or provide a way for clients to do so
;;; in some customizable fashion?
(format *error-output* "~&;;; Note: ~a~%" note)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Function MUFFLE-NOTE
;;;
;;; Invoke the MUFFLE-NOTE restart. If there is no active MUFFLE-NOTE restart,
;;; signals a CONTROL-ERROR. In either case, does not return.
(defun muffle-note (&optional condition)
(invoke-restart (find-restart 'muffle-note condition)))