From: William Harold Newman Date: Mon, 1 Apr 2002 14:52:22 +0000 (+0000) Subject: 0.7.2.4: X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=4d5c5d322dcca0753474496cde44a9dbfe627496;p=sbcl.git 0.7.2.4: merged NJF DEFINE-SYMBOL-MACRO patch sbcl-devel 2002-03-23 tweaked patch... ...removed "DEFINE-SYMBOL-MACRO" from defun-load-or-cload-xcompiler.lisp (on the theory that since SBCL doesn't use DEFINE-SYMBOL-MACRO itself, we don't need to mess with cross-compiling it and so can make the xcompiler simpler) ...updated MACROEXPAND-1 to handle symbol macros ...tweaked ECASE in EVAL to handle :MACRO case removed related entries in clocc-ansi-test-known-bugs.lisp bumped +FASL-FILE-VERSION+ since the new INFO :VARIABLE :MACRO-EXPANSION code probably displaces other codes, possibly causing stored code to be broken --- diff --git a/BUGS b/BUGS index 536b601..c5172fa 100644 --- a/BUGS +++ b/BUGS @@ -248,12 +248,6 @@ WORKAROUND: ANSI spec, bare 'MEMBER, 'AND, and 'OR are not legal types, CMUCL (and now SBCL) interpret them as legal types. -44: - ANSI specifies DEFINE-SYMBOL-MACRO, but it's not defined in SBCL. - CMU CL added it ca. Aug 13, 2000, after some discussion on the mailing - list, and it is probably possible to use substantially the same - patches to add it to SBCL. - 45: a slew of floating-point-related errors reported by Peter Van Eynde on July 25, 2000: diff --git a/NEWS b/NEWS index 8e5819c..44747a5 100644 --- a/NEWS +++ b/NEWS @@ -1061,9 +1061,10 @@ changes in sbcl-0.7.2 relative to sbcl-0.7.1: changes in sbcl-0.7.2 relative to sbcl-0.7.1: * cleanups on SPARC, both Linux and Solaris, and for gcc>=3 (thanks to Christophe Rhodes and Nathan Froyd) - * DESCRIBE on a symbol now says something about DEFTYPE-style - expansions associated with the symbol (thanks to Eric Marsden's - patch for CMU CL). + * ANSI's DEFINE-SYMBOL-MACRO is now supported. (thanks to Nathan + Froyd porting CMU CL code) + * The fasl file format has changed again, to allow the compiler's + INFO database to support symbol macros. planned incompatible changes in 0.7.x: * When the profiling interface settles down, maybe in 0.7.x, maybe diff --git a/src/code/describe.lisp b/src/code/describe.lisp index 5033aa1..814a1b9 100644 --- a/src/code/describe.lisp +++ b/src/code/describe.lisp @@ -245,6 +245,7 @@ (let* ((kind (info :variable :kind x)) (wot (ecase kind (:special "special variable") + (:macro "symbol macro") (:constant "constant") (:global "undefined variable") (:alien nil)))) @@ -257,6 +258,9 @@ (sb-alien::heap-alien-info-type info))) (format s "~@" (eval x)))) + ((eq kind :macro) + (let ((expansion (info :variable :macro-expansion x))) + (format s "~@:_It is a ~A with expansion ~S." wot expansion))) ((boundp x) (format s "~@:_~@" wot (symbol-value x))) diff --git a/src/code/early-fasl.lisp b/src/code/early-fasl.lisp index 6defa1c..2408b1a 100644 --- a/src/code/early-fasl.lisp +++ b/src/code/early-fasl.lisp @@ -42,7 +42,7 @@ ;;; versions which break binary compatibility. But it certainly should ;;; be incremented for release versions which break binary ;;; compatibility. -(defconstant +fasl-file-version+ 25) +(defconstant +fasl-file-version+ 26) ;;; (record of versions before 0.7.0 deleted in 0.7.1.41) ;;; 23 = sbcl-0.7.0.1 deleted no-longer-used EVAL-STACK stuff, ;;; causing changes in *STATIC-SYMBOLS*. @@ -50,6 +50,7 @@ ;;; called from macroexpanded code ;;; 25 = sbcl-0.7.1.41 (and immediately preceding versions, actually) ;;; introduced new functions to check for control stack exhaustion +;;; 26 = sbcl-0.7.2.4 or so added :VARIABLE :MACRO-EXPANSION to INFO codes ;;; the conventional file extension for our fasl files (declaim (type simple-string *fasl-file-type*)) diff --git a/src/code/macroexpand.lisp b/src/code/macroexpand.lisp index b1049bd..fc570d1 100644 --- a/src/code/macroexpand.lisp +++ b/src/code/macroexpand.lisp @@ -33,7 +33,7 @@ #!+sb-doc "If form is a macro (or symbol macro), expands it once. Returns two values, the expanded form and a T-or-NIL flag indicating whether the form was, in - fact, a macro. Env is the lexical environment to expand in, which defaults + fact, a macro. ENV is the lexical environment to expand in, which defaults to the null environment." (cond ((and (consp form) (symbolp (car form))) (let ((def (sb!xc:macro-function (car form) env))) @@ -56,10 +56,13 @@ ((symbolp form) (let* ((venv (when env (sb!c::lexenv-vars env))) (local-def (cdr (assoc form venv)))) - (if (and (consp local-def) - (eq (car local-def) 'macro)) - (values (cdr local-def) t) - (values form nil)))) + (cond ((and (consp local-def) + (eq (car local-def) 'macro)) + (values (cdr local-def) t)) + ((eq (info :variable :kind form) :macro) + (values (info :variable :macro-expansion form) t)) + (t + (values form nil))))) (t (values form nil)))) diff --git a/src/code/macros.lisp b/src/code/macros.lisp index f7ddd36..5ee726a 100644 --- a/src/code/macros.lisp +++ b/src/code/macros.lisp @@ -180,6 +180,32 @@ the usual naming convention (names like *FOO*) for special variables" (info :variable :constant-value name) value) name) +;;;; DEFINE-SYMBOL-MACRO + +(defmacro-mundanely define-symbol-macro (name expansion) + `(eval-when (:compile-toplevel :load-toplevel :execute) + (sb!c::%define-symbol-macro ',name ',expansion))) + +(defun sb!c::%define-symbol-macro (name expansion) + (unless (symbolp name) + (error 'simple-type-error :datum name :expected-type 'symbol + :format-control "Symbol macro name is not a symbol: ~S." + :format-arguments (list name))) + (ecase (info :variable :kind name) + ((:macro :global nil) + (setf (info :variable :kind name) :macro) + (setf (info :variable :macro-expansion name) expansion)) + (:special + (error 'simple-program-error + :format-control "Symbol macro name already declared special: ~S." + :format-arguments (list name))) + (:constant + (error 'simple-program-error + :format-control "Symbol macro name already declared constant: ~S." + :format-arguments (list name)))) + name) + + ;;;; DEFINE-COMPILER-MACRO ;;; FIXME: The logic here for handling compiler macros named (SETF diff --git a/src/compiler/globaldb.lisp b/src/compiler/globaldb.lisp index 7e13d0f..275f15d 100644 --- a/src/compiler/globaldb.lisp +++ b/src/compiler/globaldb.lisp @@ -1154,7 +1154,7 @@ (define-info-type :class :variable :type :kind - :type-spec (member :special :constant :global :alien) + :type-spec (member :special :constant :macro :global :alien) :default (if (symbol-self-evaluating-p name) :constant :global)) @@ -1189,6 +1189,13 @@ name (bug "constant lookup of nonconstant ~S" name))) +;;; the macro-expansion for symbol-macros +(define-info-type + :class :variable + :type :macro-expansion + :type-spec t + :default nil) + (define-info-type :class :variable :type :alien-info diff --git a/src/compiler/ir1tran.lisp b/src/compiler/ir1tran.lisp index 520b624..c571de3 100644 --- a/src/compiler/ir1tran.lisp +++ b/src/compiler/ir1tran.lisp @@ -172,7 +172,7 @@ ;;; information from the global environment and enter it in ;;; *FREE-VARS*. If the variable is unknown, then we emit a warning. (defun find-free-var (name) - (declare (values (or leaf heap-alien-info))) + (declare (values (or leaf cons heap-alien-info))) ; see FIXME comment (unless (symbolp name) (compiler-error "Variable name is not a symbol: ~S." name)) (or (gethash name *free-vars*) @@ -185,6 +185,15 @@ (case kind (:alien (info :variable :alien-info name)) + ;; FIXME: The return value in this case should really be + ;; of type SB!C::LEAF. I don't feel too badly about it, + ;; because the MACRO idiom is scattered throughout this + ;; file, but it should be cleaned up so we're not + ;; throwing random conses around. --njf 2002-03-23 + (:macro + (let ((expansion (info :variable :macro-expansion name)) + (type (type-specifier (info :variable :type name)))) + `(MACRO . (the ,type ,expansion)))) (:constant (let ((value (info :variable :constant-value name))) (make-constant :value value diff --git a/tests/clocc-ansi-test-known-bugs.lisp b/tests/clocc-ansi-test-known-bugs.lisp index 5ccf5ad..ad6aa37 100644 --- a/tests/clocc-ansi-test-known-bugs.lisp +++ b/tests/clocc-ansi-test-known-bugs.lisp @@ -195,13 +195,14 @@ :SECTION3-LEGACY-733 :SECTION3-LEGACY-750 :SECTION3-LEGACY-783 - :SECTION3-LEGACY-807 - :SECTION3-LEGACY-812 - :SECTION3-LEGACY-816 - :SECTION3-LEGACY-820 - :SECTION3-LEGACY-824 - :SECTION3-LEGACY-832 - :SECTION3-LEGACY-844 + ;; DEFINE-SYMBOL-MACRO stuff fixed by NJF patch merged 2002-03-31: + ;; :SECTION3-LEGACY-807 + ;; :SECTION3-LEGACY-812 + ;; :SECTION3-LEGACY-816 + ;; :SECTION3-LEGACY-820 + ;; :SECTION3-LEGACY-824 + ;; :SECTION3-LEGACY-832 + ;; :SECTION3-LEGACY-844 :SECTION4-LEGACY-111 :SECTION4-LEGACY-115 :SECTION4-LEGACY-119 diff --git a/version.lisp-expr b/version.lisp-expr index 3f8d9ad..6359058 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -18,4 +18,4 @@ ;;; for internal versions, especially for internal versions off the ;;; main CVS branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.7.2.3" +"0.7.2.4"