X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Farray.lisp;h=a15b4eb69b14369824285fbc449f03a6c2c62d37;hb=18ada11fb234e336a3d2ac4370d384d80d36f9f0;hp=e3e1f2e6b7f348054d8ebd45df76298270bb2e42;hpb=4ddbd517a72846b6b595ee12d1b1167a0199db9d;p=jscl.git diff --git a/src/array.lisp b/src/array.lisp index e3e1f2e..a15b4eb 100644 --- a/src/array.lisp +++ b/src/array.lisp @@ -13,6 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with JSCL. If not, see . +(/debug "loading array.lisp!") + (defun upgraded-array-element-type (typespec &optional environment) (declare (ignore environment)) (if (eq typespec 'character) @@ -25,15 +27,17 @@ (array (make-storage-vector size))) ;; Upgrade type (if (eq element-type 'character) - (setf element-type 'character - initial-element (or initial-element #\space)) + (progn + (oset 1 array "stringp") + (setf element-type 'character + initial-element (or initial-element #\space))) (setf element-type t)) ;; Initialize array (dotimes (i size) (storage-vector-set array i initial-element)) ;; Record and return the object - (oset array "type" element-type) - (oset array "dimensions" dimensions) + (oset element-type array "type") + (oset dimensions array "dimensions") array)) @@ -71,12 +75,25 @@ (error "~S is not an array." array)) (storage-vector-set array index value)) +(define-setf-expander aref (array index) + (let ((g!array (gensym)) + (g!index (gensym)) + (g!value (gensym))) + (values (list g!array g!index) + (list array index) + (list g!value) + `(aset ,g!array ,g!index ,g!value) + `(aref ,g!array ,g!index)))) + ;;; Vectors (defun vectorp (x) (and (arrayp x) (null (cdr (array-dimensions x))))) +(defun vector (&rest objects) + (list-to-vector objects)) + ;;; FIXME: should take optional min-extension. ;;; FIXME: should use fill-pointer instead of the absolute end of array (defun vector-push-extend (new vector)