Changeset 11764


Ignore:
Timestamp:
04/18/09 20:17:41 (14 years ago)
Author:
ehuelsmann
Message:

Don't use the implementation details in WITH-COMPILATION-UNIT
to signal errors. Move around some code to achieve that.
At the same time, switch away from using specials in favor of
variables being closed over.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compile-system.lisp

    r11677 r11764  
    271271    (time
    272272     (with-compilation-unit ()
    273        (let ((*compile-file-zip* zip))
    274          (%compile-system :output-path output-path))
    275        (when (zerop (+ jvm::*errors* jvm::*warnings*))
    276          (setf status 0))))
     273       (let ((*compile-file-zip* zip)
     274             failure-p)
     275         (handler-bind (((or warning
     276                             compiler-error)
     277                         #'(lambda (c)
     278                             (declare (ignore c))
     279                             (setf failure-p t)
     280                             ;; only register that we had this type of signal
     281                             ;; defer the actual handling to another handler
     282                             nil)))
     283           (%compile-system :output-path output-path))
     284         (unless failure-p
     285           (setf status 0)))))
    277286    (when quit
    278287      (quit :status status))))
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11763 r11764  
    10021002  (fix-boxing representation nil)
    10031003  (emit-move-from-stack target representation))
    1004 
    1005 (defvar *style-warnings* nil)
    1006 (defvar *warnings* nil)
    1007 (defvar *errors* nil)
    1008 
    1009 (defvar *last-error-context* nil)
    1010 
    1011 (defun note-error-context ()
    1012   (let ((context *compiler-error-context*))
    1013     (when (and context (neq context *last-error-context*))
    1014       (fresh-line *error-output*)
    1015       (princ "; in " *error-output*)
    1016       (let ((*print-length* 2)
    1017             (*print-level* 2)
    1018             (*print-pretty* nil))
    1019         (prin1 context *error-output*))
    1020       (terpri *error-output*)
    1021       (terpri *error-output*)
    1022       (setf *last-error-context* context))))
    1023 
    1024 (defvar *resignal-compiler-warnings* nil) ; bind this to t inside slime compilation
    1025 
    1026 (defun handle-style-warning (condition)
    1027   (cond (*resignal-compiler-warnings*
    1028          (signal condition))
    1029         (t
    1030          (unless *suppress-compiler-warnings*
    1031            (fresh-line *error-output*)
    1032            (note-error-context)
    1033            (format *error-output* "; Caught ~A:~%;   ~A~2%" (type-of condition) condition))
    1034          (incf *style-warnings*)
    1035          (muffle-warning))))
    1036 
    1037 (defun handle-warning (condition)
    1038   (cond (*resignal-compiler-warnings*
    1039          (signal condition))
    1040         (t
    1041          (unless *suppress-compiler-warnings*
    1042            (fresh-line *error-output*)
    1043            (note-error-context)
    1044            (format *error-output* "; Caught ~A:~%;   ~A~2%" (type-of condition) condition))
    1045          (incf *warnings*)
    1046          (muffle-warning))))
    1047 
    1048 (defun handle-compiler-error (condition)
    1049   (fresh-line *error-output*)
    1050   (note-error-context)
    1051   (format *error-output* "; Caught ERROR:~%;   ~A~2%" condition)
    1052   (incf *errors*)
    1053   (throw 'compile-defun-abort (funcall *compiler-error-bailout*)))
    10541004
    10551005;; "In addition to situations for which the standard specifies that conditions
     
    86988648(defvar *catch-errors* t)
    86998649
     8650(defvar *last-error-context* nil)
     8651
     8652(defun note-error-context ()
     8653  (let ((context *compiler-error-context*))
     8654    (when (and context (neq context *last-error-context*))
     8655      (fresh-line *error-output*)
     8656      (princ "; in " *error-output*)
     8657      (let ((*print-length* 2)
     8658            (*print-level* 2)
     8659            (*print-pretty* nil))
     8660        (prin1 context *error-output*))
     8661      (terpri *error-output*)
     8662      (terpri *error-output*)
     8663      (setf *last-error-context* context))))
     8664
     8665
     8666(defvar *resignal-compiler-warnings* nil
     8667  "Bind this to t inside slime compilation")
     8668
     8669(defun handle-warning (condition)
     8670  (cond (*resignal-compiler-warnings*
     8671         (signal condition))
     8672        (t
     8673         (unless *suppress-compiler-warnings*
     8674           (fresh-line *error-output*)
     8675           (note-error-context)
     8676           (format *error-output* "; Caught ~A:~%;   ~A~2%"
     8677                   (type-of condition) condition))
     8678         (muffle-warning))))
     8679
     8680(defun handle-compiler-error (condition)
     8681  (fresh-line *error-output*)
     8682  (note-error-context)
     8683  (format *error-output* "; Caught ERROR:~%;   ~A~2%" condition)
     8684  (throw 'compile-defun-abort (funcall *compiler-error-bailout*)))
     8685
    87008686(defvar *in-compilation-unit* nil)
    87018687
     
    87048690
    87058691(defun %with-compilation-unit (fn &key override)
    8706   (handler-bind ((style-warning 'handle-style-warning)
    8707                  (warning 'handle-warning)
    8708                  (compiler-error 'handle-compiler-error))
    8709     (if (and *in-compilation-unit* (not override))
    8710         (funcall fn)
    8711         (let ((*style-warnings* 0)
    8712               (*warnings* 0)
    8713               (*errors* 0)
    8714               (*defined-functions* nil)
    8715               (*undefined-functions* nil)
    8716               (*in-compilation-unit* t))
    8717           (unwind-protect
    8718               (funcall fn)
    8719             (unless (or (and *suppress-compiler-warnings* (zerop *errors*))
    8720                         (and (zerop (+ *errors* *warnings* *style-warnings*))
    8721                              (null *undefined-functions*)))
    8722               (format *error-output* "~%; Compilation unit finished~%")
    8723               (unless (zerop *errors*)
    8724                 (format *error-output* ";   Caught ~D ERROR condition~P~%"
    8725                         *errors* *errors*))
    8726               (unless *suppress-compiler-warnings*
    8727                 (unless (zerop *warnings*)
    8728                   (format *error-output* ";   Caught ~D WARNING condition~P~%"
    8729                           *warnings* *warnings*))
    8730                 (unless (zerop *style-warnings*)
    8731                   (format *error-output* ";   Caught ~D STYLE-WARNING condition~P~%"
    8732                           *style-warnings* *style-warnings*))
    8733                 (when *undefined-functions*
    8734                   (format *error-output* ";   The following functions were used but not defined:~%")
    8735                   (dolist (name *undefined-functions*)
    8736                     (format *error-output* ";     ~S~%" name))))
    8737               (terpri *error-output*)))))))
     8692  (if (and *in-compilation-unit* (not override))
     8693      (funcall fn)
     8694      (let ((style-warnings 0)
     8695            (warnings 0)
     8696            (errors 0)
     8697            (*defined-functions* nil)
     8698            (*undefined-functions* nil)
     8699            (*in-compilation-unit* t))
     8700        (unwind-protect
     8701             (handler-bind ((style-warning #'(lambda (c)
     8702                                               (incf style-warnings)
     8703                                               (handle-warning c)))
     8704                            (warning #'(lambda (c)
     8705                                         (incf warnings)
     8706                                         (handle-warning c)))
     8707                            (compiler-error #'(lambda (c)
     8708                                                (incf errors)
     8709                                                (handle-compiler-error c))))
     8710               (funcall fn))
     8711          (unless (or (and *suppress-compiler-warnings* (zerop errors))
     8712                      (and (zerop (+ errors warnings style-warnings))
     8713                           (null *undefined-functions*)))
     8714            (format *error-output*
     8715                    "~%; Compilation unit finished~%")
     8716            (unless (zerop errors)
     8717              (format *error-output*
     8718                      ";   Caught ~D ERROR condition~P~%"
     8719                      errors errors))
     8720            (unless *suppress-compiler-warnings*
     8721              (unless (zerop warnings)
     8722                (format *error-output*
     8723                        ";   Caught ~D WARNING condition~P~%"
     8724                        warnings warnings))
     8725              (unless (zerop style-warnings)
     8726                (format *error-output*
     8727                        ";   Caught ~D STYLE-WARNING condition~P~%"
     8728                        style-warnings style-warnings))
     8729              (when *undefined-functions*
     8730                (format *error-output*
     8731                        ";   The following functions were used but not defined:~%")
     8732                (dolist (name *undefined-functions*)
     8733                  (format *error-output* ";     ~S~%" name))))
     8734            (terpri *error-output*))))))
    87388735
    87398736(defun get-lambda-to-compile (thing)
Note: See TracChangeset for help on using the changeset viewer.