0.8.14.13: Step SBCL, step!
[sbcl.git] / src / compiler / ir1tran-lambda.lisp
index 00b7720..632d189 100644 (file)
            (list body aux-vars aux-vals))
   (if (null aux-vars)
       (ir1-convert-progn-body start next result body)
-      (let ((fun-ctran (make-ctran))
+      (let ((ctran (make-ctran))
             (fun-lvar (make-lvar))
            (fun (ir1-convert-lambda-body body
                                          (list (first aux-vars))
                                          :aux-vars (rest aux-vars)
                                          :aux-vals (rest aux-vals)
                                          :debug-name (debug-namify
-                                                      "&AUX bindings ~S"
+                                                      "&AUX bindings " 
                                                       aux-vars))))
-       (reference-leaf start fun-ctran fun-lvar fun)
-       (ir1-convert-combination-args fun-ctran fun-lvar next result
+       (reference-leaf start ctran fun-lvar fun)
+       (ir1-convert-combination-args fun-lvar ctran next result
                                      (list (first aux-vals)))))
   (values))
 
 ;;; the body, otherwise we do one special binding and recurse on the
 ;;; rest.
 ;;;
-;;; We make a cleanup and introduce it into the lexical environment.
-;;; If there are multiple special bindings, the cleanup for the blocks
-;;; will end up being the innermost one. We force CONT to start a
-;;; block outside of this cleanup, causing cleanup code to be emitted
-;;; when the scope is exited.
+;;; We make a cleanup and introduce it into the lexical
+;;; environment. If there are multiple special bindings, the cleanup
+;;; for the blocks will end up being the innermost one. We force NEXT
+;;; to start a block outside of this cleanup, causing cleanup code to
+;;; be emitted when the scope is exited.
 (defun ir1-convert-special-bindings
     (start next result body aux-vars aux-vals svars)
   (declare (type ctran start next) (type (or lvar null) result)
 ;;; the special binding code.
 ;;;
 ;;; We ignore any ARG-INFO in the VARS, trusting that someone else is
-;;; dealing with &nonsense.
+;;; dealing with &NONSENSE, except for &REST vars with DYNAMIC-EXTENT.
 ;;;
 ;;; AUX-VARS is a list of VAR structures for variables that are to be
 ;;; sequentially bound. Each AUX-VAL is a form that is to be evaluated
         (result-ctran (make-ctran))
          (result-lvar (make-lvar)))
 
+    (awhen (lexenv-lambda *lexenv*)
+      (push lambda (lambda-children it))
+      (setf (lambda-parent lambda) it))
+
     ;; just to check: This function should fail internal assertions if
     ;; we didn't set up a valid debug name above.
     ;;
             (ctran-starts-block prebind-ctran)
             (link-node-to-previous-ctran bind prebind-ctran)
             (use-ctran bind postbind-ctran)
-            (ir1-convert-special-bindings postbind-ctran result-ctran result-lvar
-                                          body
+           (ir1-convert-special-bindings postbind-ctran result-ctran
+                                          result-lvar body
                                           aux-vars aux-vals (svars))))))
 
     (link-blocks (component-head *current-component*) (node-block bind))
                                                        ,@(default-vals))))
                                          arg-vars
                                          :debug-name
-                                         (debug-namify "&OPTIONAL processor ~D"
-                                                       (random 100))
+                                         (debug-namify "&OPTIONAL processor "
+                                                      (gensym))
                                          :note-lexical-bindings nil))))
     (mapc (lambda (var arg-var)
            (when (cdr (leaf-refs arg-var))
       (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))
                 (tests `((eq ,n-key :allow-other-keys)
                          (setq ,n-allowp ,n-value-temp))))
              (tests `(t
-                      (setq ,n-losep ,n-key))))
+                      (setq ,n-losep (list ,n-key)))))
 
            (body
             `(when (oddp ,n-count)
 
            (unless allowp
              (body `(when (and ,n-losep (not ,n-allowp))
-                      (%unknown-key-arg-error ,n-losep)))))))
+                      (%unknown-key-arg-error (car ,n-losep))))))))
 
       (let ((ep (ir1-convert-lambda-body
                 `((let ,(temps)
                     (%funcall ,(optional-dispatch-main-entry res)
                               ,@(arg-vals))))
                 (arg-vars)
-                :debug-name (debug-namify "~S processing" '&more)
+                :debug-name "&MORE processing"
                  :note-lexical-bindings nil)))
        (setf (optional-dispatch-more-entry res)
               (register-entry-point ep res)))))
                        body (main-vars)
                        :aux-vars (append (bind-vars) aux-vars)
                        :aux-vals (append (bind-vals) aux-vals)
-                       :debug-name (debug-namify "varargs entry for ~A"
-                                                 (as-debug-name source-name
-                                                                debug-name))))
+                       :debug-name (debug-namify
+                                    "varargs entry for " source-name debug-name)))
           (last-entry (convert-optional-entry main-entry default-vars
                                               (main-vals) ())))
       (setf (optional-dispatch-main-entry res)
                         :aux-vars aux-vars
                         :aux-vals aux-vals
                         :debug-name (debug-namify
-                                     "hairy arg processor for ~A"
-                                     (as-debug-name source-name
-                                                    debug-name)))))
+                                     "hairy arg processor for "
+                                     source-name
+                                     debug-name))))
                (setf (optional-dispatch-main-entry res) fun)
                (register-entry-point fun res)
                (push (if supplied-p-p
                                      &key
                                      (source-name '.anonymous.)
                                      (debug-name (debug-namify
-                                                  "OPTIONAL-DISPATCH ~S"
+                                                  "OPTIONAL-DISPATCH "
                                                   vars)))
   (declare (list body vars aux-vars aux-vals))
   (let ((res (make-optional-dispatch :arglist vars
                     (process-decls decls (append aux-vars vars) nil))
                    (forms (if (and *allow-debug-catch-tag*
                                    (policy *lexenv* (>= insert-debug-catch 2)))
-                              `((catch (make-symbol "SB-DEBUG-CATCH-TAG")
+                              `((catch (locally (declare (optimize (insert-step-conditions 0)))
+                                         (make-symbol "SB-DEBUG-CATCH-TAG"))
                                   ,@forms))
                               forms))
                    (forms (if (eq result-type *wild-type*)
                                      (source-name '.anonymous.)
                                      debug-name
                                      allow-debug-catch-tag)
+  (declare (ignore allow-debug-catch-tag))
   (destructuring-bind (decls macros symbol-macros &rest body)
                      (if (eq (car fun) 'lambda-with-lexenv)
                          (cdr fun)
 ;;;
 ;;; The INLINE-EXPANSION is a LAMBDA-WITH-LEXENV, or NIL if there is
 ;;; no inline expansion.
-(defun %compiler-defun (name lambda-with-lexenv)
+(defun %compiler-defun (name lambda-with-lexenv compile-toplevel)
 
   (let ((defined-fun nil)) ; will be set below if we're in the compiler
 
-    (when (boundp '*lexenv*) ; when in the compiler
+    (when compile-toplevel
+      ;; better be in the compiler
+      (aver (boundp '*lexenv*)) 
       (when sb!xc:*compile-print*
        (compiler-mumble "~&; recognizing DEFUN ~S~%" name))
       (remhash name *free-funs*)
-      (setf defined-fun (get-defined-fun name)))
+      (setf defined-fun (get-defined-fun name))
 
-    (become-defined-fun-name name)
+      (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*)))
 
+    (become-defined-fun-name name)
+    
     (cond (lambda-with-lexenv
           (setf (info :function :inline-expansion-designator name)
                 lambda-with-lexenv)