X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcompiler%2Ftypetran.lisp;h=acaac05e57c5651da83ce626d3a8f3f6b18f09b6;hb=a2fcf3abd6d0b90f9de0f016ac5c9c65270294b2;hp=ad9986e129c4e1c9493e24d8a1454bbb909df196;hpb=8ac4c19014a23665e5842d0a989cb9d22d1592ed;p=sbcl.git diff --git a/src/compiler/typetran.lisp b/src/compiler/typetran.lisp index ad9986e..acaac05 100644 --- a/src/compiler/typetran.lisp +++ b/src/compiler/typetran.lisp @@ -72,6 +72,8 @@ nil) ((csubtypep otype type) t) + ((eq type *empty-type*) + nil) (t (give-up-ir1-transform))))) @@ -274,6 +276,11 @@ `(typep ,n-obj ',x)) (rest spec)))))))))) +(defun source-transform-negation-typep (object type) + (declare (type negation-type type)) + (let ((spec (type-specifier (negation-type-type type)))) + `(not (typep ,object ',spec)))) + ;;; Do source transformation for TYPEP of a known union type. If a ;;; union type contains LIST, then we pull that out and make it into a ;;; single LISTP call. Note that if SYMBOL is in the union, then LIST @@ -503,6 +510,8 @@ (typecase type (hairy-type (source-transform-hairy-typep object type)) + (negation-type + (source-transform-negation-typep object type)) (union-type (source-transform-union-typep object type)) (intersection-type @@ -529,7 +538,7 @@ ;;;; coercion -(deftransform coerce ((x type) (* *) *) +(deftransform coerce ((x type) (* *) * :node node) (unless (constant-continuation-p type) (give-up-ir1-transform)) (let ((tspec (ir1-transform-specifier-type (continuation-value type)))) @@ -544,8 +553,12 @@ ;; FIXME: #!+long-float (t ,(error "LONG-FLOAT case needed")) ((csubtypep tspec (specifier-type 'float)) '(%single-float x)) - ((csubtypep tspec (specifier-type 'simple-vector)) - '(coerce-to-simple-vector x)) + ((and (csubtypep tspec (specifier-type 'simple-vector)) + (policy node (< safety 3))) + `(if (simple-vector-p x) + x + (replace (make-array (length x)) x))) + ;; FIXME: other VECTOR types? (t (give-up-ir1-transform)))))))