mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
It could kinda have been done already, but if your form contained dumpable-though-unprintable subparts, it wasn't fun to produce the source file for that. (It needs a reader macro to return the form as-is such as using "#." which works but is ugly) So this adds a convenient interface, not to mention makes it easier to get an IR trace than by binding *COMPILER-TRACE-OUTPUT* by hand.
28 lines
962 B
Common Lisp
28 lines
962 B
Common Lisp
(defvar *foo* 0)
|
|
(defclass mything () ((a :initarg :a :reader a)
|
|
(b :initform (incf *foo*))))
|
|
(defmethod make-load-form ((self mything) &optional e)
|
|
(declare (ignore e))
|
|
(make-load-form-saving-slots self))
|
|
|
|
(with-test (:name :is-unprintable)
|
|
(assert-error (write-to-string (make-instance 'mything :a "a") :readably t)))
|
|
|
|
(defvar *form* `(setf (car *items*)
|
|
,(vector (make-instance 'mything :a "hello")
|
|
(make-instance 'mything :a "world"))))
|
|
(defun thingp (x str)
|
|
(and (typep x 'mything) (string= (a x) str)))
|
|
|
|
(defvar *items* nil)
|
|
|
|
(with-test (:name :compile-form-to-file)
|
|
(with-scratch-file (fasl "fasl")
|
|
(sb-c:compile-form-to-file *form* fasl)
|
|
(setf *items* (list nil))
|
|
(load fasl)
|
|
(let ((first (car *items*)))
|
|
(assert (and (simple-vector-p first)
|
|
(thingp (elt first 0) "hello")
|
|
(thingp (elt first 1) "world"))))))
|