Function: byte-compile-file-form-defmumble
byte-compile-file-form-defmumble is a byte-compiled function defined
in bytecomp.el.gz.
Signature
(byte-compile-file-form-defmumble NAME MACRO ARGLIST BODY REST)
Documentation
Process a defalias for NAME.
If MACRO is non-nil, the definition is known to be a macro. ARGLIST is the list of arguments, if it was recognized or t otherwise. BODY of the definition, or t if not recognized. Return non-nil if everything went as planned, or nil to imply that it decided not to take responsibility for the actual compilation of the code.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile-file-form-defmumble (name macro arglist body rest)
"Process a `defalias' for NAME.
If MACRO is non-nil, the definition is known to be a macro.
ARGLIST is the list of arguments, if it was recognized or t otherwise.
BODY of the definition, or t if not recognized.
Return non-nil if everything went as planned, or nil to imply that it decided
not to take responsibility for the actual compilation of the code."
(let* ((this-kind (if macro 'byte-compile-macro-environment
'byte-compile-function-environment))
(that-kind (if macro 'byte-compile-function-environment
'byte-compile-macro-environment))
(this-one (assq name (symbol-value this-kind)))
(that-one (assq name (symbol-value that-kind)))
(byte-compile-current-form name)) ; For warnings.
(byte-compile-set-symbol-position name)
(push name byte-compile-new-defuns)
;; When a function or macro is defined, add it to the call tree so that
;; we can tell when functions are not used.
(if byte-compile-generate-call-tree
(or (assq name byte-compile-call-tree)
(setq byte-compile-call-tree
(cons (list name nil nil) byte-compile-call-tree))))
(if (byte-compile-warning-enabled-p 'redefine name)
(byte-compile-arglist-warn name arglist macro))
(if byte-compile-verbose
(message "Compiling %s... (%s)"
(or byte-compile-current-file "") name))
(cond ((not (or macro (listp body)))
;; We do not know positively if the definition is a macro
;; or a function, so we shouldn't emit warnings.
;; This also silences "multiple definition" warnings for defmethods.
nil)
(that-one
(if (and (byte-compile-warning-enabled-p 'redefine name)
;; Don't warn when compiling the stubs in byte-run...
(not (assq name byte-compile-initial-macro-environment)))
(byte-compile-warn
"`%s' defined multiple times, as both function and macro"
name))
(setcdr that-one nil))
(this-one
(when (and (byte-compile-warning-enabled-p 'redefine name)
;; Hack: Don't warn when compiling the magic internal
;; byte-compiler macros in byte-run.el...
(not (assq name byte-compile-initial-macro-environment)))
(byte-compile-warn "%s `%s' defined multiple times in this file"
(if macro "macro" "function")
name)))
((eq (car-safe (symbol-function name))
(if macro 'lambda 'macro))
(when (byte-compile-warning-enabled-p 'redefine name)
(byte-compile-warn "%s `%s' being redefined as a %s"
(if macro "function" "macro")
name
(if macro "macro" "function")))
;; Shadow existing definition.
(set this-kind
(cons (cons name nil)
(symbol-value this-kind))))
)
(when (and (listp body)
(stringp (car body))
(symbolp (car-safe (cdr-safe body)))
(car-safe (cdr-safe body))
(stringp (car-safe (cdr-safe (cdr-safe body)))))
;; FIXME: We've done that already just above, so this looks wrong!
;;(byte-compile-set-symbol-position name)
(byte-compile-warn "probable `\"' without `\\' in doc string of %s"
name))
(if (not (listp body))
;; The precise definition requires evaluation to find out, so it
;; will only be known at runtime.
;; For a macro, that means we can't use that macro in the same file.
(progn
(unless macro
(push (cons name (if (listp arglist) `(declared ,arglist) t))
byte-compile-function-environment))
;; Tell the caller that we didn't compile it yet.
nil)
(let* ((code (byte-compile-lambda (cons arglist body) t)))
(if this-one
;; A definition in b-c-initial-m-e should always take precedence
;; during compilation, so don't let it be redefined. (Bug#8647)
(or (and macro
(assq name byte-compile-initial-macro-environment))
(setcdr this-one code))
(set this-kind
(cons (cons name code)
(symbol-value this-kind))))
(if rest
;; There are additional args to `defalias' (like maybe a docstring)
;; that the code below can't handle: punt!
nil
;; Otherwise, we have a bona-fide defun/defmacro definition, and use
;; special code to allow dynamic docstrings and byte-code.
(byte-compile-flush-pending)
(let ((index
;; If there's no doc string, provide -1 as the "doc string
;; index" so that no element will be treated as a doc string.
(if (not (stringp (documentation code t))) -1 4)))
(when byte-native-compiling
;; Spill output for the native compiler here.
(push (if macro
(make-byte-to-native-top-level
:form `(defalias ',name '(macro . ,code) nil)
:lexical lexical-binding)
(make-byte-to-native-func-def :name name
:byte-func code))
byte-to-native-top-level-forms))
;; Output the form by hand, that's much simpler than having
;; b-c-output-file-form analyze the defalias.
(byte-compile-output-docform
"\n(defalias '"
name
(if macro `(" '(macro . #[" ,index "])") `(" #[" ,index "]"))
(append code nil) ; Turn byte-code-function-p into list.
(and (atom code) byte-compile-dynamic
1)
nil))
(princ ")" byte-compile--outbuffer)
t)))))