- (if (eq (car fun) 'lambda-with-lexenv)
- (cdr fun)
- `(() () () . ,(cdr fun)))
- (let ((*lexenv* (make-lexenv
- :default (process-decls decls nil nil
- :lexenv (make-null-lexenv))
- :vars (copy-list symbol-macros)
- :funs (mapcar (lambda (x)
- `(,(car x) .
- (macro . ,(coerce (cdr x) 'function))))
- macros)
- :policy (lexenv-policy *lexenv*)))
- (*allow-instrumenting* (and (not system-lambda) *allow-instrumenting*)))
- (ir1-convert-lambda `(lambda ,@body)
- :source-name source-name
- :debug-name debug-name))))
+ (if (eq (car fun) 'lambda-with-lexenv)
+ (cdr fun)
+ `(() () () . ,(cdr fun)))
+ (let* ((*lexenv* (make-lexenv
+ :default (process-decls decls nil nil
+ :lexenv (make-null-lexenv))
+ :vars (copy-list symbol-macros)
+ :funs (mapcar (lambda (x)
+ `(,(car x) .
+ (macro . ,(coerce (cdr x) 'function))))
+ macros)
+ ;; Inherit MUFFLE-CONDITIONS from the call-site lexenv
+ ;; rather than the definition-site lexenv, since it seems
+ ;; like a much more common case.
+ :handled-conditions (lexenv-handled-conditions *lexenv*)
+ :policy (lexenv-policy *lexenv*)))
+ (clambda (ir1-convert-lambda `(lambda ,@body)
+ :source-name source-name
+ :debug-name debug-name
+ :system-lambda system-lambda)))
+ (setf (functional-inline-expanded clambda) t)
+ clambda)))
+
+;;; Given a lambda-list, return a FUN-TYPE object representing the signature:
+;;; return type is *, and each individual arguments type is T -- but we get
+;;; the argument counts and keywords.
+(defun ftype-from-lambda-list (lambda-list)
+ (multiple-value-bind (req opt restp rest-name keyp key-list allowp morep)
+ (parse-lambda-list lambda-list)
+ (declare (ignore rest-name))
+ (flet ((t (list)
+ (mapcar (constantly t) list)))
+ (let ((reqs (t req))
+ (opts (when opt (cons '&optional (t opt))))
+ ;; When it comes to building a type, &REST means pretty much the
+ ;; same thing as &MORE.
+ (rest (when (or morep restp) (list '&rest t)))
+ (keys (when keyp
+ (cons '&key (mapcar (lambda (spec)
+ (let ((key/var (if (consp spec)
+ (car spec)
+ spec)))
+ (list (if (consp key/var)
+ (car key/var)
+ (keywordicate key/var))
+ t)))
+ key-list))))
+ (allow (when allowp (list '&allow-other-keys))))
+ (specifier-type `(function (,@reqs ,@opts ,@rest ,@keys ,@allow) *))))))