mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-20 11:32:35 -08:00
In cmparray.lsp, some assertions were produced in unsafe mode. We now rely on optional-type-assertion to prevent this.
This commit is contained in:
parent
f32174203b
commit
d4f3cab76f
1 changed files with 6 additions and 20 deletions
|
|
@ -99,8 +99,7 @@
|
|||
(vector ,(second args)))
|
||||
(declare (:read-only value vector)
|
||||
(optimize (safety 0)))
|
||||
,@(unless (policy-assume-right-type)
|
||||
`((check-vectorp vector)))
|
||||
(optional-type-assertion vector vector)
|
||||
(let ((index (fill-pointer vector))
|
||||
(dimension (array-total-size vector)))
|
||||
(declare (fixnum index dimension)
|
||||
|
|
@ -168,16 +167,16 @@
|
|||
|
||||
(defun expand-zero-dim-index-check (a env)
|
||||
(if (policy-type-assertions env)
|
||||
0
|
||||
`(progn
|
||||
(check-arrayp ,a)
|
||||
(optional-type-assertion ,a array)
|
||||
(check-expected-rank ,a 0)
|
||||
0)))
|
||||
0)
|
||||
0))
|
||||
|
||||
(defun expand-vector-index-check (a index env)
|
||||
(flet ((expansion (a index)
|
||||
`(progn
|
||||
(check-vectorp ,a)
|
||||
(optional-type-assertion ,a vector)
|
||||
(check-vector-in-bounds ,a ,index)
|
||||
,index)))
|
||||
(if (policy-type-assertions env)
|
||||
|
|
@ -208,7 +207,7 @@
|
|||
(declare (type ext:array-index %output-var ,@dim-names)
|
||||
(ignorable ,@dim-names))
|
||||
,@(when (policy-type-assertions env)
|
||||
`((check-arrayp ,a)
|
||||
`((optional-type-assertion ,a array)
|
||||
(check-expected-rank ,a ,expected-rank)))
|
||||
,@(loop for i from 0
|
||||
for l in indices
|
||||
|
|
@ -226,19 +225,6 @@
|
|||
|
||||
;(trace c::expand-row-major-index c::expand-aset c::expand-aref)
|
||||
|
||||
(defmacro check-arrayp (a)
|
||||
`(c-inline
|
||||
(,a) (:object) :void
|
||||
"if (ecl_unlikely(!ECL_ARRAYP(#0))) FEtype_error_array(#0);"
|
||||
:one-liner nil))
|
||||
|
||||
(defmacro check-vectorp (v)
|
||||
`(c-inline
|
||||
(,v) (:object) :void
|
||||
"if (ecl_unlikely(!ECL_VECTORP(#0)))
|
||||
FEtype_error_vector(#0);"
|
||||
:one-liner nil))
|
||||
|
||||
(defmacro check-expected-rank (a expected-rank)
|
||||
`(c-inline
|
||||
(,a ,expected-rank) (:object :fixnum) :void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue