0.7.6.10:
[sbcl.git] / src / compiler / seqtran.lisp
index d2de8d2..e7c0da3 100644 (file)
                    (subtypep result-type-value 'vector)
                    `(coerce (apply #'%map-to-simple-vector-arity-1 fun seqs)
                             ',result-type-value))
-                  (t (give-up-ir1-transform
-                      "internal error: unexpected sequence type"))))
+                  (t (bug "impossible (?) sequence type"))))
            (t
             (let* ((seq-args (make-gensym-list (length seqs)))
                    (index-bindingoids
                      (declare (ignorable dacc))
                      ,push-dacc))))))))))
 \f
-(deftransform elt ((s i) ((simple-array * (*)) *) * :when :both)
+(deftransform elt ((s i) ((simple-array * (*)) *) *)
   '(aref s i))
 
-(deftransform elt ((s i) (list *) * :when :both)
+(deftransform elt ((s i) (list *) *)
   '(nth i s))
 
-(deftransform %setelt ((s i v) ((simple-array * (*)) * *) * :when :both)
+(deftransform %setelt ((s i v) ((simple-array * (*)) * *) *)
   '(%aset s i v))
 
 (deftransform %setelt ((s i v) (list * *))
 
 (macrolet ((def (name)
              `(deftransform ,name ((e l &key (test #'eql)) * *
-                                  :node node :when :both)
+                                  :node node)
                 (unless (constant-continuation-p l)
                   (give-up-ir1-transform))
 
                    :policy (> speed space))
   "open code"
   (let ((element-type (upgraded-element-type-specifier-or-give-up seq)))
-    `(with-array-data ((data seq)
-                      (start start)
-                      (end end))
+    (values 
+     `(with-array-data ((data seq)
+                       (start start)
+                       (end end))
        (declare (type (simple-array ,element-type 1) data))
+       (declare (type fixnum start end))
        (do ((i start (1+ i)))
           ((= i end) seq)
         (declare (type index i))
         ;; WITH-ARRAY-DATA did our range checks once and for all, so
-        ;; it'd be wasteful to check again on every AREF.
+        ;; it'd be wasteful to check again on every AREF...
         (declare (optimize (safety 0))) 
-        (setf (aref data i) item)))))
+        (setf (aref data i) item)))
+     ;; ... though we still need to check that the new element can fit
+     ;; into the vector in safe code. -- CSR, 2002-07-05
+     `((declare (type ,element-type item))))))
 \f
 ;;;; utilities
 
   ;; A form that returns the current value. This may be set with SETF to set
   ;; the current value.
   (current (error "Must specify CURRENT."))
-  ;; In a :Normal iterator, a form that tests whether there is a current value.
+  ;; In a :NORMAL iterator, a form that tests whether there is a current value.
   (done nil)
-  ;; In a :Result iterator, a form that truncates the result at the current
+  ;; In a :RESULT iterator, a form that truncates the result at the current
   ;; position and returns it.
   (result nil)
   ;; A form that returns the initial total number of values. The result is
 ;;;; calls when all arguments are vectors with the same element type,
 ;;;; rather than restricting them to STRINGs only.
 
+;;; Moved here from generic/vm-tran.lisp to satisfy clisp
+;;;
+;;; FIXME: It would be good to implement SB!XC:DEFCONSTANT, and use
+;;; use that here, so that the compiler is born knowing this value.
+;;; FIXME: Add a comment telling whether this holds for all vectors
+;;; or only for vectors based on simple arrays (non-adjustable, etc.).
+(def!constant vector-data-bit-offset
+  (* sb!vm:vector-data-offset sb!vm:n-word-bits))
+
 ;;; FIXME: Shouldn't we be testing for legality of
 ;;;   * START1, START2, END1, and END2 indices?
 ;;;   * size of copied string relative to destination string?
 ;;; %CONCATENATE (with a DEFTRANSFORM to translate constant RTYPE to
 ;;; CTYPE before calling %CONCATENATE) which is comparably efficient,
 ;;; at least once DYNAMIC-EXTENT works.
+#+nil ; FIXME: currently commented out because of bug 188
 (deftransform concatenate ((rtype &rest sequences)
                           (t &rest simple-string)
                           simple-string)
            (all-lengths)
            (args))
     (dolist (seq sequences)
-      (declare (ignore seq))
+      (declare (ignorable seq))
       (let ((n-seq (gensym))
            (n-length (gensym)))
        (args n-seq)