-
-;;; Given a function, return three values:
-;;; 1] A lambda expression that could be used to define the function,
-;;; or NIL if the definition isn't available.
-;;; 2] NIL if the function was definitely defined in a null lexical
-;;; environment, and T otherwise.
-;;; 3] Some object that \"names\" the function. Although this is
-;;; allowed to be any object, CMU CL always returns a valid
-;;; function name or a string.
-;;;
-;;; If interpreted, use the interpreter interface. Otherwise, see
-;;; whether it was compiled with COMPILE. If that fails, check for an
-;;; inline expansion.
-(defun function-lambda-expression (fun)
- (declare (type function fun))
- (let* ((fun (%function-self fun))
- (name (%function-name fun))
- (code (sb!di::function-code-header fun))
- (info (sb!kernel:%code-debug-info code)))
- (if info
- (let ((source (first (sb!c::compiled-debug-info-source info))))
- (cond ((and (eq (sb!c::debug-source-from source) :lisp)
- (eq (sb!c::debug-source-info source) fun))
- (values (second (svref (sb!c::debug-source-name source) 0))
- nil name))
- ((stringp name)
- (values nil t name))
- (t
- (let ((exp (info :function :inline-expansion name)))
- (if exp
- (values exp nil name)
- (values nil t name))))))
- (values nil t name))))