-;;; This function is called at compile-time to do the
-;;; compile-time-only actions for defining a structure type. It
-;;; installs the class in the type system in a similar way to
-;;; %DEFSTRUCT, but is quieter and safer in the case of redefinition.
-;;;
-;;; The comments for the classic CMU CL version of this function said
-;;; that EVAL-WHEN doesn't do the right thing when nested or
-;;; non-top-level, and so CMU CL had the function magically called by
-;;; the compiler. Unfortunately, this doesn't do the right thing
-;;; either: compiling a function (DEFUN FOO () (DEFSTRUCT FOO X Y))
-;;; causes the class FOO to become defined, even though FOO is never
-;;; loaded or executed. Even more unfortunately, I've been unable to
-;;; come up with any EVAL-WHEN tricks which work -- I finally gave up
-;;; on this approach when trying to get the system to cross-compile
-;;; error.lisp. (Just because I haven't found it doesn't mean that it
-;;; doesn't exist, of course. Alas, I continue to have some trouble
-;;; understanding compile/load semantics in Common Lisp.) So we
-;;; continue to use the IR1 transformation approach, even though it's
-;;; known to be buggy. -- WHN 19990507
-;;;
-;;; Basically, this function avoids trashing the compiler by only
-;;; actually defining the class if there is no current definition.
-;;; Instead, we just set the INFO TYPE COMPILER-LAYOUT. This behavior
-;;; is left over from classic CMU CL and may not be necessary in the
-;;; new build system. -- WHN 19990507
-;;;
-;;; FUNCTION-%COMPILER-ONLY-DEFSTRUCT is an ordinary function, called
-;;; by both the IR1 transform version of %COMPILER-ONLY-DEFSTRUCT and
-;;; by the ordinary function version of %COMPILER-ONLY-DEFSTRUCT. (The
-;;; ordinary function version is there for the interpreter and for
-;;; code walkers.)
-(defun %compiler-only-defstruct (info inherits)
- (function-%compiler-only-defstruct info inherits))
-(defun function-%compiler-only-defstruct (info inherits)
+;;; Return a form describing the writable place used for this slot
+;;; in the instance named INSTANCE-NAME.
+(defun %accessor-place-form (dd dsd instance-name)
+ (let (;; the operator that we'll use to access a typed slot or, in
+ ;; the case of a raw slot, to read the vector of raw slots
+ (ref (ecase (dd-type dd)
+ (structure '%instance-ref)
+ (funcallable-structure '%funcallable-instance-info)
+ (list 'nth-but-with-sane-arg-order)
+ (vector 'aref)))
+ (raw-type (dsd-raw-type dsd)))
+ (if (eq raw-type t) ; if not raw slot
+ `(,ref ,instance-name ,(dsd-index dsd))
+ (let (;; the operator that we'll use to access one value in
+ ;; the raw data vector
+ (rawref (ecase raw-type
+ ;; The compiler thinks that the raw data
+ ;; vector is a vector of unsigned bytes, so if
+ ;; the slot we want to access actually *is* an
+ ;; unsigned byte, it'll access the slot for
+ ;; us even if we don't lie to it at all.
+ (unsigned-byte 'aref)
+ ;; "A lie can travel halfway round the world while
+ ;; the truth is putting on its shoes." -- Mark Twain
+ (single-float '%raw-ref-single)
+ (double-float '%raw-ref-double)
+ #!+long-float (long-float '%raw-ref-long)
+ (complex-single-float '%raw-ref-complex-single)
+ (complex-double-float '%raw-ref-complex-double)
+ #!+long-float (complex-long-float
+ '%raw-ref-complex-long))))
+ `(,rawref (,ref ,instance-name ,(dd-raw-index dd))
+ ,(dsd-index dsd))))))
+
+;;; Return inline expansion designators (i.e. values suitable for
+;;; (INFO :FUNCTION :INLINE-EXPANSSION-DESIGNATOR ..)) for the reader
+;;; and writer functions of the slot described by DSD.
+(defun accessor-inline-expansion-designators (dd dsd)
+ ;; ordinary tagged non-raw slot case
+ (values (lambda ()
+ `(lambda (instance)
+ (declare (type ,(dd-name dd) instance))
+ (truly-the ,(dsd-type dsd)
+ ,(%accessor-place-form dd dsd 'instance))))
+ (lambda ()
+ `(lambda (new-value instance)
+ (declare (type ,(dsd-type dsd) new-value))
+ (declare (type ,(dd-name dd) structure-object))
+ (setf ,(%accessor-place-form dd dsd 'instance) new-value)))))
+
+;;; Do (COMPILE LOAD EVAL)-time actions for the defstruct described by DD.
+(defun %compiler-defstruct (dd inherits)
+ (declare (type defstruct-description dd))