X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fir1tran-lambda.lisp;h=4ae5cae617cebf9411dc85f9eb5b93c9372219dd;hb=95009657265e2af674bdfa9ce7dc75d819976e5b;hp=3374debfbf51503f41e0e48acdb2effdd13db4b0;hpb=709547dfb0905983f23bf131c43affe7788a7e9f;p=sbcl.git diff --git a/src/compiler/ir1tran-lambda.lisp b/src/compiler/ir1tran-lambda.lisp index 3374deb..4ae5cae 100644 --- a/src/compiler/ir1tran-lambda.lisp +++ b/src/compiler/ir1tran-lambda.lisp @@ -544,8 +544,7 @@ (arg-vars context-temp count-temp) (when rest - (arg-vals `(%listify-rest-args - ,n-context ,n-count))) + (arg-vals `(%listify-rest-args ,n-context ,n-count))) (when morep (arg-vals n-context) (arg-vals n-count)) @@ -561,6 +560,7 @@ (n-key (gensym "N-KEY-")) (n-value-temp (gensym "N-VALUE-TEMP-")) (n-allowp (gensym "N-ALLOWP-")) + (n-lose (gensym "N-LOSE-")) (n-losep (gensym "N-LOSEP-")) (allowp (or (optional-dispatch-allowp res) (policy *lexenv* (zerop safety)))) @@ -603,12 +603,13 @@ (tests clause))) (unless allowp - (temps n-allowp n-losep) + (temps n-allowp n-lose n-losep) (unless found-allow-p (tests `((eq ,n-key :allow-other-keys) (setq ,n-allowp ,n-value-temp)))) (tests `(t - (setq ,n-losep (list ,n-key))))) + (setq ,n-lose ,n-key + ,n-losep t)))) (body `(when (oddp ,n-count) @@ -637,7 +638,7 @@ (unless allowp (body `(when (and ,n-losep (not ,n-allowp)) - (%unknown-key-arg-error (car ,n-losep)))))))) + (%unknown-key-arg-error ,n-lose))))))) (let ((ep (ir1-convert-lambda-body `((let ,(temps) @@ -683,7 +684,23 @@ (bind-vals)) (when rest (main-vars rest) - (main-vals '())) + (main-vals '()) + (unless (lambda-var-ignorep rest) + ;; Make up two extra variables, and squirrel them away in + ;; ARG-INFO-DEFAULT for transforming (VALUES-LIST REST) into + ;; (%MORE-ARG-VALUES CONTEXT 0 COUNT) when possible. + (let* ((context-name (gensym "REST-CONTEXT")) + (context (make-lambda-var :%source-name context-name + :arg-info (make-arg-info :kind :more-context))) + (count-name (gensym "REST-COUNT")) + (count (make-lambda-var :%source-name count-name + :arg-info (make-arg-info :kind :more-count) + :type (specifier-type 'index)))) + (setf (arg-info-default (lambda-var-arg-info rest)) (list context count) + (lambda-var-ever-used context) t + (lambda-var-ever-used count) t) + (setf more-context context + more-count count)))) (when more-context (main-vars more-context) (main-vals nil) @@ -1210,34 +1227,39 @@ (substitute-leaf fun var)) fun)) +(defun %set-inline-expansion (name defined-fun inline-lambda) + (cond (inline-lambda + (setf (info :function :inline-expansion-designator name) + inline-lambda) + (when defined-fun + (setf (defined-fun-inline-expansion defined-fun) + inline-lambda))) + (t + (clear-info :function :inline-expansion-designator name)))) + ;;; the even-at-compile-time part of DEFUN ;;; -;;; The INLINE-EXPANSION is a LAMBDA-WITH-LEXENV, or NIL if there is -;;; no inline expansion. -(defun %compiler-defun (name lambda-with-lexenv compile-toplevel) +;;; The INLINE-LAMBDA is a LAMBDA-WITH-LEXENV, or NIL if there is no +;;; inline expansion. +(defun %compiler-defun (name inline-lambda compile-toplevel) (let ((defined-fun nil)) ; will be set below if we're in the compiler (when compile-toplevel - (setf defined-fun (if lambda-with-lexenv - (get-defined-fun name (fifth lambda-with-lexenv)) - (get-defined-fun name))) + (with-single-package-locked-error + (:symbol name "defining ~S as a function") + (setf defined-fun + (if inline-lambda + (get-defined-fun name (fifth inline-lambda)) + (get-defined-fun name)))) (when (boundp '*lexenv*) (remhash name *free-funs*) (aver (fasl-output-p *compile-object*)) (if (member name *fun-names-in-this-file* :test #'equal) (warn 'duplicate-definition :name name) - (push name *fun-names-in-this-file*)))) + (push name *fun-names-in-this-file*))) + (%set-inline-expansion name defined-fun inline-lambda)) (become-defined-fun-name name) - (cond (lambda-with-lexenv - (setf (info :function :inline-expansion-designator name) - lambda-with-lexenv) - (when defined-fun - (setf (defined-fun-inline-expansion defined-fun) - lambda-with-lexenv))) - (t - (clear-info :function :inline-expansion-designator name))) - ;; old CMU CL comment: ;; If there is a type from a previous definition, blast it, ;; since it is obsolete.