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)))
         (bare-name (bare-symbol name))
         (byte-compile-current-form name)) ; For warnings.

    (push bare-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 bare-name byte-compile-call-tree)
            (setq byte-compile-call-tree
                  (cons (list bare-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 "") bare-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 bare-name byte-compile-initial-macro-environment)))
               (byte-compile-warn-x
                name
                "`%s' defined multiple times, as both function and macro"
                bare-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 bare-name byte-compile-initial-macro-environment)))
             (byte-compile-warn-x
              name
              "%s `%s' defined multiple times in this file"
              (if macro "macro" "function")
              bare-name)))
          ((eq (car-safe (symbol-function bare-name))
               (if macro 'lambda 'macro))
           (when (byte-compile-warning-enabled-p 'redefine bare-name)
             (byte-compile-warn-x
              name
              "%s `%s' being redefined as a %s"
              (if macro "function" "macro")
              bare-name
              (if macro "macro" "function")))
           ;; Shadow existing definition.
           (set this-kind
                (cons (cons bare-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)))))
      (byte-compile-warn-x
       name "probable `\"' without `\\' in doc string of %s" bare-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 bare-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 bare-name byte-compile-initial-macro-environment))
                (setcdr this-one code))
          (set this-kind
               (cons (cons bare-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 '"
             bare-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)))))