+;;; Return a list of keyword args and values to use for MAKE-HASH-TABLE
+;;; when reconstructing HASH-TABLE.
+(defun %hash-table-ctor-args (hash-table)
+ (when (hash-table-weak-p hash-table)
+ ;; FIXME: This might actually work with no trouble, but as of
+ ;; sbcl-0.6.12.10 when this code was written, weak hash tables
+ ;; weren't working yet, so I couldn't test it. When weak hash
+ ;; tables are supported again, this should be fixed.
+ (error "can't dump weak hash tables readably")) ; defensive programming..
+ `(:test ',(hash-table-test hash-table)
+ :size ',(hash-table-size hash-table)
+ :rehash-size ',(hash-table-rehash-size hash-table)
+ :rehash-threshold ',(hash-table-rehash-threshold hash-table)))
+
+;;; Return an association list representing the same data as HASH-TABLE.
+(defun %hash-table-alist (hash-table)
+ (let ((result nil))
+ (maphash (lambda (key value)
+ (push (cons key value) result))
+ hash-table)
+ result))
+
+;;; Stuff an association list into HASH-TABLE. Return the hash table,
+;;; so that we can use this for the *PRINT-READABLY* case in
+;;; PRINT-OBJECT (HASH-TABLE T) without having to worry about LET
+;;; forms and readable gensyms and stuff.
+(defun %stuff-hash-table (hash-table alist)
+ (dolist (x alist)
+ (setf (gethash (car x) hash-table) (cdr x)))
+ hash-table)
+
+(def!method print-object ((hash-table hash-table) stream)