1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; This software is derived from software originally released by Xerox
5 ;;;; Corporation. Copyright and release statements follow. Later modifications
6 ;;;; to the software are in the public domain and are provided with
7 ;;;; absolutely no warranty. See the COPYING and CREDITS files for more
10 ;;;; copyright information from original PCL sources:
12 ;;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
13 ;;;; All rights reserved.
15 ;;;; Use and copying of this software and preparation of derivative works based
16 ;;;; upon this software are permitted. Any distribution of this software or
17 ;;;; derivative works must comply with all applicable United States export
20 ;;;; This software is made available AS IS, and Xerox Corporation makes no
21 ;;;; warranty about the software, its performance or its conformity to any
26 (let ((reader-specializers '(slot-object))
27 (writer-specializers '(t slot-object
)))
28 (defun ensure-accessor (type fun-name slot-name
)
29 (unless (fboundp fun-name
)
30 (multiple-value-bind (lambda-list specializers method-class initargs doc
)
32 ;; FIXME: change SLOT-OBJECT here to T to get SLOT-MISSING
33 ;; behaviour for non-slot-objects too?
35 (values '(object) reader-specializers
'global-reader-method
36 (make-std-reader-method-function 'slot-object slot-name
)
37 "automatically-generated reader method"))
39 (values '(new-value object
) writer-specializers
41 (make-std-writer-method-function 'slot-object slot-name
)
42 "automatically-generated writer method"))
44 (values '(object) reader-specializers
'global-boundp-method
45 (make-std-boundp-method-function 'slot-object slot-name
)
46 "automatically-generated boundp method")))
47 (let ((gf (ensure-generic-function fun-name
:lambda-list lambda-list
)))
48 (add-method gf
(make-a-method method-class
49 () lambda-list specializers
50 initargs doc
:slot-name slot-name
)))))
52 ;; KLUDGE: this is maybe PCL bootstrap mechanism #6 or #7, invented
53 ;; by CSR in June 2007. Making the bootstrap sane is getting higher
54 ;; on the "TODO: URGENT" list.
55 (defun !fix-ensure-accessor-specializers
()
56 (setf reader-specializers
(mapcar #'find-class reader-specializers
))
57 (setf writer-specializers
(mapcar #'find-class writer-specializers
))))
59 (defmacro quiet-funcall
(fun &rest args
)
60 ;; Don't give a style-warning about undefined function here.
61 `(funcall (locally (declare (muffle-conditions style-warning
))
65 (defmacro accessor-slot-value
(object slot-name
&environment env
)
66 (aver (constantp slot-name env
))
67 (let* ((slot-name (constant-form-value slot-name env
))
68 (reader-name (slot-reader-name slot-name
)))
69 `(let ((.ignore.
(load-time-value
70 (ensure-accessor 'reader
',reader-name
',slot-name
))))
71 (declare (ignore .ignore.
))
72 (truly-the (values t
&optional
)
73 (quiet-funcall #',reader-name
,object
)))))
75 (defmacro accessor-set-slot-value
(object slot-name new-value
&environment env
)
76 (aver (constantp slot-name env
))
77 (setq object
(%macroexpand object env
))
78 (let* ((slot-name (constant-form-value slot-name env
))
79 (bind-object (unless (or (constantp new-value env
) (atom new-value
))
80 (let* ((object-var (gensym))
81 (bind `((,object-var
,object
))))
82 (setf object object-var
)
84 (writer-name (slot-writer-name slot-name
))
88 (ensure-accessor 'writer
',writer-name
',slot-name
)))
89 (.new-value.
,new-value
))
90 (declare (ignore .ignore.
))
91 (quiet-funcall #',writer-name .new-value.
,object
)
94 `(let ,bind-object
,form
)
97 (defmacro accessor-slot-boundp
(object slot-name
&environment env
)
98 (aver (constantp slot-name env
))
99 (let* ((slot-name (constant-form-value slot-name env
))
100 (boundp-name (slot-boundp-name slot-name
)))
101 `(let ((.ignore.
(load-time-value
102 (ensure-accessor 'boundp
',boundp-name
',slot-name
))))
103 (declare (ignore .ignore.
))
104 (funcall #',boundp-name
,object
))))
106 (defun make-structure-slot-boundp-function (slotd)
107 (declare (ignore slotd
))
108 (named-lambda always-bound
(object)
109 (declare (ignore object
))
112 (define-condition instance-structure-protocol-error
113 (reference-condition error
)
114 ((slotd :initarg
:slotd
:reader instance-structure-protocol-error-slotd
)
115 (fun :initarg
:fun
:reader instance-structure-protocol-error-fun
))
118 (format s
"~@<The slot ~S has neither ~S nor ~S ~
119 allocation, so it can't be ~A by the default ~
121 (instance-structure-protocol-error-slotd c
)
124 ((member (instance-structure-protocol-error-fun c
)
125 '(slot-value-using-class slot-boundp-using-class
))
128 (instance-structure-protocol-error-fun c
)))))
130 (defun instance-structure-protocol-error (slotd fun
)
131 (error 'instance-structure-protocol-error
132 :slotd slotd
:fun fun
133 :references
(list `(:amop
:generic-function
,fun
)
134 '(:amop
:section
(5 5 3)))))
136 (defun get-optimized-std-accessor-method-function (class slotd name
)
138 ((structure-class-p class
)
140 (reader (slot-definition-internal-reader-function slotd
))
141 (writer (slot-definition-internal-writer-function slotd
))
142 (boundp (make-structure-slot-boundp-function slotd
))))
143 ((condition-class-p class
)
144 (let ((info (the slot-info
(slot-definition-info slotd
))))
146 (reader (slot-info-reader info
))
147 (writer (slot-info-writer info
))
148 (boundp (slot-info-boundp info
)))))
150 (let* ((fsc-p (cond ((standard-class-p class
) nil
)
151 ((funcallable-standard-class-p class
) t
)
153 ;; Shouldn't be using the optimized-std-accessors
155 #+nil
(format t
"* warning: ~S ~S~% ~S~%"
158 (t (error "~S is not a STANDARD-CLASS." class
))))
159 (slot-name (slot-definition-name slotd
))
160 (location (slot-definition-location slotd
))
161 (function (ecase name
162 (reader #'make-optimized-std-reader-method-function
)
163 (writer #'make-optimized-std-writer-method-function
)
164 (boundp #'make-optimized-std-boundp-method-function
)))
165 ;; KLUDGE: we need this slightly hacky calling convention
166 ;; for these functions for bootstrapping reasons: see
167 ;; !BOOTSTRAP-MAKE-SLOT-DEFINITION in braid.lisp. -- CSR,
169 (value (funcall function fsc-p slotd slot-name location
)))
170 (declare (type function function
))
171 (values value
(slot-definition-location slotd
))))))
173 (defun make-optimized-std-reader-method-function
174 (fsc-p slotd slot-name location
)
180 (check-obsolete-instance instance
)
181 (let ((value (clos-slots-ref (fsc-instance-slots instance
)
183 (if (eq value
+slot-unbound
+)
185 (slot-unbound (class-of instance
) instance slot-name
))
188 (check-obsolete-instance instance
)
189 (let ((value (clos-slots-ref (std-instance-slots instance
)
191 (if (eq value
+slot-unbound
+)
193 (slot-unbound (class-of instance
) instance slot-name
))
197 (check-obsolete-instance instance
)
198 (let ((value (cdr location
)))
199 (if (eq value
+slot-unbound
+)
200 (values (slot-unbound (class-of instance
) instance slot-name
))
204 (declare (ignore instance
))
205 (instance-structure-protocol-error slotd
'slot-value-using-class
))))
206 `(reader ,slot-name
)))
208 (defun make-optimized-std-writer-method-function (fsc-p slotd slot-name location
)
209 ;; The (WHEN SLOTD ...) gunk is for building early slot definitions.
210 (let* ((class (when slotd
(slot-definition-class slotd
)))
211 (safe-p (when slotd
(safe-p class
)))
212 (orig-wrapper (when safe-p
(class-wrapper class
)))
213 (info (when safe-p
(slot-definition-info slotd
)))
214 (writer-fun (etypecase location
215 ;; In SAFE-P case the typechecking already validated the instance.
219 (lambda (nv instance
)
220 (setf (clos-slots-ref (fsc-instance-slots instance
)
223 (lambda (nv instance
)
224 (check-obsolete-instance instance
)
225 (setf (clos-slots-ref (fsc-instance-slots instance
)
229 (lambda (nv instance
)
230 (setf (clos-slots-ref (std-instance-slots instance
)
233 (lambda (nv instance
)
234 (check-obsolete-instance instance
)
235 (setf (clos-slots-ref (std-instance-slots instance
)
240 (lambda (nv instance
)
241 (declare (ignore instance
))
242 (setf (cdr location
) nv
))
243 (lambda (nv instance
)
244 (check-obsolete-instance instance
)
245 (setf (cdr location
) nv
))))
247 (lambda (nv instance
)
248 (declare (ignore nv instance
))
249 (instance-structure-protocol-error
251 '(setf slot-value-using-class
))))))
252 (checking-fun (when safe-p
253 (lambda (new-value instance
)
254 ;; If we have a TYPE-CHECK-FUNCTION, call it.
255 (let* (;; Note that the class of INSTANCE here is not
256 ;; neccessarily the SLOT-DEFINITION-CLASS of
257 ;; the SLOTD passed to M-O-S-W-M-F, since it's
258 ;; e.g. possible for a subclass to define a
259 ;; slot of the same name but with no
260 ;; accessors. So we may need to fetch the
261 ;; right SLOT-INFO from the wrapper instead of
262 ;; just closing over it.
263 (wrapper (valid-wrapper-of instance
))
266 (if (eq wrapper orig-wrapper
)
268 (cdr (find-slot-cell wrapper slot-name
))))))
270 (funcall typecheck new-value
)))
271 ;; Then call the real writer.
272 (funcall writer-fun new-value instance
)))))
273 (set-fun-name (if safe-p
276 `(writer ,slot-name
))))
278 (defun make-optimized-std-boundp-method-function
279 (fsc-p slotd slot-name location
)
284 (check-obsolete-instance instance
)
285 (not (eq (clos-slots-ref (fsc-instance-slots instance
)
289 (check-obsolete-instance instance
)
290 (not (eq (clos-slots-ref (std-instance-slots instance
)
293 (cons (lambda (instance)
294 (check-obsolete-instance instance
)
295 (not (eq (cdr location
) +slot-unbound
+))))
298 (declare (ignore instance
))
299 (instance-structure-protocol-error slotd
'slot-boundp-using-class
))))
300 `(boundp ,slot-name
)))
302 (defun make-optimized-structure-slot-value-using-class-method-function
304 (declare (type function function
))
305 (lambda (class object slotd
)
306 (declare (ignore class slotd
))
307 (funcall function object
)))
309 (defun make-optimized-structure-setf-slot-value-using-class-method-function
311 (declare (type function function
))
312 (lambda (nv class object slotd
)
313 (declare (ignore class slotd
))
314 (funcall function nv object
)))
316 (defun make-optimized-structure-slot-boundp-using-class-method-function ()
317 (lambda (class object slotd
)
318 (declare (ignore class object slotd
))
321 (defun get-optimized-std-slot-value-using-class-method-function
324 ((structure-class-p class
)
326 (reader (make-optimized-structure-slot-value-using-class-method-function
327 (slot-definition-internal-reader-function slotd
)))
328 (writer (make-optimized-structure-setf-slot-value-using-class-method-function
329 (slot-definition-internal-writer-function slotd
)))
330 (boundp (make-optimized-structure-slot-boundp-using-class-method-function))))
331 ((condition-class-p class
)
332 (let ((info (slot-definition-info slotd
)))
335 (let ((fun (slot-info-reader info
)))
336 (lambda (class object slotd
)
337 (declare (ignore class slotd
))
338 (funcall fun object
))))
340 (let ((fun (slot-info-writer info
)))
341 (lambda (new-value class object slotd
)
342 (declare (ignore class slotd
))
343 (funcall fun new-value object
))))
345 (let ((fun (slot-info-boundp info
)))
346 (lambda (class object slotd
)
347 (declare (ignore class slotd
))
348 (funcall fun object
)))))))
350 (let* ((fsc-p (cond ((standard-class-p class
) nil
)
351 ((funcallable-standard-class-p class
) t
)
352 (t (error "~S is not a standard-class" class
))))
356 #'make-optimized-std-slot-value-using-class-method-function
)
358 #'make-optimized-std-setf-slot-value-using-class-method-function
)
360 #'make-optimized-std-slot-boundp-using-class-method-function
))))
361 (declare (type function function
))
362 (values (funcall function fsc-p slotd
)
363 (slot-definition-location slotd
))))))
365 (defun make-optimized-std-slot-value-using-class-method-function (fsc-p slotd
)
366 (let ((location (slot-definition-location slotd
))
367 (slot-name (slot-definition-name slotd
)))
370 (lambda (class instance slotd
)
371 (declare (ignore slotd
))
372 (check-obsolete-instance instance
)
373 (let ((value (clos-slots-ref (fsc-instance-slots instance
)
375 (if (eq value
+slot-unbound
+)
376 (values (slot-unbound class instance slot-name
))
378 (lambda (class instance slotd
)
379 (declare (ignore slotd
))
380 (check-obsolete-instance instance
)
381 (let ((value (clos-slots-ref (std-instance-slots instance
)
383 (if (eq value
+slot-unbound
+)
384 (values (slot-unbound class instance slot-name
))
386 (cons (lambda (class instance slotd
)
387 (declare (ignore slotd
))
388 (check-obsolete-instance instance
)
389 (let ((value (cdr location
)))
390 (if (eq value
+slot-unbound
+)
391 (values (slot-unbound class instance slot-name
))
394 (lambda (class instance slotd
)
395 (declare (ignore class instance
))
396 (instance-structure-protocol-error slotd
'slot-value-using-class
))))))
398 (defun make-optimized-std-setf-slot-value-using-class-method-function
400 (let* ((location (slot-definition-location slotd
))
401 (class (slot-definition-class slotd
))
404 (slot-info-typecheck (slot-definition-info slotd
)))))
405 (macrolet ((make-mf-lambda (&body body
)
406 `(lambda (nv class instance slotd
)
407 (declare (ignore class slotd
))
408 (check-obsolete-instance instance
)
410 (make-mf-lambdas (&body body
)
411 ;; Having separate lambdas for the NULL / not-NULL cases of
412 ;; TYPE-CHECK-FUNCTION is done to avoid runtime overhead
413 ;; for CLOS typechecking when it's not in use.
416 (funcall (the function typecheck
) nv
)
424 (setf (clos-slots-ref (fsc-instance-slots instance
) location
)
427 (setf (clos-slots-ref (std-instance-slots instance
) location
)
430 (make-mf-lambdas (setf (cdr location
) nv
)))
431 (null (lambda (nv class instance slotd
)
432 (declare (ignore nv class instance
))
433 (instance-structure-protocol-error
434 slotd
'(setf slot-value-using-class
))))))))
436 (defun make-optimized-std-slot-boundp-using-class-method-function
438 (let ((location (slot-definition-location slotd
)))
442 (lambda (class instance slotd
)
443 (declare (ignore class slotd
))
444 (check-obsolete-instance instance
)
445 (not (eq (clos-slots-ref (fsc-instance-slots instance
) location
)
447 (lambda (class instance slotd
)
448 (declare (ignore class slotd
))
449 (check-obsolete-instance instance
)
450 (not (eq (clos-slots-ref (std-instance-slots instance
) location
)
452 (cons (lambda (class instance slotd
)
453 (declare (ignore class slotd
))
454 (check-obsolete-instance instance
)
455 (not (eq (cdr location
) +slot-unbound
+))))
457 (lambda (class instance slotd
)
458 (declare (ignore class instance
))
459 (instance-structure-protocol-error slotd
460 'slot-boundp-using-class
))))))
462 (defun get-accessor-from-svuc-method-function (class slotd sdfun name
)
463 (macrolet ((emf-funcall (emf &rest args
)
464 `(invoke-effective-method-function ,emf nil
465 :required-args
,args
)))
468 (reader (lambda (instance)
469 (emf-funcall sdfun class instance slotd
)))
470 (writer (lambda (nv instance
)
471 (emf-funcall sdfun nv class instance slotd
)))
472 (boundp (lambda (instance)
473 (emf-funcall sdfun class instance slotd
))))
474 `(,name
,(class-name class
) ,(slot-definition-name slotd
)))))
476 (defun maybe-class (class-or-name)
477 (when (eq **boot-state
** 'complete
)
478 (if (typep class-or-name
'class
)
480 (find-class class-or-name nil
))))
482 (defun make-std-reader-method-function (class-or-name slot-name
)
483 (ecase (slot-access-strategy (maybe-class class-or-name
) slot-name
'reader t
)
485 (let* ((initargs (copy-tree
486 (make-method-function
488 (pv-binding1 ((bug "Please report this")
489 (instance) (instance-slots))
490 (instance-read-standard
491 .pv. instance-slots
0
492 (slot-value instance slot-name
))))))))
493 (setf (getf (getf initargs
'plist
) :slot-name-lists
)
494 (list (list nil slot-name
)))
497 (let* ((initargs (copy-tree
498 (make-method-function
500 (pv-binding1 ((bug "Please report this")
502 (instance-read-custom .pv.
0 instance
)))))))
503 (setf (getf (getf initargs
'plist
) :slot-name-lists
)
504 (list (list nil slot-name
)))
507 (defun make-std-writer-method-function (class-or-name slot-name
)
508 (let ((class (maybe-class class-or-name
)))
509 (ecase (slot-access-strategy class slot-name
'writer t
)
511 (let ((initargs (copy-tree
512 (if (and class
(safe-p class
))
513 (make-method-function
514 (lambda (nv instance
)
515 (pv-binding1 ((bug "Please report this")
516 (instance) (instance-slots))
517 (instance-write-standard
518 .pv. instance-slots
0 nv
519 (setf (slot-value instance slot-name
) .good-new-value.
)
521 (make-method-function
522 (lambda (nv instance
)
523 (pv-binding1 ((bug "Please report this")
524 (instance) (instance-slots))
525 (instance-write-standard
526 .pv. instance-slots
0 nv
527 (setf (slot-value instance slot-name
) .good-new-value.
)))))))))
528 (setf (getf (getf initargs
'plist
) :slot-name-lists
)
529 (list nil
(list nil slot-name
)))
532 (let ((initargs (copy-tree
533 (make-method-function
534 (lambda (nv instance
)
535 (pv-binding1 ((bug "Please report this")
537 (instance-write-custom .pv.
0 instance nv
)))))))
538 (setf (getf (getf initargs
'plist
) :slot-name-lists
)
539 (list nil
(list nil slot-name
)))
542 (defun make-std-boundp-method-function (class-or-name slot-name
)
543 (ecase (slot-access-strategy (maybe-class class-or-name
) slot-name
'boundp t
)
545 (let ((initargs (copy-tree
546 (make-method-function
548 (pv-binding1 ((bug "Please report this")
549 (instance) (instance-slots))
550 (instance-boundp-standard
551 .pv. instance-slots
0
552 (slot-boundp instance slot-name
))))))))
553 (setf (getf (getf initargs
'plist
) :slot-name-lists
)
554 (list (list nil slot-name
)))
557 (let ((initargs (copy-tree
558 (make-method-function
560 (pv-binding1 ((bug "Please report this")
562 (instance-boundp-custom .pv.
0 instance
)))))))
563 (setf (getf (getf initargs
'plist
) :slot-name-lists
)
564 (list (list nil slot-name
)))
567 ;;;; FINDING SLOT DEFINITIONS
569 ;;; Historical PCL found slot definitions by iterating over
570 ;;; CLASS-SLOTS, which is O(N) for number of slots, and moreover
571 ;;; requires a GF call (for SLOT-DEFINITION-NAME) for each slot in
572 ;;; list up to the desired one.
574 ;;; Current SBCL hashes the effective slot definitions, and some
575 ;;; information pulled out from them into a simple-vector, with bucket
576 ;;; chains made out of plists keyed by the slot names. This fixes
577 ;;; gives O(1) performance, and avoid the GF calls.
579 ;;; MAKE-SLOT-TABLE constructs the hashed vector out of a list of
580 ;;; effective slot definitions and the class they pertain to, and
581 ;;; FIND-SLOT-DEFINITION knows how to look up slots in that vector.
583 ;;; The only bit of cleverness in the implementation is to make the
584 ;;; vectors fairly tight, but always longer then 0 elements:
586 ;;; -- We don't want to waste huge amounts of space no these vectors,
587 ;;; which are mostly required by things like SLOT-VALUE with a
588 ;;; variable slot name, so a constant extension over the minimum
589 ;;; size seems like a good choise.
591 ;;; -- As long as the vector always has a length > 0
592 ;;; FIND-SLOT-DEFINITION doesn't need to handle the rare case of an
593 ;;; empty vector separately: it just returns a NIL.
595 ;;; In addition to the slot-definition we also store the slot-location
596 ;;; and type-check function for instances of standard metaclasses, so
597 ;;; that SLOT-VALUE &co using variable slot names can get at them
598 ;;; without additional GF calls.
601 ;;; It would also be nice to have STANDARD-INSTANCE-STRUCTURE-P
602 ;;; generic instead of checking versus STANDARD-CLASS and
603 ;;; FUNCALLABLE-STANDARD-CLASS.
605 ;;; Uh, the comments above talking about how FIND-SLOT-DEFINITION
606 ;;; does something with slot vectors has no basis in reality.
607 ;;; Probably the comments need fixing, rather than the code.
609 (defun find-slot-definition (class slot-name
&optional errorp
)
610 (unless (class-finalized-p class
)
611 (or (try-finalize-inheritance class
)
613 (error "Cannot look up slot-definition for ~S in ~S (too early to finalize.)"
615 (return-from find-slot-definition
(values nil nil
)))))
616 (dolist (slotd (class-slots class
)
618 (error "No slot called ~S in ~S." slot-name class
)
620 (when (eq slot-name
(slot-definition-name slotd
))
621 (return (values slotd t
)))))
623 (defun find-slot-cell (wrapper slot-name
)
624 (declare (symbol slot-name
))
625 (declare (optimize (sb-c::insert-array-bounds-checks
0)))
626 (let* ((vector (layout-slot-table wrapper
))
627 (modulus (truly-the index
(svref vector
0)))
628 ;; Can elide the 'else' branch of (OR symbol-hash ensure-symbol-hash)
629 ;; because every symbol in the slot-table already got a nonzero hash.
630 (index (rem (symbol-hash slot-name
) modulus
))
631 (probe (svref vector
(1+ index
))))
632 (declare (simple-vector vector
) (index index
))
633 (cond ((fixnump probe
)
634 (do* ((count (svref vector
(1- (truly-the index probe
))))
635 (end (truly-the index
(+ probe count
)))
638 (declare (index count j
))
639 (when (eq (svref vector j
) slot-name
)
640 (return (svref vector
(truly-the index
(+ j count
)))))))
641 ((eq (car (truly-the list probe
)) slot-name
)
644 (defun make-slot-table (class slots
&optional bootstrap
)
646 (return-from make-slot-table
#(1 nil
)))
647 (let* ((n (+ (logior (length slots
) 1) 2)) ; an odd divisor is preferred
648 (vector (make-array n
:initial-element nil
)))
649 (flet ((add-to-vector (name slot
)
650 (declare (symbol name
)
651 (optimize (sb-c::insert-array-bounds-checks
0)))
652 (let ((index (rem (ensure-symbol-hash name
) n
)))
653 (setf (svref vector index
)
655 (cons (when (or bootstrap
656 (and (standard-class-p class
)
657 (slot-accessor-std-p slot
'all
)))
659 (early-slot-definition-location slot
)
660 (slot-definition-location slot
)))
663 (early-slot-definition-info slot
)
664 (slot-definition-info slot
))))
665 (svref vector index
))))))
666 (if (eq 'complete
**boot-state
**)
668 (add-to-vector (slot-definition-name slot
) slot
))
670 (add-to-vector (early-slot-definition-name slot
) slot
))))
671 ;; The VECTOR as computed above implements a hash table with chaining.
672 ;; Rather than store chains using cons cells, chains can be stored in the
673 ;; vector itself at the end, with the table entry pointing to another
674 ;; index in the vector. The chain length is stored first, then all keys,
675 ;; then all values. The resulting structure takes less memory than
676 ;; linked lists, and can be scanned faster. As an exception, for lists
677 ;; of length 1, the table cell holds a (key . value) pair directly.
680 ;; number of additional cells needed to represent linked lists
681 ;; as length-prefixed subsequences in the final vector.
682 (loop for cell across vector
683 for count
= (length cell
)
684 sum
(if (<= count
1) 0 (1+ (* count
2))))))
685 (final-vector (make-array final-n
))
686 (data-index (1+ n
))) ; after the hashtable portion of the vector
687 (setf (aref final-vector
0) n
) ; the modulus
688 (dotimes (i n final-vector
)
689 (let ((alist (aref vector i
)))
690 (if (not (cdr alist
)) ; store it in the final vector as-is
691 (setf (aref final-vector
(1+ i
)) (car alist
))
692 (let ((count (length alist
)))
693 ;; Probed cell holds the index of the first symbol.
694 ;; The symbol count precedes the first symbol cell.
695 (setf (aref final-vector
(1+ i
)) (1+ data-index
)
696 (aref final-vector data-index
) count
)
698 (setf (aref final-vector
(incf data-index
)) (car cell
)))
700 (setf (aref final-vector
(incf data-index
)) (cdr cell
)))
701 (incf data-index
))))))))