Function: byte-compile-eval

byte-compile-eval is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile-eval FORM)

Documentation

Eval FORM and mark the functions defined therein.

Each function's symbol gets added to byte-compile-noruntime-functions.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
;;; compile-time evaluation

(defun byte-compile-eval (form)
  "Eval FORM and mark the functions defined therein.
Each function's symbol gets added to `byte-compile-noruntime-functions'."
  (let ((hist-orig load-history)
	(hist-nil-orig current-load-list))
    (prog1 (eval form lexical-binding)
      (when (byte-compile-warning-enabled-p 'noruntime)
	(let* ((hist-new
                ;; Get new `current-load-list' for the locally defined funs.
                (cons (butlast current-load-list
                               (length hist-nil-orig))
                      load-history)))
	  ;; Go through load-history, look for newly loaded files
	  ;; and mark all the functions defined therein.
	  (while (and hist-new (not (eq hist-new hist-orig)))
	    (let ((xs (pop hist-new)))
	      ;; Make sure the file was not already loaded before.
	      (unless (assoc (car xs) hist-orig)
		(dolist (s xs)
		  (pcase s
		    (`(defun . ,f)
		     ;; If `f' has a history, it's presumably because
		     ;; it was already defined beforehand (typically
		     ;; as an autoload).  It could also be because it
		     ;; was defined twice during `form', in which case
		     ;; we arguably should add it to b-c-noruntime-functions,
                     ;; but it's not clear it's worth the trouble
		     ;; trying to recognize that case.
		     (unless (or (get f 'function-history)
                                 (assq f byte-compile-function-environment))
                       (push f byte-compile-noruntime-functions)))))))))))))