+;;;; PCL's view of funcallable instances
+
+(!defstruct-with-alternate-metaclass standard-funcallable-instance
+ ;; KLUDGE: Note that neither of these slots is ever accessed by its
+ ;; accessor name as of sbcl-0.pre7.63. Presumably everything works
+ ;; by puns based on absolute locations. Fun fun fun.. -- WHN 2001-10-30
+ :slot-names (clos-slots name hash-code)
+ :boa-constructor %make-standard-funcallable-instance
+ :superclass-name function
+ :metaclass-name standard-classoid
+ :metaclass-constructor make-standard-classoid
+ :dd-type funcallable-structure
+ ;; Only internal implementation code will access these, and these
+ ;; accesses (slot readers in particular) could easily be a
+ ;; bottleneck, so it seems reasonable to suppress runtime type
+ ;; checks.
+ ;;
+ ;; (Except note KLUDGE above that these accessors aren't used at all
+ ;; (!) as of sbcl-0.pre7.63, so for now it's academic.)
+ :runtime-type-checks-p nil)
+
+(import 'sb-kernel:funcallable-instance-p)
+
+(defun set-funcallable-instance-function (fin new-value)
+ (declare (type function new-value))
+ (aver (funcallable-instance-p fin))
+ (setf (funcallable-instance-fun fin) new-value))
+
+;;; FIXME: these macros should just go away. It's not clear whether
+;;; the inline functions defined by
+;;; !DEFSTRUCT-WITH-ALTERNATE-METACLASS are as efficient as they could
+;;; be; ordinary defstruct accessors are defined as source transforms.
+(defun fsc-instance-p (fin)
+ (funcallable-instance-p fin))
+(define-compiler-macro fsc-instance-p (fin)
+ `(funcallable-instance-p ,fin))
+(defmacro fsc-instance-wrapper (fin)
+ `(%funcallable-instance-layout ,fin))
+(defmacro fsc-instance-slots (fin)
+ `(%funcallable-instance-info ,fin 1))
+(defmacro fsc-instance-hash (fin)
+ `(%funcallable-instance-info ,fin 3))
+\f
+(declaim (inline clos-slots-ref (setf clos-slots-ref)))