X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fknownfun.lisp;h=d28f79eef4c6473ffdd18c86559969221d946b41;hb=403bacffd903f8c5787a182f4133cffc69b55dc0;hp=bd35c9381a873c326363105336f1a25fc3437cf3;hpb=2768ed83de59354b21ea61de3dea358c53d1ae05;p=sbcl.git diff --git a/src/compiler/knownfun.lisp b/src/compiler/knownfun.lisp index bd35c93..d28f79e 100644 --- a/src/compiler/knownfun.lisp +++ b/src/compiler/knownfun.lisp @@ -262,7 +262,7 @@ (when (csubtypep type ltype) ltype)))))))) -;;; Derive the type to be the type specifier which is the N'th arg. +;;; Derive the type to be the type specifier which is the Nth arg. (defun result-type-specifier-nth-arg (n) (lambda (call) (declare (type combination call)) @@ -270,4 +270,29 @@ (when (and cont (constant-continuation-p cont)) (careful-specifier-type (continuation-value cont)))))) +;;; Derive the type to be the type specifier which is the Nth arg, +;;; with the additional restriptions noted in the CLHS for STRING and +;;; SIMPLE-STRING. +(defun creation-result-type-specifier-nth-arg (n) + (lambda (call) + (declare (type combination call)) + (let ((cont (nth (1- n) (combination-args call)))) + (when (and cont (constant-continuation-p cont)) + (let* ((specifier (continuation-value cont)) + (lspecifier (if (atom specifier) (list specifier) specifier))) + (cond + ((eq (car lspecifier) 'string) + (destructuring-bind (string &rest size) + lspecifier + (declare (ignore string)) + (careful-specifier-type + `(vector character ,@(when size size))))) + ((eq (car lspecifier) 'simple-string) + (destructuring-bind (simple-string &rest size) + lspecifier + (declare (ignore simple-string)) + (careful-specifier-type + `(simple-array character ,@(if size (list size) '((*))))))) + (t (careful-specifier-type specifier)))))))) + (/show0 "knownfun.lisp end of file")