0.8.0.42:
authorChristophe Rhodes <csr21@cam.ac.uk>
Sat, 7 Jun 2003 11:01:58 +0000 (11:01 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Sat, 7 Jun 2003 11:01:58 +0000 (11:01 +0000)
Quieten the compiler slightly for (LENGTH <VECTOR>)
... one of the transforms wants to constant-fold the above when
<VECTOR> is a 1d SIMPLE-ARRAY of known dimensions.
However, the deftransform definition (with a simple-array
type requirement) caused the compiler to complain when
the argument was known to be a vector but not a simple-array.
Instead, leave the type requirement for the transform open,
and GIVE-UP-IR1-TRANSFORM (with no arguments => silence)
if the argument isn't simple.
... write some tests for LENGTH on vectors

src/compiler/array-tran.lisp
tests/vector.pure.lisp
version.lisp-expr

index 3384b9f..724440d 100644 (file)
 
 ;;; If a simple array with known dimensions, then VECTOR-LENGTH is a
 ;;; compile-time constant.
-(deftransform vector-length ((vector) ((simple-array * (*))))
+(deftransform vector-length ((vector))
   (let ((vtype (continuation-type vector)))
-    (if (array-type-p vtype)
+    (if (and (array-type-p vtype)
+            (not (array-type-complexp vtype)))
        (let ((dim (first (array-type-dimensions vtype))))
          (when (eq dim '*) (give-up-ir1-transform))
          dim)
index 9f60cca..210f7b6 100644 (file)
                 (simple-u32 (make-array 50
                                         :element-type '(unsigned-byte 32)))
                 (simple-character (make-string 44))
-                (complex-t (make-array 35 :fill-pointer 3))
+                (complex-t (make-array 4 :fill-pointer 3))
                 (complex-u32 (make-array 88
+                                         :adjustable t
                                          :element-type '(unsigned-byte 32)))
                 (complex-character (make-array 14
                                                :element-type 'character
                                                :fill-pointer t)))
-            (assert (= (length simple-t) 35)))))
+            (assert (= (length simple-t) 35))
+            (assert (= (length simple-u32) 50))
+            (assert (= (length simple-character) 44))
+            (assert (= (length complex-t) 3))
+            (assert (= (length complex-u32) 88))
+            (assert (= (length complex-character) 14))
+            (vector-push-extend #\a complex-t)
+            (assert (= (length complex-t) 4))
+            (assert (raises-error? (vector-push-extend #\b simple-t))))))
index 60f15c1..2cffca4 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".)
-"0.8.0.41"
+"0.8.0.42"