From 77bf768d096845986af71ca5055c94c4abd626ed Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Thu, 4 Sep 2008 13:04:45 +0000 Subject: [PATCH] 1.0.20.2: Fewer XC/reader-conditional confusions Inspired by Josh Elasser (sbcl-devel 2008-08-29), write code that tries to be clever about reader conditionals in the cross-compiler, in order to point out when a mistake is likely. ... and fix the extra buglet that this reveals. --- make-host-1.lisp | 4 ++++ make-host-2.lisp | 3 +++ src/code/debug-int.lisp | 4 ++-- src/code/target-alieneval.lisp | 4 ++-- src/cold/shebang.lisp | 39 +++++++++++++++++++++++++++++++++++++++ version.lisp-expr | 2 +- 6 files changed, 51 insertions(+), 5 deletions(-) diff --git a/make-host-1.lisp b/make-host-1.lisp index 0a22dfe..6e67ee9 100644 --- a/make-host-1.lisp +++ b/make-host-1.lisp @@ -11,6 +11,10 @@ (setf *host-obj-prefix* "obj/from-host/") (load "src/cold/set-up-cold-packages.lisp") (load "src/cold/defun-load-or-cload-xcompiler.lisp") + +(set-dispatch-macro-character #\# #\+ #'she-reader) +(set-dispatch-macro-character #\# #\- #'she-reader) + (load-or-cload-xcompiler #'host-cload-stem) ;;; Let's check that the type system, and various other things, are diff --git a/make-host-2.lisp b/make-host-2.lisp index 0258b19..43fb52b 100644 --- a/make-host-2.lisp +++ b/make-host-2.lisp @@ -50,6 +50,9 @@ ;; toplevel forms in the xcompiler backq.lisp file? (set-macro-character #\` #'sb!impl::backquote-macro) (set-macro-character #\, #'sb!impl::comma-macro) + + (set-dispatch-macro-character #\# #\+ #'she-reader) + (set-dispatch-macro-character #\# #\- #'she-reader) ;; Control optimization policy. (proclaim-target-optimization) ;; Specify where target machinery lives. diff --git a/src/code/debug-int.lisp b/src/code/debug-int.lisp index 4052fdc..26ca084 100644 --- a/src/code/debug-int.lisp +++ b/src/code/debug-int.lisp @@ -3384,9 +3384,9 @@ register." ;; sense in signaling the condition. (when step-info (let ((*step-frame* - #+(or x86 x86-64) + #!+(or x86 x86-64) (signal-context-frame (sb!alien::alien-sap context)) - #-(or x86 x86-64) + #!-(or x86 x86-64) ;; KLUDGE: Use the first non-foreign frame as the ;; *STACK-TOP-HINT*. Getting the frame from the signal ;; context as on x86 would be cleaner, but diff --git a/src/code/target-alieneval.lisp b/src/code/target-alieneval.lisp index 13143b8..fec2359 100644 --- a/src/code/target-alieneval.lisp +++ b/src/code/target-alieneval.lisp @@ -180,10 +180,10 @@ `(symbol-macrolet ((&auxiliary-type-definitions& ,(append *new-auxiliary-types* (auxiliary-type-definitions env)))) - #+(or x86 x86-64) + #!+(or x86 x86-64) (let ((sb!vm::*alien-stack* sb!vm::*alien-stack*)) ,@body) - #-(or x86 x86-64) + #!-(or x86 x86-64) ,@body))) ;;;; runtime C values that don't correspond directly to Lisp types diff --git a/src/cold/shebang.lisp b/src/cold/shebang.lisp index a70feec..521f412 100644 --- a/src/cold/shebang.lisp +++ b/src/cold/shebang.lisp @@ -61,6 +61,45 @@ (compile 'shebang-reader) (set-dispatch-macro-character #\# #\! #'shebang-reader) +;;; while we are at it, let us write something which helps us sanity +;;; check our own code; it is too easy to write #+ when meaning #!+, +;;; and such mistakes can go undetected for a while. +;;; +;;; ideally we wouldn't use *SHEBANG-FEATURES* but +;;; *ALL-POSSIBLE-SHEBANG-FEATURES*, but maintaining that variable +;;; will not be easy. +(defun checked-feature-in-features-list-p (feature list) + (etypecase feature + (symbol (unless (member feature '(:ansi-cl :common-lisp :ieee-floating-point)) + (when (member feature *shebang-features* :test #'eq) + (error "probable XC bug in host read-time conditional"))) + (member feature list :test #'eq)) + (cons (flet ((subfeature-in-list-p (subfeature) + (checked-feature-in-features-list-p subfeature list))) + (ecase (first feature) + (:or (some #'subfeature-in-list-p (rest feature))) + (:and (every #'subfeature-in-list-p (rest feature))) + (:not (let ((rest (cdr feature))) + (if (or (null (car rest)) (cdr rest)) + (error "wrong number of terms in compound feature ~S" + feature) + (not (subfeature-in-list-p (second feature))))))))))) +(compile 'checked-feature-in-features-list-p) + +(defun she-reader (stream sub-character infix-parameter) + (when infix-parameter + (error "illegal read syntax: #~D~C" infix-parameter sub-character)) + (when (let* ((*package* (find-package "KEYWORD")) + (*read-suppress* nil) + (notp (eql sub-character #\-)) + (feature (read stream))) + (if (checked-feature-in-features-list-p feature *features*) + notp + (not notp))) + (let ((*read-suppress* t)) + (read stream t nil t))) + (values)) +(compile 'she-reader) ;;;; variables like *SHEBANG-FEATURES* but different diff --git a/version.lisp-expr b/version.lisp-expr index 3bc6f6f..147828b 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.20.1" +"1.0.20.2" -- 1.7.10.4