From: David Vázquez Date: Fri, 24 May 2013 00:51:38 +0000 (+0100) Subject: Move vector-push-extend to arrays.lisp X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=aae9a4aed84caf8b50536887401ef3df7d97c09a;p=jscl.git Move vector-push-extend to arrays.lisp --- diff --git a/src/arrays.lisp b/src/arrays.lisp index 9211460..a90a4bc 100644 --- a/src/arrays.lisp +++ b/src/arrays.lisp @@ -59,9 +59,6 @@ (defun array-dimension (array axis) (nth axis (array-dimensions array))) -(defun vectorp (x) - (and (arrayp x) (null (cdr (array-dimensions x))))) - (defun aref (array index) (unless (arrayp array) (error "~S is not an array." array)) @@ -73,3 +70,15 @@ (storage-vector-set array index value)) +;;; Vectors + +(defun vectorp (x) + (and (arrayp x) (null (cdr (array-dimensions x))))) + +;;; FIXME: should take optional min-extension. +;;; FIXME: should use fill-pointer instead of the absolute end of array +(defun vector-push-extend (new vector) + (let ((size (storage-vector-size vector))) + (resize-storage-vector vector (1+ size)) + (aset vector size new) + size)) diff --git a/src/compiler.lisp b/src/compiler.lisp index 7fffe42..a41a85e 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -1579,15 +1579,6 @@ "if (i < 0 || i >= x.length) throw 'Out of range';" *newline* "return x[i] = " value ";" *newline*)) - -;;; FIXME: should take optional min-extension. -;;; FIXME: should use fill-pointer instead of the absolute end of array -(define-builtin vector-push-extend (new vector) - (js!selfcall - "var v = " vector ";" *newline* - "v.push(" new ");" *newline* - "return v;")) - (define-builtin afind (value array) (js!selfcall "var v = " value ";" *newline*