1.0.17.19: fix interpreted structure constructors (regression since 1.0.17.4)
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 2 Jun 2008 15:19:15 +0000 (15:19 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 2 Jun 2008 15:19:15 +0000 (15:19 +0000)
 * Add full definition for %MAKE-STRUCTURE-INSTANCE.

 * Test-case.

src/code/target-defstruct.lisp
tests/full-eval.impure.lisp
version.lisp-expr

index 7db7029..a719bdf 100644 (file)
 (defun %instance-set (instance index new-value)
   (setf (%instance-ref instance index) new-value))
 
+;;; Normally IR2 converted, definition needed for interpreted structure
+;;; constructors only.
+#!+sb-eval
+(defun %make-structure-instance (dd slot-specs &rest slot-values)
+  (let ((instance (%make-instance (dd-instance-length dd))))
+    (setf (%instance-layout instance) (dd-layout-or-lose dd))
+    (mapc (lambda (spec value)
+            (destructuring-bind (raw-type . index) (cdr spec)
+              (macrolet ((make-case ()
+                           `(ecase raw-type
+                              ((t)
+                               (setf (%instance-ref instance index) value))
+                              ,@(mapcar
+                                 (lambda (rsd)
+                                   `(,(raw-slot-data-raw-type rsd)
+                                      (setf (,(raw-slot-data-accessor-name rsd)
+                                              instance index)
+                                            value)))
+                                 *raw-slot-data-list*))))
+                (make-case))))
+          slot-specs slot-values)
+    instance))
+
 #!-hppa
 (progn
   (defun %raw-instance-ref/word (instance index)
index a35528c..98f345f 100644 (file)
       (funcall fun)
       (assert (gethash '(when t nil) seen-forms)))))
 
+;;; defstruct constructor
+(let ((sb-ext:*evaluator-mode* :interpret))
+  (eval '(progn
+          (defstruct evaluated-struct
+            (pointer nil)
+            (word 0 :type (unsigned-byte #.sb-vm:n-word-bytes))
+            (single 0.0 :type single-float)
+            (double 0.0d0 :type double-float)
+            (csingle (complex 0.0 0.0) :type (complex single-float))
+            (cdouble (complex 0.0d0 0.0d0) :type (complex double-float)))
+          (defvar *evaluated-struct* (make-evaluated-struct
+                                      :pointer :foo
+                                      :word 42
+                                      :single 1.23
+                                      :double 2.34d0
+                                      :csingle (complex 1.0 2.0)
+                                      :cdouble (complex 2.0d0 3.0d0)))
+          (assert (eq :foo (evaluated-struct-pointer *evaluated-struct*)))
+          (assert (eql 42 (evaluated-struct-word *evaluated-struct*)))
+          (assert (eql 1.23 (evaluated-struct-single *evaluated-struct*)))
+          (assert (eql 2.34d0 (evaluated-struct-double *evaluated-struct*)))
+          (assert (eql #c(1.0 2.0) (evaluated-struct-csingle *evaluated-struct*)))
+          (assert (eql #c(2.0d0 3.0d0) (evaluated-struct-cdouble *evaluated-struct*))))))
+
index b6f8141..ad35188 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.17.18"
+"1.0.17.19"