Function: byte-compile-file-form-defalias
byte-compile-file-form-defalias is a byte-compiled function defined in
bytecomp.el.gz.
Signature
(byte-compile-file-form-defalias FORM)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
;; Used for eieio--defalias as well.
(defun byte-compile-file-form-defalias (form)
;; For the compilation itself, we could largely get rid of this hunk-handler,
;; if it weren't for the fact that we need to figure out when a defalias
;; defines a macro, so as to add it to byte-compile-macro-environment.
(let ((byte-compile-free-references nil)
(byte-compile-free-assignments nil))
(pcase form
;; Decompose `form' into:
;; - `name' is the name of the defined function.
;; - `arg' is the expression to which it is defined.
;; - `rest' is the rest of the arguments.
(`(,_ ',name ,arg . ,rest)
(let ((doc (car rest)))
(when (stringp doc)
(setq rest (byte-compile--list-with-n
rest 0
(byte-compile--docstring doc (nth 0 form) name)))))
(pcase-let*
;; `macro' is non-nil if it defines a macro.
;; `fun' is the function part of `arg' (defaults to `arg').
(((or (and (or `(cons 'macro ,fun) `'(macro . ,fun)) (let macro t))
(and (let fun arg) (let macro nil)))
arg)
;; `lam' is the lambda expression in `fun' (or nil if not
;; recognized).
((or `(,(or 'quote 'function) ,lam) (let lam nil))
fun)
;; `arglist' is the list of arguments (or t if not recognized).
;; `body' is the body of `lam' (or t if not recognized).
((or `(lambda ,arglist . ,body)
(and `(internal-make-closure ,arglist . ,_) (let body t))
(and (let arglist t) (let body t)))
lam))
(unless (byte-compile-file-form-defmumble
name macro arglist body rest)
(when macro
(if (null fun)
(message "Macro %s unrecognized, won't work in file" name)
(message "Macro %s partly recognized, trying our luck" name)
(push (cons name (eval fun))
byte-compile-macro-environment)))
(byte-compile-keep-pending form))))
;; We used to just do: (byte-compile-normal-call form)
;; But it turns out that this fails to optimize the code.
;; So instead we now do the same as what other byte-hunk-handlers do,
;; which is to call back byte-compile-file-form and then return nil.
;; Except that we can't just call byte-compile-file-form since it would
;; call us right back.
(_ (byte-compile-keep-pending form)))))